From 41a372de2b9af207b237c6abcd1cbe256319b4cb Mon Sep 17 00:00:00 2001 From: Maksim An Date: Wed, 1 Dec 2021 23:52:06 -0800 Subject: [PATCH 1/5] Add new guest request/resource packages hcsshim and GCS redefine protocol messages. Any change to the protocol requires redifinitions in both hcsshim and GCS. This PR combines the two protocol definitions into one to resolve this. Create new guestrequest and guestresource internal packages and update references in code. Signed-off-by: Maksim An --- cmd/containerd-shim-runhcs-v1/exec_hcs.go | 19 +- cmd/containerd-shim-runhcs-v1/task_hcs.go | 14 +- internal/guest/bridge/bridge_v2.go | 10 +- internal/guest/prot/protocol.go | 184 +++--------------- internal/guest/runtime/hcsv2/container.go | 17 +- internal/guest/runtime/hcsv2/network.go | 16 +- internal/guest/runtime/hcsv2/network_test.go | 4 +- internal/guest/runtime/hcsv2/uvm.go | 103 +++++----- .../guest/storage/devicemapper/targets.go | 14 +- internal/guest/storage/pmem/pmem.go | 30 ++- internal/guest/storage/pmem/pmem_test.go | 39 ++-- internal/guest/storage/scsi/scsi.go | 33 +++- internal/guest/storage/scsi/scsi_test.go | 13 +- internal/hcs/process.go | 4 +- .../hcs/schema2/modify_setting_request.go | 4 +- internal/hcs/schema2/plan9_share.go | 2 +- internal/hcsoci/clone.go | 6 +- internal/hns/hnspolicylist.go | 2 +- internal/jobcontainers/process.go | 9 +- internal/requesttype/types.go | 11 -- internal/signals/signal.go | 23 +-- internal/signals/signal_test.go | 2 +- internal/uvm/capabilities.go | 2 +- internal/uvm/combine_layers.go | 38 ++-- internal/uvm/computeagent.go | 22 +-- internal/uvm/create.go | 7 +- internal/uvm/create_wcow.go | 5 +- internal/uvm/hvsocket.go | 6 +- internal/uvm/modify.go | 8 +- internal/uvm/network.go | 68 +++---- internal/uvm/pipes.go | 6 +- internal/uvm/plan9.go | 24 +-- internal/uvm/scsi.go | 43 ++-- internal/uvm/security_policy.go | 12 +- internal/uvm/share.go | 10 +- internal/uvm/start.go | 15 +- internal/uvm/stats.go | 7 +- internal/uvm/virtual_device.go | 17 +- internal/uvm/vpmem.go | 30 +-- internal/uvm/vpmem_mapped.go | 30 +-- internal/uvm/vsmb.go | 15 +- internal/vm/hcs/network.go | 6 +- internal/vm/hcs/pci.go | 6 +- internal/vm/hcs/plan9.go | 6 +- internal/vm/hcs/scsi.go | 9 +- internal/vm/hcs/vpmem.go | 9 +- internal/vm/hcs/vsmb.go | 6 +- pkg/protocol/guestrequest/types.go | 43 ++++ .../protocol/guestresource/resources.go | 110 +++++------ .../Microsoft/hcsshim/internal/hcs/process.go | 4 +- .../hcs/schema2/modify_setting_request.go | 4 +- .../internal/hcs/schema2/plan9_share.go | 2 +- .../hcsshim/internal/hcsoci/clone.go | 6 +- .../hcsshim/internal/hns/hnspolicylist.go | 2 +- .../hcsshim/internal/requesttype/types.go | 11 -- .../hcsshim/internal/uvm/capabilities.go | 2 +- .../hcsshim/internal/uvm/combine_layers.go | 38 ++-- .../hcsshim/internal/uvm/computeagent.go | 22 +-- .../Microsoft/hcsshim/internal/uvm/create.go | 7 +- .../hcsshim/internal/uvm/create_wcow.go | 5 +- .../hcsshim/internal/uvm/hvsocket.go | 6 +- .../Microsoft/hcsshim/internal/uvm/modify.go | 8 +- .../Microsoft/hcsshim/internal/uvm/network.go | 68 +++---- .../Microsoft/hcsshim/internal/uvm/pipes.go | 6 +- .../Microsoft/hcsshim/internal/uvm/plan9.go | 24 +-- .../Microsoft/hcsshim/internal/uvm/scsi.go | 43 ++-- .../hcsshim/internal/uvm/security_policy.go | 12 +- .../Microsoft/hcsshim/internal/uvm/share.go | 10 +- .../Microsoft/hcsshim/internal/uvm/start.go | 15 +- .../Microsoft/hcsshim/internal/uvm/stats.go | 7 +- .../hcsshim/internal/uvm/virtual_device.go | 17 +- .../Microsoft/hcsshim/internal/uvm/vpmem.go | 30 +-- .../hcsshim/internal/uvm/vpmem_mapped.go | 30 +-- .../Microsoft/hcsshim/internal/uvm/vsmb.go | 15 +- .../pkg/protocol/guestrequest/types.go | 43 ++++ .../protocol/guestresource/resources.go} | 110 +++++------ test/vendor/modules.txt | 4 +- 77 files changed, 833 insertions(+), 837 deletions(-) delete mode 100644 internal/requesttype/types.go create mode 100644 pkg/protocol/guestrequest/types.go rename internal/guestrequest/types.go => pkg/protocol/guestresource/resources.go (60%) delete mode 100644 test/vendor/github.com/Microsoft/hcsshim/internal/requesttype/types.go create mode 100644 test/vendor/github.com/Microsoft/hcsshim/pkg/protocol/guestrequest/types.go rename test/vendor/github.com/Microsoft/hcsshim/{internal/guestrequest/types.go => pkg/protocol/guestresource/resources.go} (60%) diff --git a/cmd/containerd-shim-runhcs-v1/exec_hcs.go b/cmd/containerd-shim-runhcs-v1/exec_hcs.go index d176986432..a1ff2aeb28 100644 --- a/cmd/containerd-shim-runhcs-v1/exec_hcs.go +++ b/cmd/containerd-shim-runhcs-v1/exec_hcs.go @@ -5,13 +5,6 @@ import ( "sync" "time" - "github.com/Microsoft/hcsshim/internal/cmd" - "github.com/Microsoft/hcsshim/internal/cow" - "github.com/Microsoft/hcsshim/internal/guestrequest" - "github.com/Microsoft/hcsshim/internal/log" - "github.com/Microsoft/hcsshim/internal/signals" - "github.com/Microsoft/hcsshim/internal/uvm" - "github.com/Microsoft/hcsshim/osversion" eventstypes "github.com/containerd/containerd/api/events" containerd_v1_types "github.com/containerd/containerd/api/types/task" "github.com/containerd/containerd/errdefs" @@ -21,6 +14,14 @@ import ( "github.com/pkg/errors" "github.com/sirupsen/logrus" "go.opencensus.io/trace" + + "github.com/Microsoft/hcsshim/internal/cmd" + "github.com/Microsoft/hcsshim/internal/cow" + "github.com/Microsoft/hcsshim/internal/log" + "github.com/Microsoft/hcsshim/internal/signals" + "github.com/Microsoft/hcsshim/internal/uvm" + "github.com/Microsoft/hcsshim/osversion" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) // newHcsExec creates an exec to track the lifetime of `spec` in `c` which is @@ -268,13 +269,13 @@ func (he *hcsExec) Kill(ctx context.Context, signal uint32) error { var options interface{} var err error if he.isWCOW { - var opt *guestrequest.SignalProcessOptionsWCOW + var opt *guestresource.SignalProcessOptionsWCOW opt, err = signals.ValidateWCOW(int(signal), supported) if opt != nil { options = opt } } else { - var opt *guestrequest.SignalProcessOptionsLCOW + var opt *guestresource.SignalProcessOptionsLCOW opt, err = signals.ValidateLCOW(int(signal), supported) if opt != nil { options = opt diff --git a/cmd/containerd-shim-runhcs-v1/task_hcs.go b/cmd/containerd-shim-runhcs-v1/task_hcs.go index 07f6d15d31..1b3d4cbb61 100644 --- a/cmd/containerd-shim-runhcs-v1/task_hcs.go +++ b/cmd/containerd-shim-runhcs-v1/task_hcs.go @@ -22,7 +22,6 @@ import ( "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/stats" "github.com/Microsoft/hcsshim/internal/cmd" "github.com/Microsoft/hcsshim/internal/cow" - "github.com/Microsoft/hcsshim/internal/guestrequest" "github.com/Microsoft/hcsshim/internal/hcs" "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" "github.com/Microsoft/hcsshim/internal/hcs/schema1" @@ -32,12 +31,13 @@ import ( "github.com/Microsoft/hcsshim/internal/log" "github.com/Microsoft/hcsshim/internal/oci" "github.com/Microsoft/hcsshim/internal/processorinfo" - "github.com/Microsoft/hcsshim/internal/requesttype" "github.com/Microsoft/hcsshim/internal/resources" "github.com/Microsoft/hcsshim/internal/shimdiag" "github.com/Microsoft/hcsshim/internal/uvm" "github.com/Microsoft/hcsshim/osversion" "github.com/Microsoft/hcsshim/pkg/annotations" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) const bytesPerMB = 1024 * 1024 @@ -1028,7 +1028,7 @@ func (ht *hcsTask) updateLCOWResources(ctx context.Context, data interface{}, an if !ok || resources == nil { return errors.New("must have resources be non-nil and type *LinuxResources when updating a lcow container") } - settings := guestrequest.LCOWContainerConstraints{ + settings := guestresource.LCOWContainerConstraints{ Linux: *resources, } return ht.requestUpdateContainer(ctx, "", settings) @@ -1039,13 +1039,13 @@ func (ht *hcsTask) requestUpdateContainer(ctx context.Context, resourcePath stri if ht.isWCOW { modification = &hcsschema.ModifySettingRequest{ ResourcePath: resourcePath, - RequestType: requesttype.Update, + RequestType: guestrequest.RequestTypeUpdate, Settings: settings, } } else { - modification = guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeContainerConstraints, - RequestType: requesttype.Update, + modification = guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeContainerConstraints, + RequestType: guestrequest.RequestTypeUpdate, Settings: settings, } } diff --git a/internal/guest/bridge/bridge_v2.go b/internal/guest/bridge/bridge_v2.go index 4830b02f2b..098add6800 100644 --- a/internal/guest/bridge/bridge_v2.go +++ b/internal/guest/bridge/bridge_v2.go @@ -9,6 +9,10 @@ import ( "syscall" "time" + "github.com/pkg/errors" + "go.opencensus.io/trace" + "golang.org/x/sys/unix" + "github.com/Microsoft/hcsshim/internal/debug" "github.com/Microsoft/hcsshim/internal/guest/commonutils" "github.com/Microsoft/hcsshim/internal/guest/gcserr" @@ -17,9 +21,7 @@ import ( "github.com/Microsoft/hcsshim/internal/guest/stdio" "github.com/Microsoft/hcsshim/internal/log" "github.com/Microsoft/hcsshim/internal/oc" - "github.com/pkg/errors" - "go.opencensus.io/trace" - "golang.org/x/sys/unix" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" ) // The capabilities of this GCS. @@ -480,7 +482,7 @@ func (b *Bridge) modifySettingsV2(r *Request) (_ RequestResponse, err error) { return nil, errors.Wrapf(err, "failed to unmarshal JSON in message \"%s\"", r.Message) } - err = b.hostState.ModifySettings(ctx, request.ContainerID, request.Request.(*prot.ModifySettingRequest)) + err = b.hostState.ModifySettings(ctx, request.ContainerID, request.Request.(*guestrequest.ModificationRequest)) if err != nil { return nil, err } diff --git a/internal/guest/prot/protocol.go b/internal/guest/prot/protocol.go index 4ae4272345..39b7e85822 100644 --- a/internal/guest/prot/protocol.go +++ b/internal/guest/prot/protocol.go @@ -7,11 +7,15 @@ import ( "encoding/json" "strconv" - "github.com/Microsoft/hcsshim/internal/guest/commonutils" - "github.com/Microsoft/hcsshim/pkg/securitypolicy" v1 "github.com/containerd/cgroups/stats/v1" oci "github.com/opencontainers/runtime-spec/specs-go" "github.com/pkg/errors" + + "github.com/Microsoft/hcsshim/internal/guest/commonutils" + hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/pkg/securitypolicy" ) //////////// Code for the Message Header //////////// @@ -217,7 +221,7 @@ const MessageHeaderSize = 16 ///////////////////////////////////////////////////// -// ProtocolVersion is a type for the seclected HCS<->GCS protocol version of +// ProtocolVersion is a type for the selected HCS<->GCS protocol version of // messages type ProtocolVersion uint32 @@ -499,53 +503,6 @@ type ResourceModificationRequestResponse struct { Settings interface{} `json:",omitempty"` } -// ModifyResourceType is the type of resource, such as memory or virtual disk, -// which is to be modified for the container. This is the V2 schema equivalent -// of PropertyType. -type ModifyResourceType string - -const ( - // MrtMappedDirectory is the modify resource type for mapped directories - MrtMappedDirectory = ModifyResourceType("MappedDirectory") - // MrtMappedVirtualDisk is the modify resource type for mapped virtual - // disks - MrtMappedVirtualDisk = ModifyResourceType("MappedVirtualDisk") - // MrtCombinedLayers is the modify resource type for combined layers - MrtCombinedLayers = ModifyResourceType("CombinedLayers") - // MrtVPMemDevice is the modify resource type for VPMem devices - MrtVPMemDevice = ModifyResourceType("VPMemDevice") - // MrtNetwork is the modify resource type for the `NetworkAdapterV2` device. - MrtNetwork = ModifyResourceType("Network") - // MrtVPCIDevice is the modify resource type for vpci devices - MrtVPCIDevice = ModifyResourceType("VPCIDevice") - // MrtContainerConstraints is the modify resource type for updating container constraints - MrtContainerConstraints = ModifyResourceType("ContainerConstraints") - // MrtSecurityPolicy is the modify resource type for updating the security policy - MrtSecurityPolicy = ModifyResourceType("SecurityPolicy") -) - -// ModifyRequestType is the type of operation to perform on a given modify -// resource type. This is the V2 schema equivalent of RequestType. -type ModifyRequestType string - -const ( - // MreqtAdd is the "Add" modify request type - MreqtAdd = ModifyRequestType("Add") - // MreqtRemove is the "Remove" modify request type - MreqtRemove = ModifyRequestType("Remove") - // MreqtUpdate is the "Update" modify request type - MreqtUpdate = ModifyRequestType("Update") -) - -// ModifySettingRequest details a container resource which should be modified, -// how, and with what parameters. This is the V2 schema equivalent of -// ResourceModificationRequestResponse. -type ModifySettingRequest struct { - ResourceType ModifyResourceType `json:",omitempty"` - RequestType ModifyRequestType `json:",omitempty"` - Settings interface{} `json:",omitempty"` -} - // ContainerModifySettings is the message from the HCS specifying how a certain // container resource should be modified. type ContainerModifySettings struct { @@ -566,7 +523,7 @@ func UnmarshalContainerModifySettings(b []byte) (*ContainerModifySettings, error return nil, errors.Wrap(err, "failed to unmarshal ContainerModifySettings") } - var msr ModifySettingRequest + var msr guestrequest.ModificationRequest var msrRawSettings json.RawMessage msr.Settings = &msrRawSettings if err := commonutils.UnmarshalJSONWithHresult(requestRawSettings, &msr); err != nil { @@ -574,54 +531,54 @@ func UnmarshalContainerModifySettings(b []byte) (*ContainerModifySettings, error } if msr.RequestType == "" { - msr.RequestType = MreqtAdd + msr.RequestType = guestrequest.RequestTypeAdd } // Fill in the ResourceType-specific fields. switch msr.ResourceType { - case MrtMappedVirtualDisk: - mvd := &MappedVirtualDiskV2{} + case guestresource.ResourceTypeMappedVirtualDisk: + mvd := &guestresource.LCOWMappedVirtualDisk{} if err := commonutils.UnmarshalJSONWithHresult(msrRawSettings, mvd); err != nil { return &request, errors.Wrap(err, "failed to unmarshal settings as MappedVirtualDiskV2") } msr.Settings = mvd - case MrtMappedDirectory: - md := &MappedDirectoryV2{} + case guestresource.ResourceTypeMappedDirectory: + md := &guestresource.LCOWMappedDirectory{} if err := commonutils.UnmarshalJSONWithHresult(msrRawSettings, md); err != nil { return &request, errors.Wrap(err, "failed to unmarshal settings as MappedDirectoryV2") } msr.Settings = md - case MrtVPMemDevice: - vpd := &MappedVPMemDeviceV2{} + case guestresource.ResourceTypeVPMemDevice: + vpd := &guestresource.LCOWMappedVPMemDevice{} if err := commonutils.UnmarshalJSONWithHresult(msrRawSettings, vpd); err != nil { return &request, errors.Wrap(err, "failed to unmarshal hosted settings as MappedVPMemDeviceV2") } msr.Settings = vpd - case MrtCombinedLayers: - cl := &CombinedLayersV2{} + case guestresource.ResourceTypeCombinedLayers: + cl := &guestresource.LCOWCombinedLayers{} if err := commonutils.UnmarshalJSONWithHresult(msrRawSettings, cl); err != nil { return &request, errors.Wrap(err, "failed to unmarshal settings as CombinedLayersV2") } msr.Settings = cl - case MrtNetwork: - na := &NetworkAdapterV2{} + case guestresource.ResourceTypeNetwork: + na := &guestresource.LCOWNetworkAdapter{} if err := commonutils.UnmarshalJSONWithHresult(msrRawSettings, na); err != nil { return &request, errors.Wrap(err, "failed to unmarshal settings as NetworkAdapterV2") } msr.Settings = na - case MrtVPCIDevice: - vd := &MappedVPCIDeviceV2{} + case guestresource.ResourceTypeVPCIDevice: + vd := &guestresource.LCOWMappedVPCIDevice{} if err := commonutils.UnmarshalJSONWithHresult(msrRawSettings, vd); err != nil { return &request, errors.Wrap(err, "failed to unmarshal settings as MappedVPCIDeviceV2") } msr.Settings = vd - case MrtContainerConstraints: - cc := &ContainerConstraintsV2{} + case guestresource.ResourceTypeContainerConstraints: + cc := &guestresource.LCOWContainerConstraints{} if err := commonutils.UnmarshalJSONWithHresult(msrRawSettings, cc); err != nil { return &request, errors.Wrap(err, "failed to unmarshal settings as ContainerConstraintsV2") } msr.Settings = cc - case MrtSecurityPolicy: + case guestresource.ResourceTypeSecurityPolicy: policy := &securitypolicy.EncodedSecurityPolicy{} if err := commonutils.UnmarshalJSONWithHresult(msrRawSettings, policy); err != nil { return &request, errors.Wrap(err, "failed to unmarshal settings as EncodedSecurityPolicy") @@ -709,22 +666,6 @@ type ContainerGetPropertiesResponse struct { /* types added on to the current official protocol types */ -// Layer represents a filesystem layer for a container. -type Layer struct { - // Path is in this case the identifier (such as the SCSI number) of the - // layer device. - Path string -} - -// CombinedLayersV2 is a modify type that corresponds to MrtCombinedLayers -// request. -type CombinedLayersV2 struct { - Layers []Layer `json:",omitempty"` - ScratchPath string `json:",omitempty"` - ContainerRootPath string - ContainerId string `json:",omitempty"` -} - // NetworkAdapter represents a network interface and its associated // configuration. type NetworkAdapter struct { @@ -741,22 +682,6 @@ type NetworkAdapter struct { EncapOverhead uint16 `json:",omitempty"` } -// NetworkAdapterV2 represents a network interface and its associated -// configuration in a namespace. -type NetworkAdapterV2 struct { - NamespaceID string `json:",omitempty"` - ID string `json:",omitempty"` - MacAddress string `json:",omitempty"` - IPAddress string `json:",omitempty"` - PrefixLength uint8 `json:",omitempty"` - GatewayAddress string `json:",omitempty"` - DNSSuffix string `json:",omitempty"` - DNSServerList string `json:",omitempty"` - EnableLowMetric bool `json:",omitempty"` - EncapOverhead uint16 `json:",omitempty"` - VPCIAssigned bool `json:",omitempty"` -} - // MappedVirtualDisk represents a disk on the host which is mapped into a // directory in the guest. type MappedVirtualDisk struct { @@ -767,18 +692,6 @@ type MappedVirtualDisk struct { AttachOnly bool `json:",omitempty"` } -// MappedVirtualDiskV2 represents a disk on the host which is mapped into a -// directory in the guest in the V2 schema. -type MappedVirtualDiskV2 struct { - MountPath string `json:",omitempty"` - Lun uint8 `json:",omitempty"` - Controller uint8 `json:",omitempty"` - ReadOnly bool `json:",omitempty"` - Encrypted bool `json:",omitempty"` - Options []string `json:",omitempty"` - VerityInfo *DeviceVerityInfo `json:",omitempty"` -} - // MappedDirectory represents a directory on the host which is mapped to a // directory on the guest through a technology such as Plan9. type MappedDirectory struct { @@ -788,57 +701,10 @@ type MappedDirectory struct { Port uint32 `json:",omitempty"` } -// MappedDirectoryV2 represents a directory on the host which is mapped to a -// directory on the guest through Plan9 in the V2 schema. -type MappedDirectoryV2 struct { - MountPath string `json:",omitempty"` - Port uint32 `json:",omitempty"` - ShareName string `json:",omitempty"` - ReadOnly bool `json:",omitempty"` -} - -// DeviceMappingInfo represents a mapped device on a given VPMem -type DeviceMappingInfo struct { - DeviceOffsetInBytes int64 `json:",omitempty"` - DeviceSizeInBytes int64 `json:",omitempty"` -} - -// DeviceVerityInfo represents dm-verity information of a given data device. -// The assumption is that the hash device is the same as data device with -// verity data appended in the end. -type DeviceVerityInfo struct { - Ext4SizeInBytes int64 - Version int - Algorithm string - SuperBlock bool - RootDigest string - Salt string - BlockSize int -} - -// MappedVPMemDeviceV2 represents a VPMem device that is mapped into a guest -// path in the V2 schema. -type MappedVPMemDeviceV2 struct { - DeviceNumber uint32 `json:",omitempty"` - MountPath string `json:",omitempty"` - // MappingInfo is used when multiple devices are mapped onto a single VPMem device - MappingInfo *DeviceMappingInfo `json:",omitempty"` - VerityInfo *DeviceVerityInfo `json:",omitempty"` -} - -type MappedVPCIDeviceV2 struct { - VMBusGUID string `json:",omitempty"` -} - -type ContainerConstraintsV2 struct { - Windows oci.WindowsResources `json:",omitempty"` - Linux oci.LinuxResources `json:",omitempty"` -} - // VMHostedContainerSettings is the set of settings used to specify the initial // configuration of a container. type VMHostedContainerSettings struct { - Layers []Layer + Layers []hcsschema.Layer // SandboxDataPath is in this case the identifier (such as the SCSI number) // of the sandbox device. SandboxDataPath string diff --git a/internal/guest/runtime/hcsv2/container.go b/internal/guest/runtime/hcsv2/container.go index 3a44e71085..279552c8bd 100644 --- a/internal/guest/runtime/hcsv2/container.go +++ b/internal/guest/runtime/hcsv2/container.go @@ -8,6 +8,13 @@ import ( "sync" "syscall" + "github.com/containerd/cgroups" + v1 "github.com/containerd/cgroups/stats/v1" + oci "github.com/opencontainers/runtime-spec/specs-go" + "github.com/pkg/errors" + "github.com/sirupsen/logrus" + "go.opencensus.io/trace" + "github.com/Microsoft/hcsshim/internal/guest/gcserr" "github.com/Microsoft/hcsshim/internal/guest/prot" "github.com/Microsoft/hcsshim/internal/guest/runtime" @@ -16,12 +23,8 @@ import ( "github.com/Microsoft/hcsshim/internal/guest/transport" "github.com/Microsoft/hcsshim/internal/log" "github.com/Microsoft/hcsshim/internal/logfields" - "github.com/containerd/cgroups" - v1 "github.com/containerd/cgroups/stats/v1" - oci "github.com/opencontainers/runtime-spec/specs-go" - "github.com/pkg/errors" - "github.com/sirupsen/logrus" - "go.opencensus.io/trace" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) type Container struct { @@ -213,6 +216,6 @@ func (c *Container) GetStats(ctx context.Context) (*v1.Metrics, error) { return cg.Stat(cgroups.IgnoreNotExist) } -func (c *Container) modifyContainerConstraints(ctx context.Context, rt prot.ModifyRequestType, cc *prot.ContainerConstraintsV2) (err error) { +func (c *Container) modifyContainerConstraints(ctx context.Context, rt guestrequest.RequestType, cc *guestresource.LCOWContainerConstraints) (err error) { return c.Update(ctx, cc.Linux) } diff --git a/internal/guest/runtime/hcsv2/network.go b/internal/guest/runtime/hcsv2/network.go index 6a592b8240..277077f24d 100644 --- a/internal/guest/runtime/hcsv2/network.go +++ b/internal/guest/runtime/hcsv2/network.go @@ -10,13 +10,15 @@ import ( "sync" "time" + "github.com/pkg/errors" + "github.com/vishvananda/netns" + "go.opencensus.io/trace" + "github.com/Microsoft/hcsshim/internal/guest/gcserr" "github.com/Microsoft/hcsshim/internal/guest/network" "github.com/Microsoft/hcsshim/internal/guest/prot" "github.com/Microsoft/hcsshim/internal/oc" - "github.com/pkg/errors" - "github.com/vishvananda/netns" - "go.opencensus.io/trace" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) var ( @@ -130,11 +132,11 @@ func (n *namespace) AssignContainerPid(ctx context.Context, pid int) (err error) // Adapters returns a copy of the adapters assigned to `n` at the time of the // call. -func (n *namespace) Adapters() []*prot.NetworkAdapterV2 { +func (n *namespace) Adapters() []*guestresource.LCOWNetworkAdapter { n.m.Lock() defer n.m.Unlock() - adps := make([]*prot.NetworkAdapterV2, len(n.nics)) + adps := make([]*guestresource.LCOWNetworkAdapter, len(n.nics)) for i, nin := range n.nics { adps[i] = nin.adapter } @@ -144,7 +146,7 @@ func (n *namespace) Adapters() []*prot.NetworkAdapterV2 { // AddAdapter adds `adp` to `n` but does NOT move the adapter into the network // namespace assigned to `n`. A user must call `Sync()` to complete this // operation. -func (n *namespace) AddAdapter(ctx context.Context, adp *prot.NetworkAdapterV2) (err error) { +func (n *namespace) AddAdapter(ctx context.Context, adp *guestresource.LCOWNetworkAdapter) (err error) { ctx, span := trace.StartSpan(ctx, "namespace::AddAdapter") defer span.End() defer func() { oc.SetSpanStatus(span, err) }() @@ -232,7 +234,7 @@ func (n *namespace) Sync(ctx context.Context) (err error) { // guest and its mapping to the linux `ifname`. type nicInNamespace struct { // adapter captures the network settings when the nic was added - adapter *prot.NetworkAdapterV2 + adapter *guestresource.LCOWNetworkAdapter // ifname is the interface name resolved for this adapter ifname string // assignedPid will be `0` for any nic in this namespace that has not been diff --git a/internal/guest/runtime/hcsv2/network_test.go b/internal/guest/runtime/hcsv2/network_test.go index 3a428ba159..2fe1f0457c 100644 --- a/internal/guest/runtime/hcsv2/network_test.go +++ b/internal/guest/runtime/hcsv2/network_test.go @@ -7,7 +7,7 @@ import ( "context" "testing" - "github.com/Microsoft/hcsshim/internal/guest/prot" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) func Test_getNetworkNamespace_NotExist(t *testing.T) { @@ -101,7 +101,7 @@ func Test_removeNetworkNamespace_HasAdapters(t *testing.T) { networkInstanceIDToName = func(ctx context.Context, id string, _ bool) (string, error) { return "/dev/sdz", nil } - err := ns.AddAdapter(context.Background(), &prot.NetworkAdapterV2{ID: "test"}) + err := ns.AddAdapter(context.Background(), &guestresource.LCOWNetworkAdapter{ID: "test"}) if err != nil { t.Fatalf("failed to add adapter: %v", err) } diff --git a/internal/guest/runtime/hcsv2/uvm.go b/internal/guest/runtime/hcsv2/uvm.go index faf78eb7f7..9cac246208 100644 --- a/internal/guest/runtime/hcsv2/uvm.go +++ b/internal/guest/runtime/hcsv2/uvm.go @@ -16,6 +16,9 @@ import ( "syscall" "time" + shellwords "github.com/mattn/go-shellwords" + "github.com/pkg/errors" + "github.com/Microsoft/hcsshim/internal/guest/gcserr" "github.com/Microsoft/hcsshim/internal/guest/prot" "github.com/Microsoft/hcsshim/internal/guest/runtime" @@ -28,9 +31,9 @@ import ( "github.com/Microsoft/hcsshim/internal/guest/storage/scsi" "github.com/Microsoft/hcsshim/internal/guest/transport" "github.com/Microsoft/hcsshim/pkg/annotations" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" "github.com/Microsoft/hcsshim/pkg/securitypolicy" - shellwords "github.com/mattn/go-shellwords" - "github.com/pkg/errors" ) // UVMContainerID is the ContainerID that will be sent on any prot.MessageBase @@ -282,57 +285,57 @@ func (h *Host) CreateContainer(ctx context.Context, id string, settings *prot.VM return c, nil } -func (h *Host) modifyHostSettings(ctx context.Context, containerID string, settings *prot.ModifySettingRequest) error { - switch settings.ResourceType { - case prot.MrtMappedVirtualDisk: - return modifyMappedVirtualDisk(ctx, settings.RequestType, settings.Settings.(*prot.MappedVirtualDiskV2), h.securityPolicyEnforcer) - case prot.MrtMappedDirectory: - return modifyMappedDirectory(ctx, h.vsock, settings.RequestType, settings.Settings.(*prot.MappedDirectoryV2)) - case prot.MrtVPMemDevice: - return modifyMappedVPMemDevice(ctx, settings.RequestType, settings.Settings.(*prot.MappedVPMemDeviceV2), h.securityPolicyEnforcer) - case prot.MrtCombinedLayers: - return modifyCombinedLayers(ctx, settings.RequestType, settings.Settings.(*prot.CombinedLayersV2), h.securityPolicyEnforcer) - case prot.MrtNetwork: - return modifyNetwork(ctx, settings.RequestType, settings.Settings.(*prot.NetworkAdapterV2)) - case prot.MrtVPCIDevice: - return modifyMappedVPCIDevice(ctx, settings.RequestType, settings.Settings.(*prot.MappedVPCIDeviceV2)) - case prot.MrtContainerConstraints: +func (h *Host) modifyHostSettings(ctx context.Context, containerID string, req *guestrequest.ModificationRequest) error { + switch req.ResourceType { + case guestresource.ResourceTypeMappedVirtualDisk: + return modifyMappedVirtualDisk(ctx, req.RequestType, req.Settings.(*guestresource.LCOWMappedVirtualDisk), h.securityPolicyEnforcer) + case guestresource.ResourceTypeMappedDirectory: + return modifyMappedDirectory(ctx, h.vsock, req.RequestType, req.Settings.(*guestresource.LCOWMappedDirectory)) + case guestresource.ResourceTypeVPMemDevice: + return modifyMappedVPMemDevice(ctx, req.RequestType, req.Settings.(*guestresource.LCOWMappedVPMemDevice), h.securityPolicyEnforcer) + case guestresource.ResourceTypeCombinedLayers: + return modifyCombinedLayers(ctx, req.RequestType, req.Settings.(*guestresource.LCOWCombinedLayers), h.securityPolicyEnforcer) + case guestresource.ResourceTypeNetwork: + return modifyNetwork(ctx, req.RequestType, req.Settings.(*guestresource.LCOWNetworkAdapter)) + case guestresource.ResourceTypeVPCIDevice: + return modifyMappedVPCIDevice(ctx, req.RequestType, req.Settings.(*guestresource.LCOWMappedVPCIDevice)) + case guestresource.ResourceTypeContainerConstraints: c, err := h.GetContainer(containerID) if err != nil { return err } - return c.modifyContainerConstraints(ctx, settings.RequestType, settings.Settings.(*prot.ContainerConstraintsV2)) - case prot.MrtSecurityPolicy: - policy, ok := settings.Settings.(*securitypolicy.EncodedSecurityPolicy) + return c.modifyContainerConstraints(ctx, req.RequestType, req.Settings.(*guestresource.LCOWContainerConstraints)) + case guestresource.ResourceTypeSecurityPolicy: + policy, ok := req.Settings.(*securitypolicy.EncodedSecurityPolicy) if !ok { return errors.New("the request's settings are not of type EncodedSecurityPolicy") } return h.SetSecurityPolicy(policy.SecurityPolicy) default: - return errors.Errorf("the ResourceType \"%s\" is not supported for UVM", settings.ResourceType) + return errors.Errorf("the ResourceType \"%s\" is not supported for UVM", req.ResourceType) } } -func (h *Host) modifyContainerSettings(ctx context.Context, containerID string, settings *prot.ModifySettingRequest) error { +func (h *Host) modifyContainerSettings(ctx context.Context, containerID string, req *guestrequest.ModificationRequest) error { c, err := h.GetContainer(containerID) if err != nil { return err } - switch settings.ResourceType { - case prot.MrtContainerConstraints: - return c.modifyContainerConstraints(ctx, settings.RequestType, settings.Settings.(*prot.ContainerConstraintsV2)) + switch req.ResourceType { + case guestresource.ResourceTypeContainerConstraints: + return c.modifyContainerConstraints(ctx, req.RequestType, req.Settings.(*guestresource.LCOWContainerConstraints)) default: - return errors.Errorf("the ResourceType \"%s\" is not supported for containers", settings.ResourceType) + return errors.Errorf("the ResourceType \"%s\" is not supported for containers", req.ResourceType) } } -func (h *Host) ModifySettings(ctx context.Context, containerID string, settings *prot.ModifySettingRequest) error { +func (h *Host) ModifySettings(ctx context.Context, containerID string, req *guestrequest.ModificationRequest) error { if containerID == UVMContainerID { - return h.modifyHostSettings(ctx, containerID, settings) + return h.modifyHostSettings(ctx, containerID, req) } - return h.modifyContainerSettings(ctx, containerID, settings) + return h.modifyContainerSettings(ctx, containerID, req) } // Shutdown terminates this UVM. This is a destructive call and will destroy all @@ -441,20 +444,20 @@ func (h *Host) GetExternalProcess(pid int) (Process, error) { return p, nil } -func newInvalidRequestTypeError(rt prot.ModifyRequestType) error { - return errors.Errorf("the RequestType \"%s\" is not supported", rt) +func newInvalidRequestTypeError(rt guestrequest.RequestType) error { + return errors.Errorf("the RequestType %q is not supported", rt) } -func modifyMappedVirtualDisk(ctx context.Context, rt prot.ModifyRequestType, mvd *prot.MappedVirtualDiskV2, securityPolicy securitypolicy.SecurityPolicyEnforcer) (err error) { +func modifyMappedVirtualDisk(ctx context.Context, rt guestrequest.RequestType, mvd *guestresource.LCOWMappedVirtualDisk, securityPolicy securitypolicy.SecurityPolicyEnforcer) (err error) { switch rt { - case prot.MreqtAdd: + case guestrequest.RequestTypeAdd: mountCtx, cancel := context.WithTimeout(ctx, time.Second*5) defer cancel() if mvd.MountPath != "" { return scsi.Mount(mountCtx, mvd.Controller, mvd.Lun, mvd.MountPath, mvd.ReadOnly, mvd.Encrypted, mvd.Options, mvd.VerityInfo, securityPolicy) } return nil - case prot.MreqtRemove: + case guestrequest.RequestTypeRemove: if mvd.MountPath != "" { if err := scsi.Unmount(ctx, mvd.Controller, mvd.Lun, mvd.MountPath, mvd.Encrypted, mvd.VerityInfo, securityPolicy); err != nil { return err @@ -466,40 +469,40 @@ func modifyMappedVirtualDisk(ctx context.Context, rt prot.ModifyRequestType, mvd } } -func modifyMappedDirectory(ctx context.Context, vsock transport.Transport, rt prot.ModifyRequestType, md *prot.MappedDirectoryV2) (err error) { +func modifyMappedDirectory(ctx context.Context, vsock transport.Transport, rt guestrequest.RequestType, md *guestresource.LCOWMappedDirectory) (err error) { switch rt { - case prot.MreqtAdd: - return plan9.Mount(ctx, vsock, md.MountPath, md.ShareName, md.Port, md.ReadOnly) - case prot.MreqtRemove: + case guestrequest.RequestTypeAdd: + return plan9.Mount(ctx, vsock, md.MountPath, md.ShareName, uint32(md.Port), md.ReadOnly) + case guestrequest.RequestTypeRemove: return storage.UnmountPath(ctx, md.MountPath, true) default: return newInvalidRequestTypeError(rt) } } -func modifyMappedVPMemDevice(ctx context.Context, rt prot.ModifyRequestType, vpd *prot.MappedVPMemDeviceV2, securityPolicy securitypolicy.SecurityPolicyEnforcer) (err error) { +func modifyMappedVPMemDevice(ctx context.Context, rt guestrequest.RequestType, vpd *guestresource.LCOWMappedVPMemDevice, securityPolicy securitypolicy.SecurityPolicyEnforcer) (err error) { switch rt { - case prot.MreqtAdd: + case guestrequest.RequestTypeAdd: return pmem.Mount(ctx, vpd.DeviceNumber, vpd.MountPath, vpd.MappingInfo, vpd.VerityInfo, securityPolicy) - case prot.MreqtRemove: + case guestrequest.RequestTypeRemove: return pmem.Unmount(ctx, vpd.DeviceNumber, vpd.MountPath, vpd.MappingInfo, vpd.VerityInfo, securityPolicy) default: return newInvalidRequestTypeError(rt) } } -func modifyMappedVPCIDevice(ctx context.Context, rt prot.ModifyRequestType, vpciDev *prot.MappedVPCIDeviceV2) error { +func modifyMappedVPCIDevice(ctx context.Context, rt guestrequest.RequestType, vpciDev *guestresource.LCOWMappedVPCIDevice) error { switch rt { - case prot.MreqtAdd: + case guestrequest.RequestTypeAdd: return pci.WaitForPCIDeviceFromVMBusGUID(ctx, vpciDev.VMBusGUID) default: return newInvalidRequestTypeError(rt) } } -func modifyCombinedLayers(ctx context.Context, rt prot.ModifyRequestType, cl *prot.CombinedLayersV2, securityPolicy securitypolicy.SecurityPolicyEnforcer) (err error) { +func modifyCombinedLayers(ctx context.Context, rt guestrequest.RequestType, cl *guestresource.LCOWCombinedLayers, securityPolicy securitypolicy.SecurityPolicyEnforcer) (err error) { switch rt { - case prot.MreqtAdd: + case guestrequest.RequestTypeAdd: layerPaths := make([]string, len(cl.Layers)) for i, layer := range cl.Layers { layerPaths[i] = layer.Path @@ -516,17 +519,17 @@ func modifyCombinedLayers(ctx context.Context, rt prot.ModifyRequestType, cl *pr workdirPath = filepath.Join(cl.ScratchPath, "work") } - return overlay.MountLayer(ctx, layerPaths, upperdirPath, workdirPath, cl.ContainerRootPath, readonly, cl.ContainerId, securityPolicy) - case prot.MreqtRemove: + return overlay.MountLayer(ctx, layerPaths, upperdirPath, workdirPath, cl.ContainerRootPath, readonly, cl.ContainerID, securityPolicy) + case guestrequest.RequestTypeRemove: return storage.UnmountPath(ctx, cl.ContainerRootPath, true) default: return newInvalidRequestTypeError(rt) } } -func modifyNetwork(ctx context.Context, rt prot.ModifyRequestType, na *prot.NetworkAdapterV2) (err error) { +func modifyNetwork(ctx context.Context, rt guestrequest.RequestType, na *guestresource.LCOWNetworkAdapter) (err error) { switch rt { - case prot.MreqtAdd: + case guestrequest.RequestTypeAdd: ns := getOrAddNetworkNamespace(na.NamespaceID) if err := ns.AddAdapter(ctx, na); err != nil { return err @@ -534,7 +537,7 @@ func modifyNetwork(ctx context.Context, rt prot.ModifyRequestType, na *prot.Netw // This code doesnt know if the namespace was already added to the // container or not so it must always call `Sync`. return ns.Sync(ctx) - case prot.MreqtRemove: + case guestrequest.RequestTypeRemove: ns := getOrAddNetworkNamespace(na.ID) if err := ns.RemoveAdapter(ctx, na.ID); err != nil { return err diff --git a/internal/guest/storage/devicemapper/targets.go b/internal/guest/storage/devicemapper/targets.go index 9adfa0c108..d9ff565873 100644 --- a/internal/guest/storage/devicemapper/targets.go +++ b/internal/guest/storage/devicemapper/targets.go @@ -11,23 +11,25 @@ import ( "go.opencensus.io/trace" "github.com/Microsoft/hcsshim/ext4/dmverity" - "github.com/Microsoft/hcsshim/internal/guest/prot" "github.com/Microsoft/hcsshim/internal/oc" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) // CreateZeroSectorLinearTarget creates dm-linear target for a device at `devPath` and `mappingInfo`, returns // virtual block device path. -func CreateZeroSectorLinearTarget(ctx context.Context, devPath, devName string, mappingInfo *prot.DeviceMappingInfo) (_ string, err error) { +func CreateZeroSectorLinearTarget(ctx context.Context, devPath, devName string, mappingInfo *guestresource.LCOWVPMemMappingInfo) (_ string, err error) { _, span := trace.StartSpan(ctx, "devicemapper::CreateZeroSectorLinearTarget") defer span.End() defer func() { oc.SetSpanStatus(span, err) }() - linearTarget := zeroSectorLinearTarget(mappingInfo.DeviceSizeInBytes, devPath, mappingInfo.DeviceOffsetInBytes) + size := int64(mappingInfo.DeviceSizeInBytes) + offset := int64(mappingInfo.DeviceOffsetInBytes) + linearTarget := zeroSectorLinearTarget(size, devPath, offset) span.AddAttributes( trace.StringAttribute("devicePath", devPath), - trace.Int64Attribute("deviceStart", mappingInfo.DeviceOffsetInBytes), - trace.Int64Attribute("sectorSize", mappingInfo.DeviceSizeInBytes), + trace.Int64Attribute("deviceStart", offset), + trace.Int64Attribute("sectorSize", size), trace.StringAttribute("linearTable", fmt.Sprintf("%s: '%d %d %s'", devName, linearTarget.SectorStart, linearTarget.LengthInBlocks, linearTarget.Params))) devMapperPath, err := CreateDevice(devName, CreateReadOnly, []Target{linearTarget}) @@ -46,7 +48,7 @@ func CreateZeroSectorLinearTarget(ctx context.Context, devPath, devName string, // start| | | data_dev | data_block | #blocks | hash_alg root_digest salt // size | version hash_dev | hash_offset // target hash_block -func CreateVerityTarget(ctx context.Context, devPath, devName string, verityInfo *prot.DeviceVerityInfo) (_ string, err error) { +func CreateVerityTarget(ctx context.Context, devPath, devName string, verityInfo *guestresource.DeviceVerityInfo) (_ string, err error) { _, span := trace.StartSpan(ctx, "devicemapper::CreateVerityTarget") defer span.End() defer func() { oc.SetSpanStatus(span, err) }() diff --git a/internal/guest/storage/pmem/pmem.go b/internal/guest/storage/pmem/pmem.go index 3a94069b0c..6dde7fff9c 100644 --- a/internal/guest/storage/pmem/pmem.go +++ b/internal/guest/storage/pmem/pmem.go @@ -8,16 +8,16 @@ import ( "fmt" "os" - "github.com/Microsoft/hcsshim/internal/guest/prot" - "github.com/Microsoft/hcsshim/internal/log" - "github.com/Microsoft/hcsshim/pkg/securitypolicy" + "github.com/pkg/errors" + "go.opencensus.io/trace" + "golang.org/x/sys/unix" "github.com/Microsoft/hcsshim/internal/guest/storage" dm "github.com/Microsoft/hcsshim/internal/guest/storage/devicemapper" + "github.com/Microsoft/hcsshim/internal/log" "github.com/Microsoft/hcsshim/internal/oc" - "github.com/pkg/errors" - "go.opencensus.io/trace" - "golang.org/x/sys/unix" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/pkg/securitypolicy" ) // Test dependencies @@ -70,7 +70,14 @@ func mount(ctx context.Context, source, target string) (err error) { // // Note: both mappingInfo and verityInfo can be non-nil at the same time, in that case // linear target is created first and it becomes the data/hash device for verity target. -func Mount(ctx context.Context, device uint32, target string, mappingInfo *prot.DeviceMappingInfo, verityInfo *prot.DeviceVerityInfo, securityPolicy securitypolicy.SecurityPolicyEnforcer) (err error) { +func Mount( + ctx context.Context, + device uint32, + target string, + mappingInfo *guestresource.LCOWVPMemMappingInfo, + verityInfo *guestresource.DeviceVerityInfo, + securityPolicy securitypolicy.SecurityPolicyEnforcer, +) (err error) { mCtx, span := trace.StartSpan(ctx, "pmem::Mount") defer span.End() defer func() { oc.SetSpanStatus(span, err) }() @@ -124,7 +131,14 @@ func Mount(ctx context.Context, device uint32, target string, mappingInfo *prot. } // Unmount unmounts `target` and removes corresponding linear and verity targets when needed -func Unmount(ctx context.Context, devNumber uint32, target string, mappingInfo *prot.DeviceMappingInfo, verityInfo *prot.DeviceVerityInfo, securityPolicy securitypolicy.SecurityPolicyEnforcer) (err error) { +func Unmount( + ctx context.Context, + devNumber uint32, + target string, + mappingInfo *guestresource.LCOWVPMemMappingInfo, + verityInfo *guestresource.DeviceVerityInfo, + securityPolicy securitypolicy.SecurityPolicyEnforcer, +) (err error) { _, span := trace.StartSpan(ctx, "pmem::Unmount") defer span.End() defer func() { oc.SetSpanStatus(span, err) }() diff --git a/internal/guest/storage/pmem/pmem_test.go b/internal/guest/storage/pmem/pmem_test.go index 354ea3ab7a..fb8b6e4c4b 100644 --- a/internal/guest/storage/pmem/pmem_test.go +++ b/internal/guest/storage/pmem/pmem_test.go @@ -6,14 +6,15 @@ package pmem import ( "context" "fmt" - "github.com/Microsoft/hcsshim/internal/guest/prot" "os" "testing" - "github.com/Microsoft/hcsshim/internal/guest/storage/test/policy" - "github.com/Microsoft/hcsshim/pkg/securitypolicy" "github.com/pkg/errors" "golang.org/x/sys/unix" + + "github.com/Microsoft/hcsshim/internal/guest/storage/test/policy" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/pkg/securitypolicy" ) func clearTestDependencies() { @@ -316,7 +317,7 @@ func mountMonitoringSecurityPolicyEnforcer() *policy.MountMonitoringSecurityPoli func Test_CreateLinearTarget_And_Mount_Called_With_Correct_Parameters(t *testing.T) { clearTestDependencies() - mappingInfo := &prot.DeviceMappingInfo{ + mappingInfo := &guestresource.LCOWVPMemMappingInfo{ DeviceOffsetInBytes: 0, DeviceSizeInBytes: 1024, } @@ -340,7 +341,7 @@ func Test_CreateLinearTarget_And_Mount_Called_With_Correct_Parameters(t *testing return nil } - createZeroSectorLinearTarget = func(_ context.Context, source, name string, mapping *prot.DeviceMappingInfo) (string, error) { + createZeroSectorLinearTarget = func(_ context.Context, source, name string, mapping *guestresource.LCOWVPMemMappingInfo) (string, error) { createZSLTCalled = true if source != expectedSource { t.Errorf("expected createZeroSectorLinearTarget source %s, got %s", expectedSource, source) @@ -369,7 +370,7 @@ func Test_CreateLinearTarget_And_Mount_Called_With_Correct_Parameters(t *testing func Test_CreateVerityTargetCalled_And_Mount_Called_With_Correct_Parameters(t *testing.T) { clearTestDependencies() - verityInfo := &prot.DeviceVerityInfo{ + verityInfo := &guestresource.DeviceVerityInfo{ RootDigest: "hash", } expectedVerityName := fmt.Sprintf(verityDeviceFmt, 0, verityInfo.RootDigest) @@ -387,7 +388,7 @@ func Test_CreateVerityTargetCalled_And_Mount_Called_With_Correct_Parameters(t *t } return nil } - createVerityTarget = func(_ context.Context, source, name string, verity *prot.DeviceVerityInfo) (string, error) { + createVerityTarget = func(_ context.Context, source, name string, verity *guestresource.DeviceVerityInfo) (string, error) { createVerityTargetCalled = true if source != expectedSource { t.Errorf("expected createVerityTarget source %s, got %s", expectedSource, source) @@ -416,10 +417,10 @@ func Test_CreateVerityTargetCalled_And_Mount_Called_With_Correct_Parameters(t *t func Test_CreateLinearTarget_And_CreateVerityTargetCalled_Called_Correctly(t *testing.T) { clearTestDependencies() - verityInfo := &prot.DeviceVerityInfo{ + verityInfo := &guestresource.DeviceVerityInfo{ RootDigest: "hash", } - mapping := &prot.DeviceMappingInfo{ + mapping := &guestresource.LCOWVPMemMappingInfo{ DeviceOffsetInBytes: 0, DeviceSizeInBytes: 1024, } @@ -432,7 +433,7 @@ func Test_CreateLinearTarget_And_CreateVerityTargetCalled_Called_Correctly(t *te dmVerityCalled := false mountCalled := false - createZeroSectorLinearTarget = func(_ context.Context, source, name string, mapping *prot.DeviceMappingInfo) (string, error) { + createZeroSectorLinearTarget = func(_ context.Context, source, name string, mapping *guestresource.LCOWVPMemMappingInfo) (string, error) { dmLinearCalled = true if source != expectedPMemDevice { t.Errorf("expected createZeroSectorLinearTarget source %s, got %s", expectedPMemDevice, source) @@ -442,7 +443,7 @@ func Test_CreateLinearTarget_And_CreateVerityTargetCalled_Called_Correctly(t *te } return mapperLinearPath, nil } - createVerityTarget = func(_ context.Context, source, name string, verity *prot.DeviceVerityInfo) (string, error) { + createVerityTarget = func(_ context.Context, source, name string, verity *guestresource.DeviceVerityInfo) (string, error) { dmVerityCalled = true if source != mapperLinearPath { t.Errorf("expected createVerityTarget source %s, got %s", mapperLinearPath, source) @@ -484,7 +485,7 @@ func Test_CreateLinearTarget_And_CreateVerityTargetCalled_Called_Correctly(t *te func Test_RemoveDevice_Called_For_LinearTarget_On_MountInternalFailure(t *testing.T) { clearTestDependencies() - mappingInfo := &prot.DeviceMappingInfo{ + mappingInfo := &guestresource.LCOWVPMemMappingInfo{ DeviceOffsetInBytes: 0, DeviceSizeInBytes: 1024, } @@ -493,7 +494,7 @@ func Test_RemoveDevice_Called_For_LinearTarget_On_MountInternalFailure(t *testin mapperPath := fmt.Sprintf("/dev/mapper/%s", expectedTarget) removeDeviceCalled := false - createZeroSectorLinearTarget = func(_ context.Context, source, name string, mapping *prot.DeviceMappingInfo) (string, error) { + createZeroSectorLinearTarget = func(_ context.Context, source, name string, mapping *guestresource.LCOWVPMemMappingInfo) (string, error) { return mapperPath, nil } mountInternal = func(_ context.Context, source, target string) error { @@ -525,7 +526,7 @@ func Test_RemoveDevice_Called_For_LinearTarget_On_MountInternalFailure(t *testin func Test_RemoveDevice_Called_For_VerityTarget_On_MountInternalFailure(t *testing.T) { clearTestDependencies() - verity := &prot.DeviceVerityInfo{ + verity := &guestresource.DeviceVerityInfo{ RootDigest: "hash", } expectedVerityTarget := fmt.Sprintf(verityDeviceFmt, 0, verity.RootDigest) @@ -533,7 +534,7 @@ func Test_RemoveDevice_Called_For_VerityTarget_On_MountInternalFailure(t *testin mapperPath := fmt.Sprintf("/dev/mapper/%s", expectedVerityTarget) removeDeviceCalled := false - createVerityTarget = func(_ context.Context, source, name string, verity *prot.DeviceVerityInfo) (string, error) { + createVerityTarget = func(_ context.Context, source, name string, verity *guestresource.DeviceVerityInfo) (string, error) { return mapperPath, nil } mountInternal = func(_ context.Context, _, _ string) error { @@ -565,11 +566,11 @@ func Test_RemoveDevice_Called_For_VerityTarget_On_MountInternalFailure(t *testin func Test_RemoveDevice_Called_For_Both_Targets_On_MountInternalFailure(t *testing.T) { clearTestDependencies() - mapping := &prot.DeviceMappingInfo{ + mapping := &guestresource.LCOWVPMemMappingInfo{ DeviceOffsetInBytes: 0, DeviceSizeInBytes: 1024, } - verity := &prot.DeviceVerityInfo{ + verity := &guestresource.DeviceVerityInfo{ RootDigest: "hash", } expectedError := errors.New("mountInternal error") @@ -581,13 +582,13 @@ func Test_RemoveDevice_Called_For_Both_Targets_On_MountInternalFailure(t *testin rmLinearCalled := false rmVerityCalled := false - createZeroSectorLinearTarget = func(_ context.Context, source, name string, m *prot.DeviceMappingInfo) (string, error) { + createZeroSectorLinearTarget = func(_ context.Context, source, name string, m *guestresource.LCOWVPMemMappingInfo) (string, error) { if source != expectedPMemDevice { t.Errorf("expected createZeroSectorLinearTarget source %s, got %s", expectedPMemDevice, source) } return mapperLinearPath, nil } - createVerityTarget = func(_ context.Context, source, name string, v *prot.DeviceVerityInfo) (string, error) { + createVerityTarget = func(_ context.Context, source, name string, v *guestresource.DeviceVerityInfo) (string, error) { if source != mapperLinearPath { t.Errorf("expected createVerityTarget to be called with %s, got %s", mapperLinearPath, source) } diff --git a/internal/guest/storage/scsi/scsi.go b/internal/guest/storage/scsi/scsi.go index cdd02b02ab..611e8ade2d 100644 --- a/internal/guest/storage/scsi/scsi.go +++ b/internal/guest/storage/scsi/scsi.go @@ -6,21 +6,22 @@ package scsi import ( "context" "fmt" - dm "github.com/Microsoft/hcsshim/internal/guest/storage/devicemapper" "io/ioutil" "os" "path/filepath" "time" - "github.com/Microsoft/hcsshim/internal/guest/prot" + "github.com/pkg/errors" + "go.opencensus.io/trace" + "golang.org/x/sys/unix" + "github.com/Microsoft/hcsshim/internal/guest/storage" "github.com/Microsoft/hcsshim/internal/guest/storage/crypt" + dm "github.com/Microsoft/hcsshim/internal/guest/storage/devicemapper" "github.com/Microsoft/hcsshim/internal/log" "github.com/Microsoft/hcsshim/internal/oc" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" "github.com/Microsoft/hcsshim/pkg/securitypolicy" - "github.com/pkg/errors" - "go.opencensus.io/trace" - "golang.org/x/sys/unix" ) // Test dependencies @@ -50,7 +51,17 @@ const ( // // If `encrypted` is set to true, the SCSI device will be encrypted using // dm-crypt. -func Mount(ctx context.Context, controller, lun uint8, target string, readonly bool, encrypted bool, options []string, verityInfo *prot.DeviceVerityInfo, securityPolicy securitypolicy.SecurityPolicyEnforcer) (err error) { +func Mount( + ctx context.Context, + controller, + lun uint8, + target string, + readonly bool, + encrypted bool, + options []string, + verityInfo *guestresource.DeviceVerityInfo, + securityPolicy securitypolicy.SecurityPolicyEnforcer, +) (err error) { spnCtx, span := trace.StartSpan(ctx, "scsi::Mount") defer span.End() defer func() { oc.SetSpanStatus(span, err) }() @@ -151,7 +162,15 @@ func Mount(ctx context.Context, controller, lun uint8, target string, readonly b // Unmount unmounts a SCSI device mounted at `target`. // // If `encrypted` is true, it removes all its associated dm-crypto state. -func Unmount(ctx context.Context, controller, lun uint8, target string, encrypted bool, verityInfo *prot.DeviceVerityInfo, securityPolicy securitypolicy.SecurityPolicyEnforcer) (err error) { +func Unmount( + ctx context.Context, + controller, + lun uint8, + target string, + encrypted bool, + verityInfo *guestresource.DeviceVerityInfo, + securityPolicy securitypolicy.SecurityPolicyEnforcer, +) (err error) { ctx, span := trace.StartSpan(ctx, "scsi::Unmount") defer span.End() defer func() { oc.SetSpanStatus(span, err) }() diff --git a/internal/guest/storage/scsi/scsi_test.go b/internal/guest/storage/scsi/scsi_test.go index 8137421314..de73a930a3 100644 --- a/internal/guest/storage/scsi/scsi_test.go +++ b/internal/guest/storage/scsi/scsi_test.go @@ -7,13 +7,14 @@ import ( "context" "errors" "fmt" - "github.com/Microsoft/hcsshim/internal/guest/prot" "os" "testing" + "golang.org/x/sys/unix" + "github.com/Microsoft/hcsshim/internal/guest/storage/test/policy" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" "github.com/Microsoft/hcsshim/pkg/securitypolicy" - "golang.org/x/sys/unix" ) func clearTestDependencies() { @@ -643,10 +644,10 @@ func Test_CreateVerityTarget_And_Mount_Called_With_Correct_Parameters(t *testing return nil } - vInfo := &prot.DeviceVerityInfo{ + vInfo := &guestresource.DeviceVerityInfo{ RootDigest: "hash", } - createVerityTarget = func(_ context.Context, source, name string, verityInfo *prot.DeviceVerityInfo) (string, error) { + createVerityTarget = func(_ context.Context, source, name string, verityInfo *guestresource.DeviceVerityInfo) (string, error) { createVerityTargetCalled = true if source != expectedSource { t.Errorf("expected source %s, got %s", expectedSource, source) @@ -700,11 +701,11 @@ func Test_osMkdirAllFails_And_RemoveDevice_Called(t *testing.T) { return expectedError } - verityInfo := &prot.DeviceVerityInfo{ + verityInfo := &guestresource.DeviceVerityInfo{ RootDigest: "hash", } - createVerityTarget = func(_ context.Context, _, _ string, _ *prot.DeviceVerityInfo) (string, error) { + createVerityTarget = func(_ context.Context, _, _ string, _ *guestresource.DeviceVerityInfo) (string, error) { return fmt.Sprintf("/dev/mapper/%s", expectedVerityName), nil } diff --git a/internal/hcs/process.go b/internal/hcs/process.go index f4605922ab..0eb2b6d063 100644 --- a/internal/hcs/process.go +++ b/internal/hcs/process.go @@ -114,9 +114,9 @@ func (process *Process) processSignalResult(ctx context.Context, err error) (boo // Signal signals the process with `options`. // -// For LCOW `guestrequest.SignalProcessOptionsLCOW`. +// For LCOW `protocol.SignalProcessOptionsLCOW`. // -// For WCOW `guestrequest.SignalProcessOptionsWCOW`. +// For WCOW `protocol.SignalProcessOptionsWCOW`. func (process *Process) Signal(ctx context.Context, options interface{}) (bool, error) { process.handleLock.RLock() defer process.handleLock.RUnlock() diff --git a/internal/hcs/schema2/modify_setting_request.go b/internal/hcs/schema2/modify_setting_request.go index d29455a3e4..3f0309c0b2 100644 --- a/internal/hcs/schema2/modify_setting_request.go +++ b/internal/hcs/schema2/modify_setting_request.go @@ -9,10 +9,12 @@ package hcsschema +import "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + type ModifySettingRequest struct { ResourcePath string `json:"ResourcePath,omitempty"` - RequestType string `json:"RequestType,omitempty"` + RequestType guestrequest.RequestType `json:"RequestType,omitempty"` // NOTE: Swagger generated as string. Locally updated. Settings interface{} `json:"Settings,omitempty"` // NOTE: Swagger generated as *interface{}. Locally updated diff --git a/internal/hcs/schema2/plan9_share.go b/internal/hcs/schema2/plan9_share.go index 41f8fdea02..a7431f0e1b 100644 --- a/internal/hcs/schema2/plan9_share.go +++ b/internal/hcs/schema2/plan9_share.go @@ -12,7 +12,7 @@ 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. + // The name by which the guest operation system can access this share, via the aname parameter in the Plan9 guestprotocol. AccessName string `json:"AccessName,omitempty"` Path string `json:"Path,omitempty"` diff --git a/internal/hcsoci/clone.go b/internal/hcsoci/clone.go index d92531ab0a..ef5b2babe2 100644 --- a/internal/hcsoci/clone.go +++ b/internal/hcsoci/clone.go @@ -10,7 +10,7 @@ import ( "github.com/Microsoft/hcsshim/internal/cow" "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/requesttype" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" ) // Usually mounts specified in the container config are added in the container doc @@ -22,7 +22,7 @@ func addMountsToClone(ctx context.Context, c cow.Container, mounts *mountsConfig // at the same time to save time for _, md := range mounts.mdsv2 { requestDocument := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Add, + RequestType: guestrequest.RequestTypeAdd, ResourcePath: resourcepaths.SiloMappedDirectoryResourcePath, Settings: md, } @@ -34,7 +34,7 @@ func addMountsToClone(ctx context.Context, c cow.Container, mounts *mountsConfig for _, mp := range mounts.mpsv2 { requestDocument := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Add, + RequestType: guestrequest.RequestTypeAdd, ResourcePath: resourcepaths.SiloMappedPipeResourcePath, Settings: mp, } diff --git a/internal/hns/hnspolicylist.go b/internal/hns/hnspolicylist.go index 31322a6816..9e1f1cbfe1 100644 --- a/internal/hns/hnspolicylist.go +++ b/internal/hns/hnspolicylist.go @@ -143,7 +143,7 @@ func (policylist *PolicyList) RemoveEndpoint(endpoint *HNSEndpoint) (*PolicyList 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) + logrus.Debugf(title+" endpointId=%v, isILB=%v, sourceVIP=%s, vip=%s, guestprotocol=%v, internalPort=%v, externalPort=%v", endpoints, isILB, sourceVIP, vip, protocol, internalPort, externalPort) policylist := &PolicyList{} diff --git a/internal/jobcontainers/process.go b/internal/jobcontainers/process.go index b38e226111..7f66028bc8 100644 --- a/internal/jobcontainers/process.go +++ b/internal/jobcontainers/process.go @@ -6,15 +6,16 @@ import ( "io" "sync" + "github.com/pkg/errors" + "golang.org/x/sys/windows" + "github.com/Microsoft/hcsshim/internal/conpty" "github.com/Microsoft/hcsshim/internal/cow" "github.com/Microsoft/hcsshim/internal/exec" - "github.com/Microsoft/hcsshim/internal/guestrequest" "github.com/Microsoft/hcsshim/internal/hcs" "github.com/Microsoft/hcsshim/internal/log" "github.com/Microsoft/hcsshim/internal/winapi" - "github.com/pkg/errors" - "golang.org/x/sys/windows" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) // JobProcess represents a process run in a job object. @@ -81,7 +82,7 @@ func (p *JobProcess) Signal(ctx context.Context, options interface{}) (bool, err return true, nil } - signalOptions, ok := options.(*guestrequest.SignalProcessOptionsWCOW) + signalOptions, ok := options.(*guestresource.SignalProcessOptionsWCOW) if !ok { return false, errors.New("unknown signal options") } diff --git a/internal/requesttype/types.go b/internal/requesttype/types.go deleted file mode 100644 index df2db709b0..0000000000 --- a/internal/requesttype/types.go +++ /dev/null @@ -1,11 +0,0 @@ -package requesttype - -// These are constants for v2 schema modify requests. - -// RequestType const -const ( - Add = "Add" - Remove = "Remove" - PreAdd = "PreAdd" // For networking - Update = "Update" -) diff --git a/internal/signals/signal.go b/internal/signals/signal.go index b9cde04bf9..a4f6fc7348 100644 --- a/internal/signals/signal.go +++ b/internal/signals/signal.go @@ -5,7 +5,8 @@ import ( "strconv" "strings" - "github.com/Microsoft/hcsshim/internal/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) var ( @@ -21,11 +22,11 @@ var ( // // If `signalsSupported==false` we verify that only SIGTERM/SIGKILL are sent. // All other signals are not supported on downlevel platforms. -func ValidateSigstrLCOW(sigstr string, signalsSupported bool) (*guestrequest.SignalProcessOptionsLCOW, error) { +func ValidateSigstrLCOW(sigstr string, signalsSupported bool) (*guestresource.SignalProcessOptionsLCOW, error) { // All flavors including legacy default to SIGTERM on LCOW CtrlC on Windows if sigstr == "" { if signalsSupported { - return &guestrequest.SignalProcessOptionsLCOW{Signal: sigTerm}, nil + return &guestresource.SignalProcessOptionsLCOW{Signal: sigTerm}, nil } return nil, nil } @@ -51,7 +52,7 @@ func ValidateSigstrLCOW(sigstr string, signalsSupported bool) (*guestrequest.Sig // Match signal string name for k, v := range signalMapLcow { if sigstr == k { - return &guestrequest.SignalProcessOptionsLCOW{Signal: v}, nil + return &guestresource.SignalProcessOptionsLCOW{Signal: v}, nil } } return nil, ErrInvalidSignal @@ -70,11 +71,11 @@ func ValidateSigstrLCOW(sigstr string, signalsSupported bool) (*guestrequest.Sig // semantics which will be properly translated to CTRLSHUTDOWN and `Terminate`. // To detect when WCOW needs to `Terminate` the return signal will be `nil` and // the return error will be `nil`. -func ValidateSigstrWCOW(sigstr string, signalsSupported bool) (*guestrequest.SignalProcessOptionsWCOW, error) { +func ValidateSigstrWCOW(sigstr string, signalsSupported bool) (*guestresource.SignalProcessOptionsWCOW, error) { // All flavors including legacy default to SIGTERM on LCOW CtrlC on Windows if sigstr == "" { if signalsSupported { - return &guestrequest.SignalProcessOptionsWCOW{Signal: guestrequest.SignalValueWCOWCtrlShutdown}, nil + return &guestresource.SignalProcessOptionsWCOW{Signal: guestrequest.SignalValueWCOWCtrlShutdown}, nil } return nil, nil } @@ -119,7 +120,7 @@ func ValidateSigstrWCOW(sigstr string, signalsSupported bool) (*guestrequest.Sig return nil, ErrInvalidSignal } - return &guestrequest.SignalProcessOptionsWCOW{Signal: signalString}, nil + return &guestresource.SignalProcessOptionsWCOW{Signal: signalString}, nil } } @@ -128,7 +129,7 @@ func ValidateSigstrWCOW(sigstr string, signalsSupported bool) (*guestrequest.Sig // // If `signalsSupported==false` we verify that only SIGTERM/SIGKILL are sent. // All other signals are not supported on downlevel platforms. -func ValidateLCOW(signal int, signalsSupported bool) (*guestrequest.SignalProcessOptionsLCOW, error) { +func ValidateLCOW(signal int, signalsSupported bool) (*guestresource.SignalProcessOptionsLCOW, error) { if !signalsSupported { // If signals arent supported we just validate that its a known signal. // We already return 0 since we only supported a platform Kill() at that @@ -144,7 +145,7 @@ func ValidateLCOW(signal int, signalsSupported bool) (*guestrequest.SignalProces // Match signal by value for _, v := range signalMapLcow { if signal == v { - return &guestrequest.SignalProcessOptionsLCOW{Signal: signal}, nil + return &guestresource.SignalProcessOptionsLCOW{Signal: signal}, nil } } return nil, ErrInvalidSignal @@ -161,7 +162,7 @@ func ValidateLCOW(signal int, signalsSupported bool) (*guestrequest.SignalProces // semantics which will be properly translated to CTRLSHUTDOWN and `Terminate`. // To detect when WCOW needs to `Terminate` the return signal will be `nil` and // the return error will be `nil`. -func ValidateWCOW(signal int, signalsSupported bool) (*guestrequest.SignalProcessOptionsWCOW, error) { +func ValidateWCOW(signal int, signalsSupported bool) (*guestresource.SignalProcessOptionsWCOW, error) { if !signalsSupported { // If signals arent supported we just validate that its a known signal. // We already return 0 since we only supported a platform Kill() at that @@ -196,6 +197,6 @@ func ValidateWCOW(signal int, signalsSupported bool) (*guestrequest.SignalProces return nil, ErrInvalidSignal } - return &guestrequest.SignalProcessOptionsWCOW{Signal: signalString}, nil + return &guestresource.SignalProcessOptionsWCOW{Signal: signalString}, nil } } diff --git a/internal/signals/signal_test.go b/internal/signals/signal_test.go index 7657c7cf02..8dddfb5705 100644 --- a/internal/signals/signal_test.go +++ b/internal/signals/signal_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/Microsoft/hcsshim/internal/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" ) func Test_ValidateSigstr_LCOW_Empty_No_SignalsSupported(t *testing.T) { diff --git a/internal/uvm/capabilities.go b/internal/uvm/capabilities.go index d76bfdbef4..3bfa8fb182 100644 --- a/internal/uvm/capabilities.go +++ b/internal/uvm/capabilities.go @@ -17,7 +17,7 @@ func (uvm *UtilityVM) DeleteContainerStateSupported() bool { return uvm.guestCaps.DeleteContainerStateSupported } -// Capabilities returns the protocol version and the guest defined capabilities. +// Capabilities returns the guestprotocol version and the guest defined capabilities. // This should only be used for testing. func (uvm *UtilityVM) Capabilities() (uint32, schema1.GuestDefinedCapabilities) { return uvm.protocol, uvm.guestCaps diff --git a/internal/uvm/combine_layers.go b/internal/uvm/combine_layers.go index ff85fcffa5..21aa03cfa1 100644 --- a/internal/uvm/combine_layers.go +++ b/internal/uvm/combine_layers.go @@ -3,9 +3,9 @@ package uvm import ( "context" - "github.com/Microsoft/hcsshim/internal/guestrequest" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/requesttype" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) // CombineLayersWCOW combines `layerPaths` with `containerRootPath` into the @@ -17,10 +17,10 @@ func (uvm *UtilityVM) CombineLayersWCOW(ctx context.Context, layerPaths []hcssch return errNotSupported } msr := &hcsschema.ModifySettingRequest{ - GuestRequest: guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeCombinedLayers, - RequestType: requesttype.Add, - Settings: guestrequest.WCOWCombinedLayers{ + GuestRequest: guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeCombinedLayers, + RequestType: guestrequest.RequestTypeAdd, + Settings: guestresource.WCOWCombinedLayers{ ContainerRootPath: containerRootPath, Layers: layerPaths, }, @@ -40,15 +40,15 @@ func (uvm *UtilityVM) CombineLayersLCOW(ctx context.Context, containerID string, return errNotSupported } - layers := []hcsschema.Layer{} + var layers []hcsschema.Layer for _, l := range layerPaths { layers = append(layers, hcsschema.Layer{Path: l}) } msr := &hcsschema.ModifySettingRequest{ - GuestRequest: guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeCombinedLayers, - RequestType: requesttype.Add, - Settings: guestrequest.LCOWCombinedLayers{ + GuestRequest: guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeCombinedLayers, + RequestType: guestrequest.RequestTypeAdd, + Settings: guestresource.LCOWCombinedLayers{ ContainerID: containerID, ContainerRootPath: rootfsPath, Layers: layers, @@ -64,10 +64,10 @@ func (uvm *UtilityVM) CombineLayersLCOW(ctx context.Context, containerID string, // NOTE: `rootfsPath` is the path from within the UVM. func (uvm *UtilityVM) RemoveCombinedLayersWCOW(ctx context.Context, rootfsPath string) error { msr := &hcsschema.ModifySettingRequest{ - GuestRequest: guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeCombinedLayers, - RequestType: requesttype.Remove, - Settings: guestrequest.WCOWCombinedLayers{ + GuestRequest: guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeCombinedLayers, + RequestType: guestrequest.RequestTypeRemove, + Settings: guestresource.WCOWCombinedLayers{ ContainerRootPath: rootfsPath, }, }, @@ -77,10 +77,10 @@ func (uvm *UtilityVM) RemoveCombinedLayersWCOW(ctx context.Context, rootfsPath s func (uvm *UtilityVM) RemoveCombinedLayersLCOW(ctx context.Context, rootfsPath string) error { msr := &hcsschema.ModifySettingRequest{ - GuestRequest: guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeCombinedLayers, - RequestType: requesttype.Remove, - Settings: guestrequest.LCOWCombinedLayers{ + GuestRequest: guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeCombinedLayers, + RequestType: guestrequest.RequestTypeRemove, + Settings: guestresource.LCOWCombinedLayers{ ContainerRootPath: rootfsPath, }, }, diff --git a/internal/uvm/computeagent.go b/internal/uvm/computeagent.go index 9f748d2732..1668e30637 100644 --- a/internal/uvm/computeagent.go +++ b/internal/uvm/computeagent.go @@ -5,13 +5,6 @@ import ( "strings" "github.com/Microsoft/go-winio" - "github.com/Microsoft/hcsshim/hcn" - "github.com/Microsoft/hcsshim/internal/computeagent" - "github.com/Microsoft/hcsshim/internal/guestrequest" - hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/hns" - ncproxynetworking "github.com/Microsoft/hcsshim/internal/ncproxy/networking" - "github.com/Microsoft/hcsshim/pkg/octtrpc" "github.com/containerd/ttrpc" "github.com/containerd/typeurl" "github.com/pkg/errors" @@ -19,7 +12,14 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "github.com/Microsoft/hcsshim/hcn" + "github.com/Microsoft/hcsshim/internal/computeagent" + hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" + "github.com/Microsoft/hcsshim/internal/hns" "github.com/Microsoft/hcsshim/internal/log" + ncproxynetworking "github.com/Microsoft/hcsshim/internal/ncproxy/networking" + "github.com/Microsoft/hcsshim/pkg/octtrpc" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) func init() { @@ -41,8 +41,8 @@ type agentComputeSystem interface { RemoveEndpointFromNS(context.Context, string, *hns.HNSEndpoint) error AssignDevice(context.Context, string, uint16, string) (*VPCIDevice, error) RemoveDevice(context.Context, string, uint16) error - AddNICInGuest(context.Context, *guestrequest.LCOWNetworkAdapter) error - RemoveNICInGuest(context.Context, *guestrequest.LCOWNetworkAdapter) error + AddNICInGuest(context.Context, *guestresource.LCOWNetworkAdapter) error + RemoveNICInGuest(context.Context, *guestresource.LCOWNetworkAdapter) error } var _ agentComputeSystem = &UtilityVM{} @@ -110,7 +110,7 @@ func (ca *computeAgent) AddNIC(ctx context.Context, req *computeagent.AddNICInte switch endpt := endpoint.(type) { case *ncproxynetworking.Endpoint: - cfg := &guestrequest.LCOWNetworkAdapter{ + cfg := &guestresource.LCOWNetworkAdapter{ NamespaceID: endpt.NamespaceID, ID: req.NicID, IPAddress: endpt.Settings.IPAddress, @@ -205,7 +205,7 @@ func (ca *computeAgent) DeleteNIC(ctx context.Context, req *computeagent.DeleteN switch endpt := endpoint.(type) { case *ncproxynetworking.Endpoint: - cfg := &guestrequest.LCOWNetworkAdapter{ + cfg := &guestresource.LCOWNetworkAdapter{ ID: req.NicID, } if err := ca.uvm.RemoveNICInGuest(ctx, cfg); err != nil { diff --git a/internal/uvm/create.go b/internal/uvm/create.go index e77a08f3a1..8f293f67fe 100644 --- a/internal/uvm/create.go +++ b/internal/uvm/create.go @@ -8,6 +8,10 @@ import ( "path/filepath" "runtime" + "github.com/sirupsen/logrus" + "go.opencensus.io/trace" + "golang.org/x/sys/windows" + "github.com/Microsoft/hcsshim/internal/cow" "github.com/Microsoft/hcsshim/internal/hcs" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" @@ -16,9 +20,6 @@ import ( "github.com/Microsoft/hcsshim/internal/oc" "github.com/Microsoft/hcsshim/internal/schemaversion" "github.com/Microsoft/hcsshim/osversion" - "github.com/sirupsen/logrus" - "go.opencensus.io/trace" - "golang.org/x/sys/windows" ) // Options are the set of options passed to Create() to create a utility vm. diff --git a/internal/uvm/create_wcow.go b/internal/uvm/create_wcow.go index e4a4197078..c09b49d9f0 100644 --- a/internal/uvm/create_wcow.go +++ b/internal/uvm/create_wcow.go @@ -6,6 +6,9 @@ import ( "os" "path/filepath" + "github.com/pkg/errors" + "go.opencensus.io/trace" + "github.com/Microsoft/go-winio" "github.com/Microsoft/go-winio/pkg/guid" "github.com/Microsoft/hcsshim/internal/gcs" @@ -19,8 +22,6 @@ import ( "github.com/Microsoft/hcsshim/internal/wclayer" "github.com/Microsoft/hcsshim/internal/wcow" "github.com/Microsoft/hcsshim/osversion" - "github.com/pkg/errors" - "go.opencensus.io/trace" ) // OptionsWCOW are the set of options passed to CreateWCOW() to create a utility vm. diff --git a/internal/uvm/hvsocket.go b/internal/uvm/hvsocket.go index 48f7730761..22b76d8988 100644 --- a/internal/uvm/hvsocket.go +++ b/internal/uvm/hvsocket.go @@ -6,7 +6,7 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/requesttype" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" ) // UpdateHvSocketService calls HCS to update/create the hvsocket service for @@ -27,7 +27,7 @@ import ( // behavior as the relevant fields are set on HCS' side. func (uvm *UtilityVM) UpdateHvSocketService(ctx context.Context, sid string, doc *hcsschema.HvSocketServiceConfig) error { request := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Update, + RequestType: guestrequest.RequestTypeUpdate, ResourcePath: fmt.Sprintf(resourcepaths.HvSocketConfigResourceFormat, sid), Settings: doc, } @@ -37,7 +37,7 @@ func (uvm *UtilityVM) UpdateHvSocketService(ctx context.Context, sid string, doc // RemoveHvSocketService will remove an hvsocket service entry if it exists. func (uvm *UtilityVM) RemoveHvSocketService(ctx context.Context, sid string) error { request := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Remove, + RequestType: guestrequest.RequestTypeRemove, ResourcePath: fmt.Sprintf(resourcepaths.HvSocketConfigResourceFormat, sid), } return uvm.modify(ctx, request) diff --git a/internal/uvm/modify.go b/internal/uvm/modify.go index 72b391756c..5646156453 100644 --- a/internal/uvm/modify.go +++ b/internal/uvm/modify.go @@ -6,7 +6,7 @@ import ( hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/log" - "github.com/Microsoft/hcsshim/internal/requesttype" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" ) // Modify modifies the compute system by sending a request to HCS. @@ -17,14 +17,14 @@ func (uvm *UtilityVM) modify(ctx context.Context, doc *hcsschema.ModifySettingRe hostdoc := *doc hostdoc.GuestRequest = nil - if doc.ResourcePath != "" && doc.RequestType == requesttype.Add { + if doc.ResourcePath != "" && doc.RequestType == guestrequest.RequestTypeAdd { err = uvm.hcsSystem.Modify(ctx, &hostdoc) if err != nil { return fmt.Errorf("adding VM resources: %s", err) } defer func() { if err != nil { - hostdoc.RequestType = requesttype.Remove + hostdoc.RequestType = guestrequest.RequestTypeRemove rerr := uvm.hcsSystem.Modify(ctx, &hostdoc) if rerr != nil { log.G(ctx).WithError(rerr).Error("failed to roll back resource add") @@ -36,7 +36,7 @@ func (uvm *UtilityVM) modify(ctx context.Context, doc *hcsschema.ModifySettingRe if err != nil { return fmt.Errorf("guest modify: %s", err) } - if doc.ResourcePath != "" && doc.RequestType == requesttype.Remove { + if doc.ResourcePath != "" && doc.RequestType == guestrequest.RequestTypeRemove { err = uvm.hcsSystem.Modify(ctx, &hostdoc) if err != nil { err = fmt.Errorf("removing VM resources: %s", err) diff --git a/internal/uvm/network.go b/internal/uvm/network.go index 52b35a33dd..2d2f2defcf 100644 --- a/internal/uvm/network.go +++ b/internal/uvm/network.go @@ -6,20 +6,20 @@ import ( "os" "github.com/Microsoft/go-winio" - "github.com/Microsoft/hcsshim/internal/ncproxyttrpc" + "github.com/Microsoft/go-winio/pkg/guid" "github.com/containerd/ttrpc" + "github.com/pkg/errors" + "github.com/sirupsen/logrus" - "github.com/Microsoft/go-winio/pkg/guid" "github.com/Microsoft/hcsshim/hcn" - "github.com/Microsoft/hcsshim/internal/guestrequest" "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/hns" "github.com/Microsoft/hcsshim/internal/log" - "github.com/Microsoft/hcsshim/internal/requesttype" + "github.com/Microsoft/hcsshim/internal/ncproxyttrpc" "github.com/Microsoft/hcsshim/osversion" - "github.com/pkg/errors" - "github.com/sirupsen/logrus" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) var ( @@ -343,9 +343,9 @@ func (uvm *UtilityVM) AddNetNS(ctx context.Context, hcnNamespace *hcn.HostComput // dynamically. if uvm.operatingSystem == "windows" { guestNamespace := hcsschema.ModifySettingRequest{ - GuestRequest: guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeNetworkNamespace, - RequestType: requesttype.Add, + GuestRequest: guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeNetworkNamespace, + RequestType: guestrequest.RequestTypeRemove, Settings: hcnNamespace, }, } @@ -464,9 +464,9 @@ func (uvm *UtilityVM) RemoveNetNS(ctx context.Context, id string) error { return err } guestNamespace := hcsschema.ModifySettingRequest{ - GuestRequest: guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeNetworkNamespace, - RequestType: requesttype.Remove, + GuestRequest: guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeNetworkNamespace, + RequestType: guestrequest.RequestTypeRemove, Settings: hcnNamespace, }, } @@ -535,7 +535,7 @@ func (uvm *UtilityVM) isNetworkNamespaceSupported() bool { return uvm.guestCaps.NamespaceAddRequestSupported } -func getNetworkModifyRequest(adapterID string, requestType string, settings interface{}) interface{} { +func getNetworkModifyRequest(adapterID string, requestType guestrequest.RequestType, settings interface{}) interface{} { if osversion.Build() >= osversion.RS5 { return guestrequest.NetworkModifyRequest{ AdapterId: adapterID, @@ -555,12 +555,12 @@ func (uvm *UtilityVM) addNIC(ctx context.Context, id string, endpoint *hns.HNSEn // First a pre-add. This is a guest-only request and is only done on Windows. if uvm.operatingSystem == "windows" { preAddRequest := hcsschema.ModifySettingRequest{ - GuestRequest: guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeNetwork, - RequestType: requesttype.Add, + GuestRequest: guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeNetwork, + RequestType: guestrequest.RequestTypeAdd, Settings: getNetworkModifyRequest( id, - requesttype.PreAdd, + guestrequest.RequestTypePreAdd, endpoint), }, } @@ -571,7 +571,7 @@ func (uvm *UtilityVM) addNIC(ctx context.Context, id string, endpoint *hns.HNSEn // Then the Add itself request := hcsschema.ModifySettingRequest{ - RequestType: requesttype.Add, + RequestType: guestrequest.RequestTypeAdd, ResourcePath: fmt.Sprintf(resourcepaths.NetworkResourceFormat, id), Settings: hcsschema.NetworkAdapter{ EndpointId: endpoint.Id, @@ -580,21 +580,21 @@ func (uvm *UtilityVM) addNIC(ctx context.Context, id string, endpoint *hns.HNSEn } if uvm.operatingSystem == "windows" { - request.GuestRequest = guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeNetwork, - RequestType: requesttype.Add, + request.GuestRequest = guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeNetwork, + RequestType: guestrequest.RequestTypeAdd, Settings: getNetworkModifyRequest( id, - requesttype.Add, + guestrequest.RequestTypeAdd, nil), } } else { // Verify this version of LCOW supports Network HotAdd if uvm.isNetworkNamespaceSupported() { - request.GuestRequest = guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeNetwork, - RequestType: requesttype.Add, - Settings: &guestrequest.LCOWNetworkAdapter{ + request.GuestRequest = guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeNetwork, + RequestType: guestrequest.RequestTypeAdd, + Settings: &guestresource.LCOWNetworkAdapter{ NamespaceID: endpoint.Namespace.ID, ID: id, MacAddress: endpoint.MacAddress, @@ -619,7 +619,7 @@ func (uvm *UtilityVM) addNIC(ctx context.Context, id string, endpoint *hns.HNSEn func (uvm *UtilityVM) removeNIC(ctx context.Context, id string, endpoint *hns.HNSEndpoint) error { request := hcsschema.ModifySettingRequest{ - RequestType: requesttype.Remove, + RequestType: guestrequest.RequestTypeRemove, ResourcePath: fmt.Sprintf(resourcepaths.NetworkResourceFormat, id), Settings: hcsschema.NetworkAdapter{ EndpointId: endpoint.Id, @@ -629,19 +629,19 @@ func (uvm *UtilityVM) removeNIC(ctx context.Context, id string, endpoint *hns.HN if uvm.operatingSystem == "windows" { request.GuestRequest = hcsschema.ModifySettingRequest{ - RequestType: requesttype.Remove, + RequestType: guestrequest.RequestTypeRemove, Settings: getNetworkModifyRequest( id, - requesttype.Remove, + guestrequest.RequestTypeRemove, nil), } } else { // Verify this version of LCOW supports Network HotRemove if uvm.isNetworkNamespaceSupported() { - request.GuestRequest = guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeNetwork, - RequestType: requesttype.Remove, - Settings: &guestrequest.LCOWNetworkAdapter{ + request.GuestRequest = guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeNetwork, + RequestType: guestrequest.RequestTypeRemove, + Settings: &guestresource.LCOWNetworkAdapter{ NamespaceID: endpoint.Namespace.ID, ID: endpoint.Id, }, @@ -670,7 +670,7 @@ func (uvm *UtilityVM) RemoveAllNICs(ctx context.Context) error { // UpdateNIC updates a UVM's network adapter. func (uvm *UtilityVM) UpdateNIC(ctx context.Context, id string, settings *hcsschema.NetworkAdapter) error { req := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Update, + RequestType: guestrequest.RequestTypeUpdate, ResourcePath: fmt.Sprintf(resourcepaths.NetworkResourceFormat, id), Settings: settings, } diff --git a/internal/uvm/pipes.go b/internal/uvm/pipes.go index ba08aedbdb..eb111662df 100644 --- a/internal/uvm/pipes.go +++ b/internal/uvm/pipes.go @@ -7,7 +7,7 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/requesttype" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" specs "github.com/opencontainers/runtime-spec/specs-go" ) @@ -31,7 +31,7 @@ func (pipe *PipeMount) Release(ctx context.Context) error { // AddPipe shares a named pipe into the UVM. func (uvm *UtilityVM) AddPipe(ctx context.Context, hostPath string) (*PipeMount, error) { modification := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Add, + RequestType: guestrequest.RequestTypeAdd, ResourcePath: fmt.Sprintf(resourcepaths.MappedPipeResourceFormat, hostPath), } if err := uvm.modify(ctx, modification); err != nil { @@ -43,7 +43,7 @@ func (uvm *UtilityVM) AddPipe(ctx context.Context, hostPath string) (*PipeMount, // RemovePipe removes a shared named pipe from the UVM. func (uvm *UtilityVM) RemovePipe(ctx context.Context, hostPath string) error { modification := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Remove, + RequestType: guestrequest.RequestTypeRemove, ResourcePath: fmt.Sprintf(resourcepaths.MappedPipeResourceFormat, hostPath), } if err := uvm.modify(ctx, modification); err != nil { diff --git a/internal/uvm/plan9.go b/internal/uvm/plan9.go index 755fbdb731..13239ce500 100644 --- a/internal/uvm/plan9.go +++ b/internal/uvm/plan9.go @@ -6,11 +6,11 @@ import ( "fmt" "strconv" - "github.com/Microsoft/hcsshim/internal/guestrequest" "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/requesttype" "github.com/Microsoft/hcsshim/osversion" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) // Plan9Share is a struct containing host paths for the UVM @@ -69,7 +69,7 @@ func (uvm *UtilityVM) AddPlan9(ctx context.Context, hostPath string, uvmPath str name := strconv.FormatUint(index, 10) modification := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Add, + RequestType: guestrequest.RequestTypeAdd, Settings: hcsschema.Plan9Share{ Name: name, AccessName: name, @@ -79,10 +79,10 @@ func (uvm *UtilityVM) AddPlan9(ctx context.Context, hostPath string, uvmPath str AllowedFiles: allowedNames, }, ResourcePath: resourcepaths.Plan9ShareResourcePath, - GuestRequest: guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeMappedDirectory, - RequestType: requesttype.Add, - Settings: guestrequest.LCOWMappedDirectory{ + GuestRequest: guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeMappedDirectory, + RequestType: guestrequest.RequestTypeAdd, + Settings: guestresource.LCOWMappedDirectory{ MountPath: uvmPath, ShareName: name, Port: plan9Port, @@ -110,17 +110,17 @@ func (uvm *UtilityVM) RemovePlan9(ctx context.Context, share *Plan9Share) error } modification := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Remove, + RequestType: guestrequest.RequestTypeRemove, Settings: hcsschema.Plan9Share{ Name: share.name, AccessName: share.name, Port: plan9Port, }, ResourcePath: resourcepaths.Plan9ShareResourcePath, - GuestRequest: guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeMappedDirectory, - RequestType: requesttype.Remove, - Settings: guestrequest.LCOWMappedDirectory{ + GuestRequest: guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeMappedDirectory, + RequestType: guestrequest.RequestTypeRemove, + Settings: guestresource.LCOWMappedDirectory{ MountPath: share.uvmPath, ShareName: share.name, Port: plan9Port, diff --git a/internal/uvm/scsi.go b/internal/uvm/scsi.go index f9587e908a..e1b898e2dd 100644 --- a/internal/uvm/scsi.go +++ b/internal/uvm/scsi.go @@ -12,15 +12,16 @@ import ( "strings" "github.com/Microsoft/go-winio/pkg/security" + "github.com/pkg/errors" + "github.com/sirupsen/logrus" + "github.com/Microsoft/hcsshim/internal/copyfile" - "github.com/Microsoft/hcsshim/internal/guestrequest" "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/log" - "github.com/Microsoft/hcsshim/internal/requesttype" "github.com/Microsoft/hcsshim/internal/wclayer" - "github.com/pkg/errors" - "github.com/sirupsen/logrus" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) // VMAccessType is used to determine the various types of access we can @@ -222,11 +223,11 @@ func (uvm *UtilityVM) RemoveSCSI(ctx context.Context, hostPath string) error { } scsiModification := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Remove, + RequestType: guestrequest.RequestTypeRemove, ResourcePath: fmt.Sprintf(resourcepaths.SCSIResourceFormat, strconv.Itoa(sm.Controller), sm.LUN), } - var verity *guestrequest.DeviceVerityInfo + var verity *guestresource.DeviceVerityInfo if v, iErr := readVeritySuperBlock(ctx, hostPath); iErr != nil { log.G(ctx).WithError(iErr).WithField("hostPath", sm.HostPath).Debug("unable to read dm-verity information from VHD") } else { @@ -246,19 +247,19 @@ func (uvm *UtilityVM) RemoveSCSI(ctx context.Context, hostPath string) error { // so that we synchronize the guest state. This seems to always avoid SCSI // related errors if this index quickly reused by another container. if uvm.operatingSystem == "windows" && sm.UVMPath != "" { - scsiModification.GuestRequest = guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeMappedVirtualDisk, - RequestType: requesttype.Remove, - Settings: guestrequest.WCOWMappedVirtualDisk{ + scsiModification.GuestRequest = guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeMappedVirtualDisk, + RequestType: guestrequest.RequestTypeRemove, + Settings: guestresource.WCOWMappedVirtualDisk{ ContainerPath: sm.UVMPath, Lun: sm.LUN, }, } } else { - scsiModification.GuestRequest = guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeMappedVirtualDisk, - RequestType: requesttype.Remove, - Settings: guestrequest.LCOWMappedVirtualDisk{ + scsiModification.GuestRequest = guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeMappedVirtualDisk, + RequestType: guestrequest.RequestTypeRemove, + Settings: guestresource.LCOWMappedVirtualDisk{ MountPath: sm.UVMPath, // May be blank in attach-only Lun: uint8(sm.LUN), Controller: uint8(sm.Controller), @@ -413,7 +414,7 @@ func (uvm *UtilityVM) addSCSIActual(ctx context.Context, addReq *addSCSIRequest) } SCSIModification := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Add, + RequestType: guestrequest.RequestTypeAdd, Settings: hcsschema.Attachment{ Path: sm.HostPath, Type_: addReq.attachmentType, @@ -424,18 +425,18 @@ func (uvm *UtilityVM) addSCSIActual(ctx context.Context, addReq *addSCSIRequest) } if sm.UVMPath != "" { - guestReq := guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeMappedVirtualDisk, - RequestType: requesttype.Add, + guestReq := guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeMappedVirtualDisk, + RequestType: guestrequest.RequestTypeAdd, } if uvm.operatingSystem == "windows" { - guestReq.Settings = guestrequest.WCOWMappedVirtualDisk{ + guestReq.Settings = guestresource.WCOWMappedVirtualDisk{ ContainerPath: sm.UVMPath, Lun: sm.LUN, } } else { - var verity *guestrequest.DeviceVerityInfo + var verity *guestresource.DeviceVerityInfo if v, iErr := readVeritySuperBlock(ctx, sm.HostPath); iErr != nil { log.G(ctx).WithError(iErr).WithField("hostPath", sm.HostPath).Debug("unable to read dm-verity information from VHD") } else { @@ -448,7 +449,7 @@ func (uvm *UtilityVM) addSCSIActual(ctx context.Context, addReq *addSCSIRequest) verity = v } - guestReq.Settings = guestrequest.LCOWMappedVirtualDisk{ + guestReq.Settings = guestresource.LCOWMappedVirtualDisk{ MountPath: sm.UVMPath, Lun: uint8(sm.LUN), Controller: uint8(sm.Controller), diff --git a/internal/uvm/security_policy.go b/internal/uvm/security_policy.go index 0898babbc1..411b62ea92 100644 --- a/internal/uvm/security_policy.go +++ b/internal/uvm/security_policy.go @@ -4,9 +4,9 @@ import ( "context" "fmt" - "github.com/Microsoft/hcsshim/internal/guestrequest" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/requesttype" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" "github.com/Microsoft/hcsshim/pkg/securitypolicy" ) @@ -27,15 +27,15 @@ func (uvm *UtilityVM) SetSecurityPolicy(ctx context.Context, policy string) erro defer uvm.m.Unlock() modification := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Add, + RequestType: guestrequest.RequestTypeAdd, Settings: securitypolicy.EncodedSecurityPolicy{ SecurityPolicy: policy, }, } - modification.GuestRequest = guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeSecurityPolicy, - RequestType: requesttype.Add, + modification.GuestRequest = guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeSecurityPolicy, + RequestType: guestrequest.RequestTypeAdd, Settings: securitypolicy.EncodedSecurityPolicy{ SecurityPolicy: policy, }, diff --git a/internal/uvm/share.go b/internal/uvm/share.go index e72d7d10c5..d66ad6831d 100644 --- a/internal/uvm/share.go +++ b/internal/uvm/share.go @@ -6,9 +6,9 @@ import ( "os" "path/filepath" - "github.com/Microsoft/hcsshim/internal/guestrequest" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/requesttype" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) // Share shares in file(s) from `reqHostPath` on the host machine to `reqUVMPath` inside the UVM. @@ -30,9 +30,9 @@ func (uvm *UtilityVM) Share(ctx context.Context, reqHostPath, reqUVMPath string, if err != nil { return err } - guestReq := guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeMappedDirectory, - RequestType: requesttype.Add, + guestReq := guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeMappedDirectory, + RequestType: guestrequest.RequestTypeAdd, Settings: &hcsschema.MappedDirectory{ HostPath: sharePath, ContainerPath: reqUVMPath, diff --git a/internal/uvm/start.go b/internal/uvm/start.go index 7fd6682cb4..28152c1ab4 100644 --- a/internal/uvm/start.go +++ b/internal/uvm/start.go @@ -13,15 +13,16 @@ import ( "syscall" "time" + "github.com/sirupsen/logrus" + "golang.org/x/sync/errgroup" + "github.com/Microsoft/hcsshim/internal/gcs" - "github.com/Microsoft/hcsshim/internal/guestrequest" "github.com/Microsoft/hcsshim/internal/hcs/schema1" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/log" "github.com/Microsoft/hcsshim/internal/logfields" - "github.com/Microsoft/hcsshim/internal/requesttype" - "github.com/sirupsen/logrus" - "golang.org/x/sync/errgroup" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) // entropyBytes is the number of bytes of random data to send to a Linux UVM @@ -135,9 +136,9 @@ func (uvm *UtilityVM) configureHvSocketForGCS(ctx context.Context) (err error) { } conSetupReq := &hcsschema.ModifySettingRequest{ - GuestRequest: guestrequest.GuestRequest{ - RequestType: requesttype.Update, - ResourceType: guestrequest.ResourceTypeHvSocket, + GuestRequest: guestrequest.ModificationRequest{ + RequestType: guestrequest.RequestTypeUpdate, + ResourceType: guestresource.ResourceTypeHvSocket, Settings: hvsocketAddress, }, } diff --git a/internal/uvm/stats.go b/internal/uvm/stats.go index 73bb65da89..d6a27b67a3 100644 --- a/internal/uvm/stats.go +++ b/internal/uvm/stats.go @@ -6,12 +6,13 @@ import ( "github.com/Microsoft/go-winio/pkg/guid" "github.com/Microsoft/go-winio/pkg/process" - "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/stats" - hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/log" "github.com/pkg/errors" "github.com/sirupsen/logrus" "golang.org/x/sys/windows" + + "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/stats" + hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" + "github.com/Microsoft/hcsshim/internal/log" ) // checkProcess checks if the process identified by the given pid has a name diff --git a/internal/uvm/virtual_device.go b/internal/uvm/virtual_device.go index 38369b6061..ff4d7e01a8 100644 --- a/internal/uvm/virtual_device.go +++ b/internal/uvm/virtual_device.go @@ -5,10 +5,11 @@ import ( "fmt" "github.com/Microsoft/go-winio/pkg/guid" - "github.com/Microsoft/hcsshim/internal/guestrequest" + "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/requesttype" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) const ( @@ -110,7 +111,7 @@ func (uvm *UtilityVM) AssignDevice(ctx context.Context, deviceID string, index u request := &hcsschema.ModifySettingRequest{ ResourcePath: fmt.Sprintf(resourcepaths.VirtualPCIResourceFormat, vmBusGUID), - RequestType: requesttype.Add, + RequestType: guestrequest.RequestTypeAdd, Settings: targetDevice, } @@ -120,10 +121,10 @@ func (uvm *UtilityVM) AssignDevice(ctx context.Context, deviceID string, index u // for LCOW, we need to make sure that specific paths relating to the // device exist so they are ready to be used by later // work in openGCS - request.GuestRequest = guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeVPCIDevice, - RequestType: requesttype.Add, - Settings: guestrequest.LCOWMappedVPCIDevice{ + request.GuestRequest = guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeVPCIDevice, + RequestType: guestrequest.RequestTypeAdd, + Settings: guestresource.LCOWMappedVPCIDevice{ VMBusGUID: vmBusGUID, }, } @@ -165,7 +166,7 @@ func (uvm *UtilityVM) RemoveDevice(ctx context.Context, deviceInstanceID string, delete(uvm.vpciDevices, key) return uvm.modify(ctx, &hcsschema.ModifySettingRequest{ ResourcePath: fmt.Sprintf(resourcepaths.VirtualPCIResourceFormat, vpci.VMBusGUID), - RequestType: requesttype.Remove, + RequestType: guestrequest.RequestTypeRemove, }) } return nil diff --git a/internal/uvm/vpmem.go b/internal/uvm/vpmem.go index d3cb8ee97f..23eb5b27f3 100644 --- a/internal/uvm/vpmem.go +++ b/internal/uvm/vpmem.go @@ -10,11 +10,11 @@ import ( "github.com/Microsoft/hcsshim/ext4/dmverity" "github.com/Microsoft/hcsshim/ext4/tar2ext4" - "github.com/Microsoft/hcsshim/internal/guestrequest" "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/log" - "github.com/Microsoft/hcsshim/internal/requesttype" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) const ( @@ -54,7 +54,7 @@ func fileSystemSize(vhdPath string) (int64, int, error) { // readVeritySuperBlock reads ext4 super block for a given VHD to then further read the dm-verity super block // and root hash -func readVeritySuperBlock(ctx context.Context, layerPath string) (*guestrequest.DeviceVerityInfo, error) { +func readVeritySuperBlock(ctx context.Context, layerPath string) (*guestresource.DeviceVerityInfo, error) { // dm-verity information is expected to be appended, the size of ext4 data will be the offset // of the dm-verity super block, followed by merkle hash tree ext4SizeInBytes, ext4BlockSize, err := fileSystemSize(layerPath) @@ -75,7 +75,7 @@ func readVeritySuperBlock(ctx context.Context, layerPath string) (*guestrequest. "dataBlockSize": dmvsb.DataBlockSize, }).Debug("dm-verity information") - return &guestrequest.DeviceVerityInfo{ + return &guestresource.DeviceVerityInfo{ Ext4SizeInBytes: ext4SizeInBytes, BlockSize: ext4BlockSize, RootDigest: dmvsb.RootDigest, @@ -143,7 +143,7 @@ func (uvm *UtilityVM) addVPMemDefault(ctx context.Context, hostPath string) (_ s } modification := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Add, + RequestType: guestrequest.RequestTypeAdd, Settings: hcsschema.VirtualPMemDevice{ HostPath: hostPath, ReadOnly: true, @@ -153,7 +153,7 @@ func (uvm *UtilityVM) addVPMemDefault(ctx context.Context, hostPath string) (_ s } uvmPath := fmt.Sprintf(lcowDefaultVPMemLayerFmt, deviceNumber) - guestSettings := guestrequest.LCOWMappedVPMemDevice{ + guestSettings := guestresource.LCOWMappedVPMemDevice{ DeviceNumber: deviceNumber, MountPath: uvmPath, } @@ -169,9 +169,9 @@ func (uvm *UtilityVM) addVPMemDefault(ctx context.Context, hostPath string) (_ s guestSettings.VerityInfo = v } - modification.GuestRequest = guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeVPMemDevice, - RequestType: requesttype.Add, + modification.GuestRequest = guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeVPMemDevice, + RequestType: guestrequest.RequestTypeAdd, Settings: guestSettings, } @@ -197,7 +197,7 @@ func (uvm *UtilityVM) removeVPMemDefault(ctx context.Context, hostPath string) e return nil } - var verity *guestrequest.DeviceVerityInfo + var verity *guestresource.DeviceVerityInfo if v, _ := readVeritySuperBlock(ctx, hostPath); v != nil { log.G(ctx).WithFields(logrus.Fields{ "hostPath": hostPath, @@ -206,12 +206,12 @@ func (uvm *UtilityVM) removeVPMemDefault(ctx context.Context, hostPath string) e verity = v } modification := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Remove, + RequestType: guestrequest.RequestTypeRemove, ResourcePath: fmt.Sprintf(resourcepaths.VPMemControllerResourceFormat, deviceNumber), - GuestRequest: guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeVPMemDevice, - RequestType: requesttype.Remove, - Settings: guestrequest.LCOWMappedVPMemDevice{ + GuestRequest: guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeVPMemDevice, + RequestType: guestrequest.RequestTypeRemove, + Settings: guestresource.LCOWMappedVPMemDevice{ DeviceNumber: deviceNumber, MountPath: device.uvmPath, VerityInfo: verity, diff --git a/internal/uvm/vpmem_mapped.go b/internal/uvm/vpmem_mapped.go index 7749531662..c690cada83 100644 --- a/internal/uvm/vpmem_mapped.go +++ b/internal/uvm/vpmem_mapped.go @@ -8,12 +8,12 @@ import ( "github.com/pkg/errors" "github.com/sirupsen/logrus" - "github.com/Microsoft/hcsshim/internal/guestrequest" "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/log" "github.com/Microsoft/hcsshim/internal/memory" - "github.com/Microsoft/hcsshim/internal/requesttype" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) const ( @@ -66,11 +66,17 @@ func pageAlign(t uint64) uint64 { // newMappedVPMemModifyRequest creates an hcsschema.ModifySettingsRequest to modify VPMem devices/mappings // for the multi-mapping setup -func newMappedVPMemModifyRequest(ctx context.Context, rType string, deviceNumber uint32, md *mappedDeviceInfo, uvm *UtilityVM) (*hcsschema.ModifySettingRequest, error) { - guestSettings := guestrequest.LCOWMappedVPMemDevice{ +func newMappedVPMemModifyRequest( + ctx context.Context, + rType guestrequest.RequestType, + deviceNumber uint32, + md *mappedDeviceInfo, + uvm *UtilityVM, +) (*hcsschema.ModifySettingRequest, error) { + guestSettings := guestresource.LCOWMappedVPMemDevice{ DeviceNumber: deviceNumber, MountPath: md.uvmPath, - MappingInfo: &guestrequest.LCOWMappedLayer{ + MappingInfo: &guestresource.LCOWVPMemMappingInfo{ DeviceOffsetInBytes: md.mappedRegion.Offset(), DeviceSizeInBytes: md.sizeInBytes, }, @@ -88,8 +94,8 @@ func newMappedVPMemModifyRequest(ctx context.Context, rType string, deviceNumber request := &hcsschema.ModifySettingRequest{ RequestType: rType, - GuestRequest: guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeVPMemDevice, + GuestRequest: guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeVPMemDevice, RequestType: rType, Settings: guestSettings, }, @@ -97,7 +103,7 @@ func newMappedVPMemModifyRequest(ctx context.Context, rType string, deviceNumber pmem := uvm.vpmemDevicesMultiMapped[deviceNumber] switch rType { - case requesttype.Add: + case guestrequest.RequestTypeAdd: if pmem == nil { request.Settings = hcsschema.VirtualPMemDevice{ ReadOnly: true, @@ -112,7 +118,7 @@ func newMappedVPMemModifyRequest(ctx context.Context, rType string, deviceNumber } request.ResourcePath = fmt.Sprintf(resourcepaths.VPMemDeviceResourceFormat, deviceNumber, md.mappedRegion.Offset()) } - case requesttype.Remove: + case guestrequest.RequestTypeRemove: if pmem == nil { return nil, errors.Errorf("no device found at location %d", deviceNumber) } @@ -259,13 +265,13 @@ func (uvm *UtilityVM) addVPMemMappedDevice(ctx context.Context, hostPath string) uvmPath := fmt.Sprintf(lcowPackedVPMemLayerFmt, deviceNumber, memReg.Offset(), devSize) md := newVPMemMappedDevice(hostPath, uvmPath, devSize, memReg) - modification, err := newMappedVPMemModifyRequest(ctx, requesttype.Add, deviceNumber, md, uvm) + modification, err := newMappedVPMemModifyRequest(ctx, guestrequest.RequestTypeAdd, deviceNumber, md, uvm) if err := uvm.modify(ctx, modification); err != nil { return "", errors.Errorf("uvm::addVPMemMappedDevice: failed to modify utility VM configuration: %s", err) } defer func() { if err != nil { - rmRequest, _ := newMappedVPMemModifyRequest(ctx, requesttype.Remove, deviceNumber, md, uvm) + rmRequest, _ := newMappedVPMemModifyRequest(ctx, guestrequest.RequestTypeRemove, deviceNumber, md, uvm) if err := uvm.modify(ctx, rmRequest); err != nil { log.G(ctx).WithError(err).Debugf("failed to rollback modification") } @@ -293,7 +299,7 @@ func (uvm *UtilityVM) removeVPMemMappedDevice(ctx context.Context, hostPath stri return nil } - modification, err := newMappedVPMemModifyRequest(ctx, requesttype.Remove, devNum, md, uvm) + modification, err := newMappedVPMemModifyRequest(ctx, guestrequest.RequestTypeRemove, devNum, md, uvm) if err != nil { return err } diff --git a/internal/uvm/vsmb.go b/internal/uvm/vsmb.go index 11d5a89b37..d641e454df 100644 --- a/internal/uvm/vsmb.go +++ b/internal/uvm/vsmb.go @@ -10,14 +10,15 @@ import ( "strconv" "unsafe" + "github.com/sirupsen/logrus" + "golang.org/x/sys/windows" + "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/log" - "github.com/Microsoft/hcsshim/internal/requesttype" "github.com/Microsoft/hcsshim/internal/winapi" "github.com/Microsoft/hcsshim/osversion" - "github.com/sirupsen/logrus" - "golang.org/x/sys/windows" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" ) const ( @@ -193,11 +194,11 @@ func (uvm *UtilityVM) AddVSMB(ctx context.Context, hostPath string, options *hcs options.NoDirectmap = true } - var requestType = requesttype.Update + var requestType = guestrequest.RequestTypeUpdate shareKey := getVSMBShareKey(hostPath, options.ReadOnly) share, err := uvm.findVSMBShare(ctx, m, shareKey) if err == ErrNotAttached { - requestType = requesttype.Add + requestType = guestrequest.RequestTypeAdd uvm.vsmbCounter++ shareName := "s" + strconv.FormatUint(uvm.vsmbCounter, 16) @@ -218,7 +219,7 @@ func (uvm *UtilityVM) AddVSMB(ctx context.Context, hostPath string, options *hcs // AllowedFileList, and in fact will return an error if RestrictFileAccess // isn't set (e.g. if used on an unrestricted share). So we only call Modify // if we are either doing an Add, or if RestrictFileAccess is set. - if requestType == requesttype.Add || options.RestrictFileAccess { + if requestType == guestrequest.RequestTypeAdd || options.RestrictFileAccess { log.G(ctx).WithFields(logrus.Fields{ "name": share.name, "path": hostPath, @@ -279,7 +280,7 @@ func (uvm *UtilityVM) RemoveVSMB(ctx context.Context, hostPath string, readOnly } modification := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Remove, + RequestType: guestrequest.RequestTypeRemove, Settings: hcsschema.VirtualSmbShare{Name: share.name}, ResourcePath: resourcepaths.VSMBShareResourcePath, } diff --git a/internal/vm/hcs/network.go b/internal/vm/hcs/network.go index 6610fffd39..bf4922af6c 100644 --- a/internal/vm/hcs/network.go +++ b/internal/vm/hcs/network.go @@ -6,12 +6,12 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/requesttype" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" ) func (uvm *utilityVM) AddNIC(ctx context.Context, nicID, endpointID, macAddr string) error { request := hcsschema.ModifySettingRequest{ - RequestType: requesttype.Add, + RequestType: guestrequest.RequestTypeAdd, ResourcePath: fmt.Sprintf(resourcepaths.NetworkResourceFormat, nicID), Settings: hcsschema.NetworkAdapter{ EndpointId: endpointID, @@ -23,7 +23,7 @@ func (uvm *utilityVM) AddNIC(ctx context.Context, nicID, endpointID, macAddr str func (uvm *utilityVM) RemoveNIC(ctx context.Context, nicID, endpointID, macAddr string) error { request := hcsschema.ModifySettingRequest{ - RequestType: requesttype.Remove, + RequestType: guestrequest.RequestTypeRemove, ResourcePath: fmt.Sprintf(resourcepaths.NetworkResourceFormat, nicID), Settings: hcsschema.NetworkAdapter{ EndpointId: endpointID, diff --git a/internal/vm/hcs/pci.go b/internal/vm/hcs/pci.go index 262823768f..03db028a29 100644 --- a/internal/vm/hcs/pci.go +++ b/internal/vm/hcs/pci.go @@ -6,13 +6,13 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/requesttype" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" ) func (uvm *utilityVM) AddDevice(ctx context.Context, instanceID, vmbusGUID string) error { request := &hcsschema.ModifySettingRequest{ ResourcePath: fmt.Sprintf(resourcepaths.VirtualPCIResourceFormat, vmbusGUID), - RequestType: requesttype.Add, + RequestType: guestrequest.RequestTypeAdd, Settings: hcsschema.VirtualPciDevice{ Functions: []hcsschema.VirtualPciFunction{ { @@ -27,7 +27,7 @@ func (uvm *utilityVM) AddDevice(ctx context.Context, instanceID, vmbusGUID strin func (uvm *utilityVM) RemoveDevice(ctx context.Context, instanceID, vmbusGUID string) error { request := &hcsschema.ModifySettingRequest{ ResourcePath: fmt.Sprintf(resourcepaths.VirtualPCIResourceFormat, vmbusGUID), - RequestType: requesttype.Remove, + RequestType: guestrequest.RequestTypeRemove, } return uvm.cs.Modify(ctx, request) } diff --git a/internal/vm/hcs/plan9.go b/internal/vm/hcs/plan9.go index 65d60c21ba..88fb9afa60 100644 --- a/internal/vm/hcs/plan9.go +++ b/internal/vm/hcs/plan9.go @@ -5,12 +5,12 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/requesttype" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" ) func (uvm *utilityVM) AddPlan9(ctx context.Context, path, name string, port int32, flags int32, allowed []string) error { modification := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Add, + RequestType: guestrequest.RequestTypeAdd, Settings: hcsschema.Plan9Share{ Name: name, AccessName: name, @@ -26,7 +26,7 @@ func (uvm *utilityVM) AddPlan9(ctx context.Context, path, name string, port int3 func (uvm *utilityVM) RemovePlan9(ctx context.Context, name string, port int32) error { modification := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Remove, + RequestType: guestrequest.RequestTypeRemove, Settings: hcsschema.Plan9Share{ Name: name, AccessName: name, diff --git a/internal/vm/hcs/scsi.go b/internal/vm/hcs/scsi.go index 1fc2bba473..70b24508ea 100644 --- a/internal/vm/hcs/scsi.go +++ b/internal/vm/hcs/scsi.go @@ -5,11 +5,12 @@ import ( "fmt" "strconv" + "github.com/pkg/errors" + "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/requesttype" "github.com/Microsoft/hcsshim/internal/vm" - "github.com/pkg/errors" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" ) func (uvmb *utilityVMBuilder) AddSCSIController(id uint32) error { @@ -55,7 +56,7 @@ func (uvm *utilityVM) AddSCSIDisk(ctx context.Context, controller uint32, lun ui return err } request := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Add, + RequestType: guestrequest.RequestTypeAdd, Settings: hcsschema.Attachment{ Path: path, Type_: diskTypeString, @@ -68,7 +69,7 @@ func (uvm *utilityVM) AddSCSIDisk(ctx context.Context, controller uint32, lun ui func (uvm *utilityVM) RemoveSCSIDisk(ctx context.Context, controller uint32, lun uint32, path string) error { request := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Remove, + RequestType: guestrequest.RequestTypeRemove, ResourcePath: fmt.Sprintf(resourcepaths.SCSIResourceFormat, strconv.Itoa(int(controller)), lun), } diff --git a/internal/vm/hcs/vpmem.go b/internal/vm/hcs/vpmem.go index 09287ab8f8..04dca05c76 100644 --- a/internal/vm/hcs/vpmem.go +++ b/internal/vm/hcs/vpmem.go @@ -5,11 +5,12 @@ import ( "fmt" "strconv" + "github.com/pkg/errors" + "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/requesttype" "github.com/Microsoft/hcsshim/internal/vm" - "github.com/pkg/errors" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" ) func (uvmb *utilityVMBuilder) AddVPMemController(maximumDevices uint32, maximumSizeBytes uint64) error { @@ -51,7 +52,7 @@ func (uvm *utilityVM) AddVPMemDevice(ctx context.Context, id uint32, path string return err } request := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Add, + RequestType: guestrequest.RequestTypeAdd, Settings: hcsschema.VirtualPMemDevice{ HostPath: path, ReadOnly: readOnly, @@ -64,7 +65,7 @@ func (uvm *utilityVM) AddVPMemDevice(ctx context.Context, id uint32, path string func (uvm *utilityVM) RemoveVPMemDevice(ctx context.Context, id uint32, path string) error { request := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Remove, + RequestType: guestrequest.RequestTypeRemove, ResourcePath: fmt.Sprintf(resourcepaths.VPMemControllerResourceFormat, id), } return uvm.cs.Modify(ctx, request) diff --git a/internal/vm/hcs/vsmb.go b/internal/vm/hcs/vsmb.go index b5cbade5b7..9b140a4685 100644 --- a/internal/vm/hcs/vsmb.go +++ b/internal/vm/hcs/vsmb.go @@ -5,8 +5,8 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/requesttype" "github.com/Microsoft/hcsshim/internal/vm" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" ) func (uvmb *utilityVMBuilder) AddVSMB(ctx context.Context, path string, name string, allowed []string, options *vm.VSMBOptions) error { @@ -43,7 +43,7 @@ func vmVSMBOptionsToHCS(options *vm.VSMBOptions) *hcsschema.VirtualSmbShareOptio func (uvm *utilityVM) AddVSMB(ctx context.Context, path string, name string, allowed []string, options *vm.VSMBOptions) error { modification := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Add, + RequestType: guestrequest.RequestTypeAdd, Settings: hcsschema.VirtualSmbShare{ Name: name, Options: vmVSMBOptionsToHCS(options), @@ -57,7 +57,7 @@ func (uvm *utilityVM) AddVSMB(ctx context.Context, path string, name string, all func (uvm *utilityVM) RemoveVSMB(ctx context.Context, name string) error { modification := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Remove, + RequestType: guestrequest.RequestTypeRemove, Settings: hcsschema.VirtualSmbShare{Name: name}, ResourcePath: resourcepaths.VSMBShareResourcePath, } diff --git a/pkg/protocol/guestrequest/types.go b/pkg/protocol/guestrequest/types.go new file mode 100644 index 0000000000..5c3d7111d4 --- /dev/null +++ b/pkg/protocol/guestrequest/types.go @@ -0,0 +1,43 @@ +package guestrequest + +// These are constants for v2 schema modify requests. + +type RequestType string +type ResourceType string + +// RequestType const +const ( + RequestTypeAdd RequestType = "Add" + RequestTypeRemove RequestType = "Remove" + RequestTypePreAdd RequestType = "PreAdd" // For networking + RequestTypeUpdate RequestType = "Update" +) + +type SignalValueWCOW string + +const ( + SignalValueWCOWCtrlC SignalValueWCOW = "CtrlC" + SignalValueWCOWCtrlBreak SignalValueWCOW = "CtrlBreak" + SignalValueWCOWCtrlClose SignalValueWCOW = "CtrlClose" + SignalValueWCOWCtrlLogOff SignalValueWCOW = "CtrlLogOff" + SignalValueWCOWCtrlShutdown SignalValueWCOW = "CtrlShutdown" +) + +// ModificationRequest is for modify commands passed to the guest. +type ModificationRequest struct { + RequestType RequestType `json:"RequestType,omitempty"` + ResourceType ResourceType `json:"ResourceType,omitempty"` + Settings interface{} `json:"Settings,omitempty"` +} + +type NetworkModifyRequest struct { + AdapterId string `json:"AdapterId,omitempty"` //nolint:stylecheck + RequestType RequestType `json:"RequestType,omitempty"` + Settings interface{} `json:"Settings,omitempty"` +} + +type RS4NetworkModifyRequest struct { + AdapterInstanceId string `json:"AdapterInstanceId,omitempty"` //nolint:stylecheck + RequestType RequestType `json:"RequestType,omitempty"` + Settings interface{} `json:"Settings,omitempty"` +} diff --git a/internal/guestrequest/types.go b/pkg/protocol/guestresource/resources.go similarity index 60% rename from internal/guestrequest/types.go rename to pkg/protocol/guestresource/resources.go index e3e09f5201..636f4c97c9 100644 --- a/internal/guestrequest/types.go +++ b/pkg/protocol/guestresource/resources.go @@ -1,8 +1,10 @@ -package guestrequest +package guestresource import ( - hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" "github.com/opencontainers/runtime-spec/specs-go" + + hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" ) // Arguably, many of these (at least CombinedLayers) should have been generated @@ -10,6 +12,34 @@ import ( // // This will also change package name due to an inbound breaking change. +const ( + // These are constants for v2 schema modify guest requests. + // ResourceTypeMappedDirectory is the modify resource type for mapped + // directories + ResourceTypeMappedDirectory guestrequest.ResourceType = "MappedDirectory" + // ResourceTypeMappedVirtualDisk is the modify resource type for mapped + // virtual disks + ResourceTypeMappedVirtualDisk guestrequest.ResourceType = "MappedVirtualDisk" + // ResourceTypeNetwork is the modify resource type for the `NetworkAdapterV2` + // device. + ResourceTypeNetwork guestrequest.ResourceType = "Network" + ResourceTypeNetworkNamespace guestrequest.ResourceType = "NetworkNamespace" + // ResourceTypeCombinedLayers is the modify resource type for combined + // layers + ResourceTypeCombinedLayers guestrequest.ResourceType = "CombinedLayers" + // ResourceTypeVPMemDevice is the modify resource type for VPMem devices + ResourceTypeVPMemDevice guestrequest.ResourceType = "VPMemDevice" + // ResourceTypeVPCIDevice is the modify resource type for vpci devices + ResourceTypeVPCIDevice guestrequest.ResourceType = "VPCIDevice" + // ResourceTypeContainerConstraints is the modify resource type for updating + // container constraints + ResourceTypeContainerConstraints guestrequest.ResourceType = "ContainerConstraints" + ResourceTypeHvSocket guestrequest.ResourceType = "HvSocket" + // ResourceTypeSecurityPolicy is the modify resource type for updating the security + // policy + ResourceTypeSecurityPolicy guestrequest.ResourceType = "SecurityPolicy" +) + // 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 @@ -17,10 +47,10 @@ import ( // the specified layers and ScratchPath together, placing the resulting union // filesystem at ContainerRootPath. type LCOWCombinedLayers struct { - ContainerID string `jason:"ContainerID"` - ContainerRootPath string `json:"ContainerRootPath,omitempty"` - Layers []hcsschema.Layer `json:"Layers,omitempty"` - ScratchPath string `json:"ScratchPath,omitempty"` + ContainerID string `json:",omitempty"` + ContainerRootPath string `json:",omitempty"` + Layers []hcsschema.Layer `json:",omitempty"` + ScratchPath string `json:",omitempty"` } type WCOWCombinedLayers struct { @@ -31,7 +61,8 @@ type WCOWCombinedLayers struct { // 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 +// LCOWMappedVirtualDisk represents a disk on the host which is mapped into a +// directory in the guest in the V2 schema. type LCOWMappedVirtualDisk struct { MountPath string `json:"MountPath,omitempty"` Lun uint8 `json:"Lun,omitempty"` @@ -47,6 +78,8 @@ type WCOWMappedVirtualDisk struct { Lun int32 `json:"Lun,omitempty"` } +// LCOWMappedDirectory represents a directory on the host which is mapped to a +// directory on the guest through Plan9 in the V2 schema. type LCOWMappedDirectory struct { MountPath string `json:"MountPath,omitempty"` Port int32 `json:"Port,omitempty"` @@ -54,8 +87,8 @@ type LCOWMappedDirectory struct { ReadOnly bool `json:"ReadOnly,omitempty"` } -// LCOWMappedLayer is one of potentially multiple read-only layers mapped on a VPMem device -type LCOWMappedLayer struct { +// LCOWVPMemMappingInfo is one of potentially multiple read-only layers mapped on a VPMem device +type LCOWVPMemMappingInfo struct { DeviceOffsetInBytes uint64 `json:"DeviceOffsetInBytes,omitempty"` DeviceSizeInBytes uint64 `json:"DeviceSizeInBytes,omitempty"` } @@ -81,16 +114,20 @@ type DeviceVerityInfo struct { // Read-only layers over VPMem type LCOWMappedVPMemDevice struct { - DeviceNumber uint32 `json:"DeviceNumber,omitempty"` - MountPath string `json:"MountPath,omitempty"` - MappingInfo *LCOWMappedLayer `json:"MappingInfo,omitempty"` - VerityInfo *DeviceVerityInfo `json:"VerityInfo,omitempty"` + DeviceNumber uint32 `json:"DeviceNumber,omitempty"` + MountPath string `json:"MountPath,omitempty"` + // MappingInfo is used when multiple devices are mapped onto a single VPMem device + MappingInfo *LCOWVPMemMappingInfo `json:"MappingInfo,omitempty"` + // VerityInfo is used when the VPMem has read-only integrity protection enabled + VerityInfo *DeviceVerityInfo `json:"VerityInfo,omitempty"` } type LCOWMappedVPCIDevice struct { VMBusGUID string `json:"VMBusGUID,omitempty"` } +// LCOWNetworkAdapter represents a network interface and its associated +// configuration in a namespace. type LCOWNetworkAdapter struct { NamespaceID string `json:",omitempty"` ID string `json:",omitempty"` @@ -110,59 +147,14 @@ type LCOWContainerConstraints struct { Linux specs.LinuxResources `json:",omitempty"` } -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" - ResourceTypeVPCIDevice ResourceType = "VPCIDevice" - ResourceTypeContainerConstraints ResourceType = "ContainerConstraints" - ResourceTypeHvSocket ResourceType = "HvSocket" - ResourceTypeSecurityPolicy ResourceType = "SecurityPolicy" -) - -// 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"` -} - // SignalProcessOptionsLCOW is the options passed to LCOW to signal a given // process. type SignalProcessOptionsLCOW struct { Signal int `json:",omitempty"` } -type SignalValueWCOW string - -const ( - SignalValueWCOWCtrlC SignalValueWCOW = "CtrlC" - SignalValueWCOWCtrlBreak SignalValueWCOW = "CtrlBreak" - SignalValueWCOWCtrlClose SignalValueWCOW = "CtrlClose" - SignalValueWCOWCtrlLogOff SignalValueWCOW = "CtrlLogOff" - SignalValueWCOWCtrlShutdown SignalValueWCOW = "CtrlShutdown" -) - // SignalProcessOptionsWCOW is the options passed to WCOW to signal a given // process. type SignalProcessOptionsWCOW struct { - Signal SignalValueWCOW `json:",omitempty"` + Signal guestrequest.SignalValueWCOW `json:",omitempty"` } diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go b/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go index f4605922ab..0eb2b6d063 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go @@ -114,9 +114,9 @@ func (process *Process) processSignalResult(ctx context.Context, err error) (boo // Signal signals the process with `options`. // -// For LCOW `guestrequest.SignalProcessOptionsLCOW`. +// For LCOW `protocol.SignalProcessOptionsLCOW`. // -// For WCOW `guestrequest.SignalProcessOptionsWCOW`. +// For WCOW `protocol.SignalProcessOptionsWCOW`. func (process *Process) Signal(ctx context.Context, options interface{}) (bool, error) { process.handleLock.RLock() defer process.handleLock.RUnlock() diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/modify_setting_request.go b/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/modify_setting_request.go index d29455a3e4..3f0309c0b2 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/modify_setting_request.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/modify_setting_request.go @@ -9,10 +9,12 @@ package hcsschema +import "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + type ModifySettingRequest struct { ResourcePath string `json:"ResourcePath,omitempty"` - RequestType string `json:"RequestType,omitempty"` + RequestType guestrequest.RequestType `json:"RequestType,omitempty"` // NOTE: Swagger generated as string. Locally updated. Settings interface{} `json:"Settings,omitempty"` // NOTE: Swagger generated as *interface{}. Locally updated diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/plan9_share.go b/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/plan9_share.go index 41f8fdea02..a7431f0e1b 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/plan9_share.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/plan9_share.go @@ -12,7 +12,7 @@ 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. + // The name by which the guest operation system can access this share, via the aname parameter in the Plan9 guestprotocol. AccessName string `json:"AccessName,omitempty"` Path string `json:"Path,omitempty"` diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/hcsoci/clone.go b/test/vendor/github.com/Microsoft/hcsshim/internal/hcsoci/clone.go index d92531ab0a..ef5b2babe2 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/hcsoci/clone.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/hcsoci/clone.go @@ -10,7 +10,7 @@ import ( "github.com/Microsoft/hcsshim/internal/cow" "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/requesttype" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" ) // Usually mounts specified in the container config are added in the container doc @@ -22,7 +22,7 @@ func addMountsToClone(ctx context.Context, c cow.Container, mounts *mountsConfig // at the same time to save time for _, md := range mounts.mdsv2 { requestDocument := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Add, + RequestType: guestrequest.RequestTypeAdd, ResourcePath: resourcepaths.SiloMappedDirectoryResourcePath, Settings: md, } @@ -34,7 +34,7 @@ func addMountsToClone(ctx context.Context, c cow.Container, mounts *mountsConfig for _, mp := range mounts.mpsv2 { requestDocument := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Add, + RequestType: guestrequest.RequestTypeAdd, ResourcePath: resourcepaths.SiloMappedPipeResourcePath, Settings: mp, } diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/hns/hnspolicylist.go b/test/vendor/github.com/Microsoft/hcsshim/internal/hns/hnspolicylist.go index 31322a6816..9e1f1cbfe1 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/hns/hnspolicylist.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/hns/hnspolicylist.go @@ -143,7 +143,7 @@ func (policylist *PolicyList) RemoveEndpoint(endpoint *HNSEndpoint) (*PolicyList 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) + logrus.Debugf(title+" endpointId=%v, isILB=%v, sourceVIP=%s, vip=%s, guestprotocol=%v, internalPort=%v, externalPort=%v", endpoints, isILB, sourceVIP, vip, protocol, internalPort, externalPort) policylist := &PolicyList{} diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/requesttype/types.go b/test/vendor/github.com/Microsoft/hcsshim/internal/requesttype/types.go deleted file mode 100644 index df2db709b0..0000000000 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/requesttype/types.go +++ /dev/null @@ -1,11 +0,0 @@ -package requesttype - -// These are constants for v2 schema modify requests. - -// RequestType const -const ( - Add = "Add" - Remove = "Remove" - PreAdd = "PreAdd" // For networking - Update = "Update" -) diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/capabilities.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/capabilities.go index d76bfdbef4..3bfa8fb182 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/capabilities.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/capabilities.go @@ -17,7 +17,7 @@ func (uvm *UtilityVM) DeleteContainerStateSupported() bool { return uvm.guestCaps.DeleteContainerStateSupported } -// Capabilities returns the protocol version and the guest defined capabilities. +// Capabilities returns the guestprotocol version and the guest defined capabilities. // This should only be used for testing. func (uvm *UtilityVM) Capabilities() (uint32, schema1.GuestDefinedCapabilities) { return uvm.protocol, uvm.guestCaps diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/combine_layers.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/combine_layers.go index ff85fcffa5..21aa03cfa1 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/combine_layers.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/combine_layers.go @@ -3,9 +3,9 @@ package uvm import ( "context" - "github.com/Microsoft/hcsshim/internal/guestrequest" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/requesttype" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) // CombineLayersWCOW combines `layerPaths` with `containerRootPath` into the @@ -17,10 +17,10 @@ func (uvm *UtilityVM) CombineLayersWCOW(ctx context.Context, layerPaths []hcssch return errNotSupported } msr := &hcsschema.ModifySettingRequest{ - GuestRequest: guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeCombinedLayers, - RequestType: requesttype.Add, - Settings: guestrequest.WCOWCombinedLayers{ + GuestRequest: guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeCombinedLayers, + RequestType: guestrequest.RequestTypeAdd, + Settings: guestresource.WCOWCombinedLayers{ ContainerRootPath: containerRootPath, Layers: layerPaths, }, @@ -40,15 +40,15 @@ func (uvm *UtilityVM) CombineLayersLCOW(ctx context.Context, containerID string, return errNotSupported } - layers := []hcsschema.Layer{} + var layers []hcsschema.Layer for _, l := range layerPaths { layers = append(layers, hcsschema.Layer{Path: l}) } msr := &hcsschema.ModifySettingRequest{ - GuestRequest: guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeCombinedLayers, - RequestType: requesttype.Add, - Settings: guestrequest.LCOWCombinedLayers{ + GuestRequest: guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeCombinedLayers, + RequestType: guestrequest.RequestTypeAdd, + Settings: guestresource.LCOWCombinedLayers{ ContainerID: containerID, ContainerRootPath: rootfsPath, Layers: layers, @@ -64,10 +64,10 @@ func (uvm *UtilityVM) CombineLayersLCOW(ctx context.Context, containerID string, // NOTE: `rootfsPath` is the path from within the UVM. func (uvm *UtilityVM) RemoveCombinedLayersWCOW(ctx context.Context, rootfsPath string) error { msr := &hcsschema.ModifySettingRequest{ - GuestRequest: guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeCombinedLayers, - RequestType: requesttype.Remove, - Settings: guestrequest.WCOWCombinedLayers{ + GuestRequest: guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeCombinedLayers, + RequestType: guestrequest.RequestTypeRemove, + Settings: guestresource.WCOWCombinedLayers{ ContainerRootPath: rootfsPath, }, }, @@ -77,10 +77,10 @@ func (uvm *UtilityVM) RemoveCombinedLayersWCOW(ctx context.Context, rootfsPath s func (uvm *UtilityVM) RemoveCombinedLayersLCOW(ctx context.Context, rootfsPath string) error { msr := &hcsschema.ModifySettingRequest{ - GuestRequest: guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeCombinedLayers, - RequestType: requesttype.Remove, - Settings: guestrequest.LCOWCombinedLayers{ + GuestRequest: guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeCombinedLayers, + RequestType: guestrequest.RequestTypeRemove, + Settings: guestresource.LCOWCombinedLayers{ ContainerRootPath: rootfsPath, }, }, diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/computeagent.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/computeagent.go index 9f748d2732..1668e30637 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/computeagent.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/computeagent.go @@ -5,13 +5,6 @@ import ( "strings" "github.com/Microsoft/go-winio" - "github.com/Microsoft/hcsshim/hcn" - "github.com/Microsoft/hcsshim/internal/computeagent" - "github.com/Microsoft/hcsshim/internal/guestrequest" - hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/hns" - ncproxynetworking "github.com/Microsoft/hcsshim/internal/ncproxy/networking" - "github.com/Microsoft/hcsshim/pkg/octtrpc" "github.com/containerd/ttrpc" "github.com/containerd/typeurl" "github.com/pkg/errors" @@ -19,7 +12,14 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "github.com/Microsoft/hcsshim/hcn" + "github.com/Microsoft/hcsshim/internal/computeagent" + hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" + "github.com/Microsoft/hcsshim/internal/hns" "github.com/Microsoft/hcsshim/internal/log" + ncproxynetworking "github.com/Microsoft/hcsshim/internal/ncproxy/networking" + "github.com/Microsoft/hcsshim/pkg/octtrpc" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) func init() { @@ -41,8 +41,8 @@ type agentComputeSystem interface { RemoveEndpointFromNS(context.Context, string, *hns.HNSEndpoint) error AssignDevice(context.Context, string, uint16, string) (*VPCIDevice, error) RemoveDevice(context.Context, string, uint16) error - AddNICInGuest(context.Context, *guestrequest.LCOWNetworkAdapter) error - RemoveNICInGuest(context.Context, *guestrequest.LCOWNetworkAdapter) error + AddNICInGuest(context.Context, *guestresource.LCOWNetworkAdapter) error + RemoveNICInGuest(context.Context, *guestresource.LCOWNetworkAdapter) error } var _ agentComputeSystem = &UtilityVM{} @@ -110,7 +110,7 @@ func (ca *computeAgent) AddNIC(ctx context.Context, req *computeagent.AddNICInte switch endpt := endpoint.(type) { case *ncproxynetworking.Endpoint: - cfg := &guestrequest.LCOWNetworkAdapter{ + cfg := &guestresource.LCOWNetworkAdapter{ NamespaceID: endpt.NamespaceID, ID: req.NicID, IPAddress: endpt.Settings.IPAddress, @@ -205,7 +205,7 @@ func (ca *computeAgent) DeleteNIC(ctx context.Context, req *computeagent.DeleteN switch endpt := endpoint.(type) { case *ncproxynetworking.Endpoint: - cfg := &guestrequest.LCOWNetworkAdapter{ + cfg := &guestresource.LCOWNetworkAdapter{ ID: req.NicID, } if err := ca.uvm.RemoveNICInGuest(ctx, cfg); err != nil { diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/create.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/create.go index e77a08f3a1..8f293f67fe 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/create.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/create.go @@ -8,6 +8,10 @@ import ( "path/filepath" "runtime" + "github.com/sirupsen/logrus" + "go.opencensus.io/trace" + "golang.org/x/sys/windows" + "github.com/Microsoft/hcsshim/internal/cow" "github.com/Microsoft/hcsshim/internal/hcs" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" @@ -16,9 +20,6 @@ import ( "github.com/Microsoft/hcsshim/internal/oc" "github.com/Microsoft/hcsshim/internal/schemaversion" "github.com/Microsoft/hcsshim/osversion" - "github.com/sirupsen/logrus" - "go.opencensus.io/trace" - "golang.org/x/sys/windows" ) // Options are the set of options passed to Create() to create a utility vm. diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/create_wcow.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/create_wcow.go index e4a4197078..c09b49d9f0 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/create_wcow.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/create_wcow.go @@ -6,6 +6,9 @@ import ( "os" "path/filepath" + "github.com/pkg/errors" + "go.opencensus.io/trace" + "github.com/Microsoft/go-winio" "github.com/Microsoft/go-winio/pkg/guid" "github.com/Microsoft/hcsshim/internal/gcs" @@ -19,8 +22,6 @@ import ( "github.com/Microsoft/hcsshim/internal/wclayer" "github.com/Microsoft/hcsshim/internal/wcow" "github.com/Microsoft/hcsshim/osversion" - "github.com/pkg/errors" - "go.opencensus.io/trace" ) // OptionsWCOW are the set of options passed to CreateWCOW() to create a utility vm. diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/hvsocket.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/hvsocket.go index 48f7730761..22b76d8988 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/hvsocket.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/hvsocket.go @@ -6,7 +6,7 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/requesttype" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" ) // UpdateHvSocketService calls HCS to update/create the hvsocket service for @@ -27,7 +27,7 @@ import ( // behavior as the relevant fields are set on HCS' side. func (uvm *UtilityVM) UpdateHvSocketService(ctx context.Context, sid string, doc *hcsschema.HvSocketServiceConfig) error { request := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Update, + RequestType: guestrequest.RequestTypeUpdate, ResourcePath: fmt.Sprintf(resourcepaths.HvSocketConfigResourceFormat, sid), Settings: doc, } @@ -37,7 +37,7 @@ func (uvm *UtilityVM) UpdateHvSocketService(ctx context.Context, sid string, doc // RemoveHvSocketService will remove an hvsocket service entry if it exists. func (uvm *UtilityVM) RemoveHvSocketService(ctx context.Context, sid string) error { request := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Remove, + RequestType: guestrequest.RequestTypeRemove, ResourcePath: fmt.Sprintf(resourcepaths.HvSocketConfigResourceFormat, sid), } return uvm.modify(ctx, request) diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/modify.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/modify.go index 72b391756c..5646156453 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/modify.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/modify.go @@ -6,7 +6,7 @@ import ( hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/log" - "github.com/Microsoft/hcsshim/internal/requesttype" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" ) // Modify modifies the compute system by sending a request to HCS. @@ -17,14 +17,14 @@ func (uvm *UtilityVM) modify(ctx context.Context, doc *hcsschema.ModifySettingRe hostdoc := *doc hostdoc.GuestRequest = nil - if doc.ResourcePath != "" && doc.RequestType == requesttype.Add { + if doc.ResourcePath != "" && doc.RequestType == guestrequest.RequestTypeAdd { err = uvm.hcsSystem.Modify(ctx, &hostdoc) if err != nil { return fmt.Errorf("adding VM resources: %s", err) } defer func() { if err != nil { - hostdoc.RequestType = requesttype.Remove + hostdoc.RequestType = guestrequest.RequestTypeRemove rerr := uvm.hcsSystem.Modify(ctx, &hostdoc) if rerr != nil { log.G(ctx).WithError(rerr).Error("failed to roll back resource add") @@ -36,7 +36,7 @@ func (uvm *UtilityVM) modify(ctx context.Context, doc *hcsschema.ModifySettingRe if err != nil { return fmt.Errorf("guest modify: %s", err) } - if doc.ResourcePath != "" && doc.RequestType == requesttype.Remove { + if doc.ResourcePath != "" && doc.RequestType == guestrequest.RequestTypeRemove { err = uvm.hcsSystem.Modify(ctx, &hostdoc) if err != nil { err = fmt.Errorf("removing VM resources: %s", err) diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/network.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/network.go index 52b35a33dd..2d2f2defcf 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/network.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/network.go @@ -6,20 +6,20 @@ import ( "os" "github.com/Microsoft/go-winio" - "github.com/Microsoft/hcsshim/internal/ncproxyttrpc" + "github.com/Microsoft/go-winio/pkg/guid" "github.com/containerd/ttrpc" + "github.com/pkg/errors" + "github.com/sirupsen/logrus" - "github.com/Microsoft/go-winio/pkg/guid" "github.com/Microsoft/hcsshim/hcn" - "github.com/Microsoft/hcsshim/internal/guestrequest" "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/hns" "github.com/Microsoft/hcsshim/internal/log" - "github.com/Microsoft/hcsshim/internal/requesttype" + "github.com/Microsoft/hcsshim/internal/ncproxyttrpc" "github.com/Microsoft/hcsshim/osversion" - "github.com/pkg/errors" - "github.com/sirupsen/logrus" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) var ( @@ -343,9 +343,9 @@ func (uvm *UtilityVM) AddNetNS(ctx context.Context, hcnNamespace *hcn.HostComput // dynamically. if uvm.operatingSystem == "windows" { guestNamespace := hcsschema.ModifySettingRequest{ - GuestRequest: guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeNetworkNamespace, - RequestType: requesttype.Add, + GuestRequest: guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeNetworkNamespace, + RequestType: guestrequest.RequestTypeRemove, Settings: hcnNamespace, }, } @@ -464,9 +464,9 @@ func (uvm *UtilityVM) RemoveNetNS(ctx context.Context, id string) error { return err } guestNamespace := hcsschema.ModifySettingRequest{ - GuestRequest: guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeNetworkNamespace, - RequestType: requesttype.Remove, + GuestRequest: guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeNetworkNamespace, + RequestType: guestrequest.RequestTypeRemove, Settings: hcnNamespace, }, } @@ -535,7 +535,7 @@ func (uvm *UtilityVM) isNetworkNamespaceSupported() bool { return uvm.guestCaps.NamespaceAddRequestSupported } -func getNetworkModifyRequest(adapterID string, requestType string, settings interface{}) interface{} { +func getNetworkModifyRequest(adapterID string, requestType guestrequest.RequestType, settings interface{}) interface{} { if osversion.Build() >= osversion.RS5 { return guestrequest.NetworkModifyRequest{ AdapterId: adapterID, @@ -555,12 +555,12 @@ func (uvm *UtilityVM) addNIC(ctx context.Context, id string, endpoint *hns.HNSEn // First a pre-add. This is a guest-only request and is only done on Windows. if uvm.operatingSystem == "windows" { preAddRequest := hcsschema.ModifySettingRequest{ - GuestRequest: guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeNetwork, - RequestType: requesttype.Add, + GuestRequest: guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeNetwork, + RequestType: guestrequest.RequestTypeAdd, Settings: getNetworkModifyRequest( id, - requesttype.PreAdd, + guestrequest.RequestTypePreAdd, endpoint), }, } @@ -571,7 +571,7 @@ func (uvm *UtilityVM) addNIC(ctx context.Context, id string, endpoint *hns.HNSEn // Then the Add itself request := hcsschema.ModifySettingRequest{ - RequestType: requesttype.Add, + RequestType: guestrequest.RequestTypeAdd, ResourcePath: fmt.Sprintf(resourcepaths.NetworkResourceFormat, id), Settings: hcsschema.NetworkAdapter{ EndpointId: endpoint.Id, @@ -580,21 +580,21 @@ func (uvm *UtilityVM) addNIC(ctx context.Context, id string, endpoint *hns.HNSEn } if uvm.operatingSystem == "windows" { - request.GuestRequest = guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeNetwork, - RequestType: requesttype.Add, + request.GuestRequest = guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeNetwork, + RequestType: guestrequest.RequestTypeAdd, Settings: getNetworkModifyRequest( id, - requesttype.Add, + guestrequest.RequestTypeAdd, nil), } } else { // Verify this version of LCOW supports Network HotAdd if uvm.isNetworkNamespaceSupported() { - request.GuestRequest = guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeNetwork, - RequestType: requesttype.Add, - Settings: &guestrequest.LCOWNetworkAdapter{ + request.GuestRequest = guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeNetwork, + RequestType: guestrequest.RequestTypeAdd, + Settings: &guestresource.LCOWNetworkAdapter{ NamespaceID: endpoint.Namespace.ID, ID: id, MacAddress: endpoint.MacAddress, @@ -619,7 +619,7 @@ func (uvm *UtilityVM) addNIC(ctx context.Context, id string, endpoint *hns.HNSEn func (uvm *UtilityVM) removeNIC(ctx context.Context, id string, endpoint *hns.HNSEndpoint) error { request := hcsschema.ModifySettingRequest{ - RequestType: requesttype.Remove, + RequestType: guestrequest.RequestTypeRemove, ResourcePath: fmt.Sprintf(resourcepaths.NetworkResourceFormat, id), Settings: hcsschema.NetworkAdapter{ EndpointId: endpoint.Id, @@ -629,19 +629,19 @@ func (uvm *UtilityVM) removeNIC(ctx context.Context, id string, endpoint *hns.HN if uvm.operatingSystem == "windows" { request.GuestRequest = hcsschema.ModifySettingRequest{ - RequestType: requesttype.Remove, + RequestType: guestrequest.RequestTypeRemove, Settings: getNetworkModifyRequest( id, - requesttype.Remove, + guestrequest.RequestTypeRemove, nil), } } else { // Verify this version of LCOW supports Network HotRemove if uvm.isNetworkNamespaceSupported() { - request.GuestRequest = guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeNetwork, - RequestType: requesttype.Remove, - Settings: &guestrequest.LCOWNetworkAdapter{ + request.GuestRequest = guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeNetwork, + RequestType: guestrequest.RequestTypeRemove, + Settings: &guestresource.LCOWNetworkAdapter{ NamespaceID: endpoint.Namespace.ID, ID: endpoint.Id, }, @@ -670,7 +670,7 @@ func (uvm *UtilityVM) RemoveAllNICs(ctx context.Context) error { // UpdateNIC updates a UVM's network adapter. func (uvm *UtilityVM) UpdateNIC(ctx context.Context, id string, settings *hcsschema.NetworkAdapter) error { req := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Update, + RequestType: guestrequest.RequestTypeUpdate, ResourcePath: fmt.Sprintf(resourcepaths.NetworkResourceFormat, id), Settings: settings, } diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/pipes.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/pipes.go index ba08aedbdb..eb111662df 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/pipes.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/pipes.go @@ -7,7 +7,7 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/requesttype" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" specs "github.com/opencontainers/runtime-spec/specs-go" ) @@ -31,7 +31,7 @@ func (pipe *PipeMount) Release(ctx context.Context) error { // AddPipe shares a named pipe into the UVM. func (uvm *UtilityVM) AddPipe(ctx context.Context, hostPath string) (*PipeMount, error) { modification := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Add, + RequestType: guestrequest.RequestTypeAdd, ResourcePath: fmt.Sprintf(resourcepaths.MappedPipeResourceFormat, hostPath), } if err := uvm.modify(ctx, modification); err != nil { @@ -43,7 +43,7 @@ func (uvm *UtilityVM) AddPipe(ctx context.Context, hostPath string) (*PipeMount, // RemovePipe removes a shared named pipe from the UVM. func (uvm *UtilityVM) RemovePipe(ctx context.Context, hostPath string) error { modification := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Remove, + RequestType: guestrequest.RequestTypeRemove, ResourcePath: fmt.Sprintf(resourcepaths.MappedPipeResourceFormat, hostPath), } if err := uvm.modify(ctx, modification); err != nil { diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/plan9.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/plan9.go index 755fbdb731..13239ce500 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/plan9.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/plan9.go @@ -6,11 +6,11 @@ import ( "fmt" "strconv" - "github.com/Microsoft/hcsshim/internal/guestrequest" "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/requesttype" "github.com/Microsoft/hcsshim/osversion" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) // Plan9Share is a struct containing host paths for the UVM @@ -69,7 +69,7 @@ func (uvm *UtilityVM) AddPlan9(ctx context.Context, hostPath string, uvmPath str name := strconv.FormatUint(index, 10) modification := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Add, + RequestType: guestrequest.RequestTypeAdd, Settings: hcsschema.Plan9Share{ Name: name, AccessName: name, @@ -79,10 +79,10 @@ func (uvm *UtilityVM) AddPlan9(ctx context.Context, hostPath string, uvmPath str AllowedFiles: allowedNames, }, ResourcePath: resourcepaths.Plan9ShareResourcePath, - GuestRequest: guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeMappedDirectory, - RequestType: requesttype.Add, - Settings: guestrequest.LCOWMappedDirectory{ + GuestRequest: guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeMappedDirectory, + RequestType: guestrequest.RequestTypeAdd, + Settings: guestresource.LCOWMappedDirectory{ MountPath: uvmPath, ShareName: name, Port: plan9Port, @@ -110,17 +110,17 @@ func (uvm *UtilityVM) RemovePlan9(ctx context.Context, share *Plan9Share) error } modification := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Remove, + RequestType: guestrequest.RequestTypeRemove, Settings: hcsschema.Plan9Share{ Name: share.name, AccessName: share.name, Port: plan9Port, }, ResourcePath: resourcepaths.Plan9ShareResourcePath, - GuestRequest: guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeMappedDirectory, - RequestType: requesttype.Remove, - Settings: guestrequest.LCOWMappedDirectory{ + GuestRequest: guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeMappedDirectory, + RequestType: guestrequest.RequestTypeRemove, + Settings: guestresource.LCOWMappedDirectory{ MountPath: share.uvmPath, ShareName: share.name, Port: plan9Port, diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/scsi.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/scsi.go index f9587e908a..e1b898e2dd 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/scsi.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/scsi.go @@ -12,15 +12,16 @@ import ( "strings" "github.com/Microsoft/go-winio/pkg/security" + "github.com/pkg/errors" + "github.com/sirupsen/logrus" + "github.com/Microsoft/hcsshim/internal/copyfile" - "github.com/Microsoft/hcsshim/internal/guestrequest" "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/log" - "github.com/Microsoft/hcsshim/internal/requesttype" "github.com/Microsoft/hcsshim/internal/wclayer" - "github.com/pkg/errors" - "github.com/sirupsen/logrus" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) // VMAccessType is used to determine the various types of access we can @@ -222,11 +223,11 @@ func (uvm *UtilityVM) RemoveSCSI(ctx context.Context, hostPath string) error { } scsiModification := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Remove, + RequestType: guestrequest.RequestTypeRemove, ResourcePath: fmt.Sprintf(resourcepaths.SCSIResourceFormat, strconv.Itoa(sm.Controller), sm.LUN), } - var verity *guestrequest.DeviceVerityInfo + var verity *guestresource.DeviceVerityInfo if v, iErr := readVeritySuperBlock(ctx, hostPath); iErr != nil { log.G(ctx).WithError(iErr).WithField("hostPath", sm.HostPath).Debug("unable to read dm-verity information from VHD") } else { @@ -246,19 +247,19 @@ func (uvm *UtilityVM) RemoveSCSI(ctx context.Context, hostPath string) error { // so that we synchronize the guest state. This seems to always avoid SCSI // related errors if this index quickly reused by another container. if uvm.operatingSystem == "windows" && sm.UVMPath != "" { - scsiModification.GuestRequest = guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeMappedVirtualDisk, - RequestType: requesttype.Remove, - Settings: guestrequest.WCOWMappedVirtualDisk{ + scsiModification.GuestRequest = guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeMappedVirtualDisk, + RequestType: guestrequest.RequestTypeRemove, + Settings: guestresource.WCOWMappedVirtualDisk{ ContainerPath: sm.UVMPath, Lun: sm.LUN, }, } } else { - scsiModification.GuestRequest = guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeMappedVirtualDisk, - RequestType: requesttype.Remove, - Settings: guestrequest.LCOWMappedVirtualDisk{ + scsiModification.GuestRequest = guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeMappedVirtualDisk, + RequestType: guestrequest.RequestTypeRemove, + Settings: guestresource.LCOWMappedVirtualDisk{ MountPath: sm.UVMPath, // May be blank in attach-only Lun: uint8(sm.LUN), Controller: uint8(sm.Controller), @@ -413,7 +414,7 @@ func (uvm *UtilityVM) addSCSIActual(ctx context.Context, addReq *addSCSIRequest) } SCSIModification := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Add, + RequestType: guestrequest.RequestTypeAdd, Settings: hcsschema.Attachment{ Path: sm.HostPath, Type_: addReq.attachmentType, @@ -424,18 +425,18 @@ func (uvm *UtilityVM) addSCSIActual(ctx context.Context, addReq *addSCSIRequest) } if sm.UVMPath != "" { - guestReq := guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeMappedVirtualDisk, - RequestType: requesttype.Add, + guestReq := guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeMappedVirtualDisk, + RequestType: guestrequest.RequestTypeAdd, } if uvm.operatingSystem == "windows" { - guestReq.Settings = guestrequest.WCOWMappedVirtualDisk{ + guestReq.Settings = guestresource.WCOWMappedVirtualDisk{ ContainerPath: sm.UVMPath, Lun: sm.LUN, } } else { - var verity *guestrequest.DeviceVerityInfo + var verity *guestresource.DeviceVerityInfo if v, iErr := readVeritySuperBlock(ctx, sm.HostPath); iErr != nil { log.G(ctx).WithError(iErr).WithField("hostPath", sm.HostPath).Debug("unable to read dm-verity information from VHD") } else { @@ -448,7 +449,7 @@ func (uvm *UtilityVM) addSCSIActual(ctx context.Context, addReq *addSCSIRequest) verity = v } - guestReq.Settings = guestrequest.LCOWMappedVirtualDisk{ + guestReq.Settings = guestresource.LCOWMappedVirtualDisk{ MountPath: sm.UVMPath, Lun: uint8(sm.LUN), Controller: uint8(sm.Controller), diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/security_policy.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/security_policy.go index 0898babbc1..411b62ea92 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/security_policy.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/security_policy.go @@ -4,9 +4,9 @@ import ( "context" "fmt" - "github.com/Microsoft/hcsshim/internal/guestrequest" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/requesttype" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" "github.com/Microsoft/hcsshim/pkg/securitypolicy" ) @@ -27,15 +27,15 @@ func (uvm *UtilityVM) SetSecurityPolicy(ctx context.Context, policy string) erro defer uvm.m.Unlock() modification := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Add, + RequestType: guestrequest.RequestTypeAdd, Settings: securitypolicy.EncodedSecurityPolicy{ SecurityPolicy: policy, }, } - modification.GuestRequest = guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeSecurityPolicy, - RequestType: requesttype.Add, + modification.GuestRequest = guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeSecurityPolicy, + RequestType: guestrequest.RequestTypeAdd, Settings: securitypolicy.EncodedSecurityPolicy{ SecurityPolicy: policy, }, diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/share.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/share.go index e72d7d10c5..d66ad6831d 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/share.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/share.go @@ -6,9 +6,9 @@ import ( "os" "path/filepath" - "github.com/Microsoft/hcsshim/internal/guestrequest" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/requesttype" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) // Share shares in file(s) from `reqHostPath` on the host machine to `reqUVMPath` inside the UVM. @@ -30,9 +30,9 @@ func (uvm *UtilityVM) Share(ctx context.Context, reqHostPath, reqUVMPath string, if err != nil { return err } - guestReq := guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeMappedDirectory, - RequestType: requesttype.Add, + guestReq := guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeMappedDirectory, + RequestType: guestrequest.RequestTypeAdd, Settings: &hcsschema.MappedDirectory{ HostPath: sharePath, ContainerPath: reqUVMPath, diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/start.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/start.go index 7fd6682cb4..28152c1ab4 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/start.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/start.go @@ -13,15 +13,16 @@ import ( "syscall" "time" + "github.com/sirupsen/logrus" + "golang.org/x/sync/errgroup" + "github.com/Microsoft/hcsshim/internal/gcs" - "github.com/Microsoft/hcsshim/internal/guestrequest" "github.com/Microsoft/hcsshim/internal/hcs/schema1" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/log" "github.com/Microsoft/hcsshim/internal/logfields" - "github.com/Microsoft/hcsshim/internal/requesttype" - "github.com/sirupsen/logrus" - "golang.org/x/sync/errgroup" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) // entropyBytes is the number of bytes of random data to send to a Linux UVM @@ -135,9 +136,9 @@ func (uvm *UtilityVM) configureHvSocketForGCS(ctx context.Context) (err error) { } conSetupReq := &hcsschema.ModifySettingRequest{ - GuestRequest: guestrequest.GuestRequest{ - RequestType: requesttype.Update, - ResourceType: guestrequest.ResourceTypeHvSocket, + GuestRequest: guestrequest.ModificationRequest{ + RequestType: guestrequest.RequestTypeUpdate, + ResourceType: guestresource.ResourceTypeHvSocket, Settings: hvsocketAddress, }, } diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/stats.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/stats.go index 73bb65da89..d6a27b67a3 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/stats.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/stats.go @@ -6,12 +6,13 @@ import ( "github.com/Microsoft/go-winio/pkg/guid" "github.com/Microsoft/go-winio/pkg/process" - "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/stats" - hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/log" "github.com/pkg/errors" "github.com/sirupsen/logrus" "golang.org/x/sys/windows" + + "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/stats" + hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" + "github.com/Microsoft/hcsshim/internal/log" ) // checkProcess checks if the process identified by the given pid has a name diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/virtual_device.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/virtual_device.go index 38369b6061..ff4d7e01a8 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/virtual_device.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/virtual_device.go @@ -5,10 +5,11 @@ import ( "fmt" "github.com/Microsoft/go-winio/pkg/guid" - "github.com/Microsoft/hcsshim/internal/guestrequest" + "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/internal/requesttype" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) const ( @@ -110,7 +111,7 @@ func (uvm *UtilityVM) AssignDevice(ctx context.Context, deviceID string, index u request := &hcsschema.ModifySettingRequest{ ResourcePath: fmt.Sprintf(resourcepaths.VirtualPCIResourceFormat, vmBusGUID), - RequestType: requesttype.Add, + RequestType: guestrequest.RequestTypeAdd, Settings: targetDevice, } @@ -120,10 +121,10 @@ func (uvm *UtilityVM) AssignDevice(ctx context.Context, deviceID string, index u // for LCOW, we need to make sure that specific paths relating to the // device exist so they are ready to be used by later // work in openGCS - request.GuestRequest = guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeVPCIDevice, - RequestType: requesttype.Add, - Settings: guestrequest.LCOWMappedVPCIDevice{ + request.GuestRequest = guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeVPCIDevice, + RequestType: guestrequest.RequestTypeAdd, + Settings: guestresource.LCOWMappedVPCIDevice{ VMBusGUID: vmBusGUID, }, } @@ -165,7 +166,7 @@ func (uvm *UtilityVM) RemoveDevice(ctx context.Context, deviceInstanceID string, delete(uvm.vpciDevices, key) return uvm.modify(ctx, &hcsschema.ModifySettingRequest{ ResourcePath: fmt.Sprintf(resourcepaths.VirtualPCIResourceFormat, vpci.VMBusGUID), - RequestType: requesttype.Remove, + RequestType: guestrequest.RequestTypeRemove, }) } return nil diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vpmem.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vpmem.go index d3cb8ee97f..23eb5b27f3 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vpmem.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vpmem.go @@ -10,11 +10,11 @@ import ( "github.com/Microsoft/hcsshim/ext4/dmverity" "github.com/Microsoft/hcsshim/ext4/tar2ext4" - "github.com/Microsoft/hcsshim/internal/guestrequest" "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/log" - "github.com/Microsoft/hcsshim/internal/requesttype" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) const ( @@ -54,7 +54,7 @@ func fileSystemSize(vhdPath string) (int64, int, error) { // readVeritySuperBlock reads ext4 super block for a given VHD to then further read the dm-verity super block // and root hash -func readVeritySuperBlock(ctx context.Context, layerPath string) (*guestrequest.DeviceVerityInfo, error) { +func readVeritySuperBlock(ctx context.Context, layerPath string) (*guestresource.DeviceVerityInfo, error) { // dm-verity information is expected to be appended, the size of ext4 data will be the offset // of the dm-verity super block, followed by merkle hash tree ext4SizeInBytes, ext4BlockSize, err := fileSystemSize(layerPath) @@ -75,7 +75,7 @@ func readVeritySuperBlock(ctx context.Context, layerPath string) (*guestrequest. "dataBlockSize": dmvsb.DataBlockSize, }).Debug("dm-verity information") - return &guestrequest.DeviceVerityInfo{ + return &guestresource.DeviceVerityInfo{ Ext4SizeInBytes: ext4SizeInBytes, BlockSize: ext4BlockSize, RootDigest: dmvsb.RootDigest, @@ -143,7 +143,7 @@ func (uvm *UtilityVM) addVPMemDefault(ctx context.Context, hostPath string) (_ s } modification := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Add, + RequestType: guestrequest.RequestTypeAdd, Settings: hcsschema.VirtualPMemDevice{ HostPath: hostPath, ReadOnly: true, @@ -153,7 +153,7 @@ func (uvm *UtilityVM) addVPMemDefault(ctx context.Context, hostPath string) (_ s } uvmPath := fmt.Sprintf(lcowDefaultVPMemLayerFmt, deviceNumber) - guestSettings := guestrequest.LCOWMappedVPMemDevice{ + guestSettings := guestresource.LCOWMappedVPMemDevice{ DeviceNumber: deviceNumber, MountPath: uvmPath, } @@ -169,9 +169,9 @@ func (uvm *UtilityVM) addVPMemDefault(ctx context.Context, hostPath string) (_ s guestSettings.VerityInfo = v } - modification.GuestRequest = guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeVPMemDevice, - RequestType: requesttype.Add, + modification.GuestRequest = guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeVPMemDevice, + RequestType: guestrequest.RequestTypeAdd, Settings: guestSettings, } @@ -197,7 +197,7 @@ func (uvm *UtilityVM) removeVPMemDefault(ctx context.Context, hostPath string) e return nil } - var verity *guestrequest.DeviceVerityInfo + var verity *guestresource.DeviceVerityInfo if v, _ := readVeritySuperBlock(ctx, hostPath); v != nil { log.G(ctx).WithFields(logrus.Fields{ "hostPath": hostPath, @@ -206,12 +206,12 @@ func (uvm *UtilityVM) removeVPMemDefault(ctx context.Context, hostPath string) e verity = v } modification := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Remove, + RequestType: guestrequest.RequestTypeRemove, ResourcePath: fmt.Sprintf(resourcepaths.VPMemControllerResourceFormat, deviceNumber), - GuestRequest: guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeVPMemDevice, - RequestType: requesttype.Remove, - Settings: guestrequest.LCOWMappedVPMemDevice{ + GuestRequest: guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeVPMemDevice, + RequestType: guestrequest.RequestTypeRemove, + Settings: guestresource.LCOWMappedVPMemDevice{ DeviceNumber: deviceNumber, MountPath: device.uvmPath, VerityInfo: verity, diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vpmem_mapped.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vpmem_mapped.go index 7749531662..c690cada83 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vpmem_mapped.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vpmem_mapped.go @@ -8,12 +8,12 @@ import ( "github.com/pkg/errors" "github.com/sirupsen/logrus" - "github.com/Microsoft/hcsshim/internal/guestrequest" "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/log" "github.com/Microsoft/hcsshim/internal/memory" - "github.com/Microsoft/hcsshim/internal/requesttype" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) const ( @@ -66,11 +66,17 @@ func pageAlign(t uint64) uint64 { // newMappedVPMemModifyRequest creates an hcsschema.ModifySettingsRequest to modify VPMem devices/mappings // for the multi-mapping setup -func newMappedVPMemModifyRequest(ctx context.Context, rType string, deviceNumber uint32, md *mappedDeviceInfo, uvm *UtilityVM) (*hcsschema.ModifySettingRequest, error) { - guestSettings := guestrequest.LCOWMappedVPMemDevice{ +func newMappedVPMemModifyRequest( + ctx context.Context, + rType guestrequest.RequestType, + deviceNumber uint32, + md *mappedDeviceInfo, + uvm *UtilityVM, +) (*hcsschema.ModifySettingRequest, error) { + guestSettings := guestresource.LCOWMappedVPMemDevice{ DeviceNumber: deviceNumber, MountPath: md.uvmPath, - MappingInfo: &guestrequest.LCOWMappedLayer{ + MappingInfo: &guestresource.LCOWVPMemMappingInfo{ DeviceOffsetInBytes: md.mappedRegion.Offset(), DeviceSizeInBytes: md.sizeInBytes, }, @@ -88,8 +94,8 @@ func newMappedVPMemModifyRequest(ctx context.Context, rType string, deviceNumber request := &hcsschema.ModifySettingRequest{ RequestType: rType, - GuestRequest: guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeVPMemDevice, + GuestRequest: guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeVPMemDevice, RequestType: rType, Settings: guestSettings, }, @@ -97,7 +103,7 @@ func newMappedVPMemModifyRequest(ctx context.Context, rType string, deviceNumber pmem := uvm.vpmemDevicesMultiMapped[deviceNumber] switch rType { - case requesttype.Add: + case guestrequest.RequestTypeAdd: if pmem == nil { request.Settings = hcsschema.VirtualPMemDevice{ ReadOnly: true, @@ -112,7 +118,7 @@ func newMappedVPMemModifyRequest(ctx context.Context, rType string, deviceNumber } request.ResourcePath = fmt.Sprintf(resourcepaths.VPMemDeviceResourceFormat, deviceNumber, md.mappedRegion.Offset()) } - case requesttype.Remove: + case guestrequest.RequestTypeRemove: if pmem == nil { return nil, errors.Errorf("no device found at location %d", deviceNumber) } @@ -259,13 +265,13 @@ func (uvm *UtilityVM) addVPMemMappedDevice(ctx context.Context, hostPath string) uvmPath := fmt.Sprintf(lcowPackedVPMemLayerFmt, deviceNumber, memReg.Offset(), devSize) md := newVPMemMappedDevice(hostPath, uvmPath, devSize, memReg) - modification, err := newMappedVPMemModifyRequest(ctx, requesttype.Add, deviceNumber, md, uvm) + modification, err := newMappedVPMemModifyRequest(ctx, guestrequest.RequestTypeAdd, deviceNumber, md, uvm) if err := uvm.modify(ctx, modification); err != nil { return "", errors.Errorf("uvm::addVPMemMappedDevice: failed to modify utility VM configuration: %s", err) } defer func() { if err != nil { - rmRequest, _ := newMappedVPMemModifyRequest(ctx, requesttype.Remove, deviceNumber, md, uvm) + rmRequest, _ := newMappedVPMemModifyRequest(ctx, guestrequest.RequestTypeRemove, deviceNumber, md, uvm) if err := uvm.modify(ctx, rmRequest); err != nil { log.G(ctx).WithError(err).Debugf("failed to rollback modification") } @@ -293,7 +299,7 @@ func (uvm *UtilityVM) removeVPMemMappedDevice(ctx context.Context, hostPath stri return nil } - modification, err := newMappedVPMemModifyRequest(ctx, requesttype.Remove, devNum, md, uvm) + modification, err := newMappedVPMemModifyRequest(ctx, guestrequest.RequestTypeRemove, devNum, md, uvm) if err != nil { return err } diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vsmb.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vsmb.go index 11d5a89b37..d641e454df 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vsmb.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vsmb.go @@ -10,14 +10,15 @@ import ( "strconv" "unsafe" + "github.com/sirupsen/logrus" + "golang.org/x/sys/windows" + "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/log" - "github.com/Microsoft/hcsshim/internal/requesttype" "github.com/Microsoft/hcsshim/internal/winapi" "github.com/Microsoft/hcsshim/osversion" - "github.com/sirupsen/logrus" - "golang.org/x/sys/windows" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" ) const ( @@ -193,11 +194,11 @@ func (uvm *UtilityVM) AddVSMB(ctx context.Context, hostPath string, options *hcs options.NoDirectmap = true } - var requestType = requesttype.Update + var requestType = guestrequest.RequestTypeUpdate shareKey := getVSMBShareKey(hostPath, options.ReadOnly) share, err := uvm.findVSMBShare(ctx, m, shareKey) if err == ErrNotAttached { - requestType = requesttype.Add + requestType = guestrequest.RequestTypeAdd uvm.vsmbCounter++ shareName := "s" + strconv.FormatUint(uvm.vsmbCounter, 16) @@ -218,7 +219,7 @@ func (uvm *UtilityVM) AddVSMB(ctx context.Context, hostPath string, options *hcs // AllowedFileList, and in fact will return an error if RestrictFileAccess // isn't set (e.g. if used on an unrestricted share). So we only call Modify // if we are either doing an Add, or if RestrictFileAccess is set. - if requestType == requesttype.Add || options.RestrictFileAccess { + if requestType == guestrequest.RequestTypeAdd || options.RestrictFileAccess { log.G(ctx).WithFields(logrus.Fields{ "name": share.name, "path": hostPath, @@ -279,7 +280,7 @@ func (uvm *UtilityVM) RemoveVSMB(ctx context.Context, hostPath string, readOnly } modification := &hcsschema.ModifySettingRequest{ - RequestType: requesttype.Remove, + RequestType: guestrequest.RequestTypeRemove, Settings: hcsschema.VirtualSmbShare{Name: share.name}, ResourcePath: resourcepaths.VSMBShareResourcePath, } diff --git a/test/vendor/github.com/Microsoft/hcsshim/pkg/protocol/guestrequest/types.go b/test/vendor/github.com/Microsoft/hcsshim/pkg/protocol/guestrequest/types.go new file mode 100644 index 0000000000..5c3d7111d4 --- /dev/null +++ b/test/vendor/github.com/Microsoft/hcsshim/pkg/protocol/guestrequest/types.go @@ -0,0 +1,43 @@ +package guestrequest + +// These are constants for v2 schema modify requests. + +type RequestType string +type ResourceType string + +// RequestType const +const ( + RequestTypeAdd RequestType = "Add" + RequestTypeRemove RequestType = "Remove" + RequestTypePreAdd RequestType = "PreAdd" // For networking + RequestTypeUpdate RequestType = "Update" +) + +type SignalValueWCOW string + +const ( + SignalValueWCOWCtrlC SignalValueWCOW = "CtrlC" + SignalValueWCOWCtrlBreak SignalValueWCOW = "CtrlBreak" + SignalValueWCOWCtrlClose SignalValueWCOW = "CtrlClose" + SignalValueWCOWCtrlLogOff SignalValueWCOW = "CtrlLogOff" + SignalValueWCOWCtrlShutdown SignalValueWCOW = "CtrlShutdown" +) + +// ModificationRequest is for modify commands passed to the guest. +type ModificationRequest struct { + RequestType RequestType `json:"RequestType,omitempty"` + ResourceType ResourceType `json:"ResourceType,omitempty"` + Settings interface{} `json:"Settings,omitempty"` +} + +type NetworkModifyRequest struct { + AdapterId string `json:"AdapterId,omitempty"` //nolint:stylecheck + RequestType RequestType `json:"RequestType,omitempty"` + Settings interface{} `json:"Settings,omitempty"` +} + +type RS4NetworkModifyRequest struct { + AdapterInstanceId string `json:"AdapterInstanceId,omitempty"` //nolint:stylecheck + RequestType RequestType `json:"RequestType,omitempty"` + Settings interface{} `json:"Settings,omitempty"` +} diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/guestrequest/types.go b/test/vendor/github.com/Microsoft/hcsshim/pkg/protocol/guestresource/resources.go similarity index 60% rename from test/vendor/github.com/Microsoft/hcsshim/internal/guestrequest/types.go rename to test/vendor/github.com/Microsoft/hcsshim/pkg/protocol/guestresource/resources.go index e3e09f5201..636f4c97c9 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/guestrequest/types.go +++ b/test/vendor/github.com/Microsoft/hcsshim/pkg/protocol/guestresource/resources.go @@ -1,8 +1,10 @@ -package guestrequest +package guestresource import ( - hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" + "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" "github.com/opencontainers/runtime-spec/specs-go" + + hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" ) // Arguably, many of these (at least CombinedLayers) should have been generated @@ -10,6 +12,34 @@ import ( // // This will also change package name due to an inbound breaking change. +const ( + // These are constants for v2 schema modify guest requests. + // ResourceTypeMappedDirectory is the modify resource type for mapped + // directories + ResourceTypeMappedDirectory guestrequest.ResourceType = "MappedDirectory" + // ResourceTypeMappedVirtualDisk is the modify resource type for mapped + // virtual disks + ResourceTypeMappedVirtualDisk guestrequest.ResourceType = "MappedVirtualDisk" + // ResourceTypeNetwork is the modify resource type for the `NetworkAdapterV2` + // device. + ResourceTypeNetwork guestrequest.ResourceType = "Network" + ResourceTypeNetworkNamespace guestrequest.ResourceType = "NetworkNamespace" + // ResourceTypeCombinedLayers is the modify resource type for combined + // layers + ResourceTypeCombinedLayers guestrequest.ResourceType = "CombinedLayers" + // ResourceTypeVPMemDevice is the modify resource type for VPMem devices + ResourceTypeVPMemDevice guestrequest.ResourceType = "VPMemDevice" + // ResourceTypeVPCIDevice is the modify resource type for vpci devices + ResourceTypeVPCIDevice guestrequest.ResourceType = "VPCIDevice" + // ResourceTypeContainerConstraints is the modify resource type for updating + // container constraints + ResourceTypeContainerConstraints guestrequest.ResourceType = "ContainerConstraints" + ResourceTypeHvSocket guestrequest.ResourceType = "HvSocket" + // ResourceTypeSecurityPolicy is the modify resource type for updating the security + // policy + ResourceTypeSecurityPolicy guestrequest.ResourceType = "SecurityPolicy" +) + // 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 @@ -17,10 +47,10 @@ import ( // the specified layers and ScratchPath together, placing the resulting union // filesystem at ContainerRootPath. type LCOWCombinedLayers struct { - ContainerID string `jason:"ContainerID"` - ContainerRootPath string `json:"ContainerRootPath,omitempty"` - Layers []hcsschema.Layer `json:"Layers,omitempty"` - ScratchPath string `json:"ScratchPath,omitempty"` + ContainerID string `json:",omitempty"` + ContainerRootPath string `json:",omitempty"` + Layers []hcsschema.Layer `json:",omitempty"` + ScratchPath string `json:",omitempty"` } type WCOWCombinedLayers struct { @@ -31,7 +61,8 @@ type WCOWCombinedLayers struct { // 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 +// LCOWMappedVirtualDisk represents a disk on the host which is mapped into a +// directory in the guest in the V2 schema. type LCOWMappedVirtualDisk struct { MountPath string `json:"MountPath,omitempty"` Lun uint8 `json:"Lun,omitempty"` @@ -47,6 +78,8 @@ type WCOWMappedVirtualDisk struct { Lun int32 `json:"Lun,omitempty"` } +// LCOWMappedDirectory represents a directory on the host which is mapped to a +// directory on the guest through Plan9 in the V2 schema. type LCOWMappedDirectory struct { MountPath string `json:"MountPath,omitempty"` Port int32 `json:"Port,omitempty"` @@ -54,8 +87,8 @@ type LCOWMappedDirectory struct { ReadOnly bool `json:"ReadOnly,omitempty"` } -// LCOWMappedLayer is one of potentially multiple read-only layers mapped on a VPMem device -type LCOWMappedLayer struct { +// LCOWVPMemMappingInfo is one of potentially multiple read-only layers mapped on a VPMem device +type LCOWVPMemMappingInfo struct { DeviceOffsetInBytes uint64 `json:"DeviceOffsetInBytes,omitempty"` DeviceSizeInBytes uint64 `json:"DeviceSizeInBytes,omitempty"` } @@ -81,16 +114,20 @@ type DeviceVerityInfo struct { // Read-only layers over VPMem type LCOWMappedVPMemDevice struct { - DeviceNumber uint32 `json:"DeviceNumber,omitempty"` - MountPath string `json:"MountPath,omitempty"` - MappingInfo *LCOWMappedLayer `json:"MappingInfo,omitempty"` - VerityInfo *DeviceVerityInfo `json:"VerityInfo,omitempty"` + DeviceNumber uint32 `json:"DeviceNumber,omitempty"` + MountPath string `json:"MountPath,omitempty"` + // MappingInfo is used when multiple devices are mapped onto a single VPMem device + MappingInfo *LCOWVPMemMappingInfo `json:"MappingInfo,omitempty"` + // VerityInfo is used when the VPMem has read-only integrity protection enabled + VerityInfo *DeviceVerityInfo `json:"VerityInfo,omitempty"` } type LCOWMappedVPCIDevice struct { VMBusGUID string `json:"VMBusGUID,omitempty"` } +// LCOWNetworkAdapter represents a network interface and its associated +// configuration in a namespace. type LCOWNetworkAdapter struct { NamespaceID string `json:",omitempty"` ID string `json:",omitempty"` @@ -110,59 +147,14 @@ type LCOWContainerConstraints struct { Linux specs.LinuxResources `json:",omitempty"` } -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" - ResourceTypeVPCIDevice ResourceType = "VPCIDevice" - ResourceTypeContainerConstraints ResourceType = "ContainerConstraints" - ResourceTypeHvSocket ResourceType = "HvSocket" - ResourceTypeSecurityPolicy ResourceType = "SecurityPolicy" -) - -// 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"` -} - // SignalProcessOptionsLCOW is the options passed to LCOW to signal a given // process. type SignalProcessOptionsLCOW struct { Signal int `json:",omitempty"` } -type SignalValueWCOW string - -const ( - SignalValueWCOWCtrlC SignalValueWCOW = "CtrlC" - SignalValueWCOWCtrlBreak SignalValueWCOW = "CtrlBreak" - SignalValueWCOWCtrlClose SignalValueWCOW = "CtrlClose" - SignalValueWCOWCtrlLogOff SignalValueWCOW = "CtrlLogOff" - SignalValueWCOWCtrlShutdown SignalValueWCOW = "CtrlShutdown" -) - // SignalProcessOptionsWCOW is the options passed to WCOW to signal a given // process. type SignalProcessOptionsWCOW struct { - Signal SignalValueWCOW `json:",omitempty"` + Signal guestrequest.SignalValueWCOW `json:",omitempty"` } diff --git a/test/vendor/modules.txt b/test/vendor/modules.txt index d9959cd498..569213ac45 100644 --- a/test/vendor/modules.txt +++ b/test/vendor/modules.txt @@ -28,7 +28,6 @@ github.com/Microsoft/hcsshim/internal/credentials github.com/Microsoft/hcsshim/internal/devices github.com/Microsoft/hcsshim/internal/extendedtask github.com/Microsoft/hcsshim/internal/gcs -github.com/Microsoft/hcsshim/internal/guestrequest github.com/Microsoft/hcsshim/internal/hcs github.com/Microsoft/hcsshim/internal/hcs/resourcepaths github.com/Microsoft/hcsshim/internal/hcs/schema1 @@ -51,7 +50,6 @@ github.com/Microsoft/hcsshim/internal/oci github.com/Microsoft/hcsshim/internal/ospath github.com/Microsoft/hcsshim/internal/processorinfo github.com/Microsoft/hcsshim/internal/regstate -github.com/Microsoft/hcsshim/internal/requesttype github.com/Microsoft/hcsshim/internal/resources github.com/Microsoft/hcsshim/internal/runhcs github.com/Microsoft/hcsshim/internal/safefile @@ -69,6 +67,8 @@ github.com/Microsoft/hcsshim/pkg/annotations github.com/Microsoft/hcsshim/pkg/go-runhcs github.com/Microsoft/hcsshim/pkg/ociwclayer github.com/Microsoft/hcsshim/pkg/octtrpc +github.com/Microsoft/hcsshim/pkg/protocol/guestrequest +github.com/Microsoft/hcsshim/pkg/protocol/guestresource github.com/Microsoft/hcsshim/pkg/securitypolicy # github.com/bits-and-blooms/bitset v1.2.0 github.com/bits-and-blooms/bitset From 89ebebcb43957bd2fb3d16859babcee9bca3bfe5 Mon Sep 17 00:00:00 2001 From: Maksim An Date: Mon, 13 Dec 2021 17:10:06 -0800 Subject: [PATCH 2/5] pr feedback: guestrequest and guestresource as internal package Do not export guestrequest and guestresource packages and rather keep them under internal/protocol. Signed-off-by: Maksim An --- cmd/containerd-shim-runhcs-v1/exec_hcs.go | 2 +- cmd/containerd-shim-runhcs-v1/task_hcs.go | 4 ++-- internal/guest/bridge/bridge_v2.go | 2 +- internal/guest/prot/protocol.go | 4 ++-- internal/guest/runtime/hcsv2/container.go | 4 ++-- internal/guest/runtime/hcsv2/network.go | 2 +- internal/guest/runtime/hcsv2/network_test.go | 2 +- internal/guest/runtime/hcsv2/uvm.go | 4 ++-- internal/guest/storage/devicemapper/targets.go | 2 +- internal/guest/storage/pmem/pmem.go | 2 +- internal/guest/storage/pmem/pmem_test.go | 2 +- internal/guest/storage/scsi/scsi.go | 2 +- internal/guest/storage/scsi/scsi_test.go | 2 +- internal/hcs/schema2/modify_setting_request.go | 2 +- internal/hcsoci/clone.go | 2 +- internal/jobcontainers/process.go | 2 +- {pkg => internal}/protocol/guestrequest/types.go | 0 {pkg => internal}/protocol/guestresource/resources.go | 2 +- internal/signals/signal.go | 4 ++-- internal/signals/signal_test.go | 2 +- internal/uvm/combine_layers.go | 4 ++-- internal/uvm/hvsocket.go | 2 +- internal/uvm/modify.go | 2 +- internal/uvm/network.go | 4 ++-- internal/uvm/pipes.go | 2 +- internal/uvm/plan9.go | 4 ++-- internal/uvm/scsi.go | 4 ++-- internal/uvm/security_policy.go | 4 ++-- internal/uvm/share.go | 4 ++-- internal/uvm/start.go | 4 ++-- internal/uvm/virtual_device.go | 4 ++-- internal/uvm/vpmem.go | 4 ++-- internal/uvm/vpmem_mapped.go | 4 ++-- internal/uvm/vsmb.go | 2 +- internal/vm/hcs/network.go | 2 +- internal/vm/hcs/pci.go | 2 +- internal/vm/hcs/plan9.go | 2 +- internal/vm/hcs/scsi.go | 2 +- internal/vm/hcs/vpmem.go | 2 +- internal/vm/hcs/vsmb.go | 2 +- .../hcsshim/internal/hcs/schema2/modify_setting_request.go | 2 +- .../github.com/Microsoft/hcsshim/internal/hcsoci/clone.go | 2 +- .../hcsshim/{pkg => internal}/protocol/guestrequest/types.go | 0 .../{pkg => internal}/protocol/guestresource/resources.go | 2 +- .../Microsoft/hcsshim/internal/uvm/combine_layers.go | 4 ++-- .../github.com/Microsoft/hcsshim/internal/uvm/hvsocket.go | 2 +- .../github.com/Microsoft/hcsshim/internal/uvm/modify.go | 2 +- .../github.com/Microsoft/hcsshim/internal/uvm/network.go | 4 ++-- .../vendor/github.com/Microsoft/hcsshim/internal/uvm/pipes.go | 2 +- .../vendor/github.com/Microsoft/hcsshim/internal/uvm/plan9.go | 4 ++-- test/vendor/github.com/Microsoft/hcsshim/internal/uvm/scsi.go | 4 ++-- .../Microsoft/hcsshim/internal/uvm/security_policy.go | 4 ++-- .../vendor/github.com/Microsoft/hcsshim/internal/uvm/share.go | 4 ++-- .../vendor/github.com/Microsoft/hcsshim/internal/uvm/start.go | 4 ++-- .../Microsoft/hcsshim/internal/uvm/virtual_device.go | 4 ++-- .../vendor/github.com/Microsoft/hcsshim/internal/uvm/vpmem.go | 4 ++-- .../github.com/Microsoft/hcsshim/internal/uvm/vpmem_mapped.go | 4 ++-- test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vsmb.go | 2 +- test/vendor/modules.txt | 4 ++-- 59 files changed, 83 insertions(+), 83 deletions(-) rename {pkg => internal}/protocol/guestrequest/types.go (100%) rename {pkg => internal}/protocol/guestresource/resources.go (99%) rename test/vendor/github.com/Microsoft/hcsshim/{pkg => internal}/protocol/guestrequest/types.go (100%) rename test/vendor/github.com/Microsoft/hcsshim/{pkg => internal}/protocol/guestresource/resources.go (99%) diff --git a/cmd/containerd-shim-runhcs-v1/exec_hcs.go b/cmd/containerd-shim-runhcs-v1/exec_hcs.go index a1ff2aeb28..b3b8e84ee9 100644 --- a/cmd/containerd-shim-runhcs-v1/exec_hcs.go +++ b/cmd/containerd-shim-runhcs-v1/exec_hcs.go @@ -18,10 +18,10 @@ import ( "github.com/Microsoft/hcsshim/internal/cmd" "github.com/Microsoft/hcsshim/internal/cow" "github.com/Microsoft/hcsshim/internal/log" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" "github.com/Microsoft/hcsshim/internal/signals" "github.com/Microsoft/hcsshim/internal/uvm" "github.com/Microsoft/hcsshim/osversion" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) // newHcsExec creates an exec to track the lifetime of `spec` in `c` which is diff --git a/cmd/containerd-shim-runhcs-v1/task_hcs.go b/cmd/containerd-shim-runhcs-v1/task_hcs.go index 1b3d4cbb61..9076e2b08f 100644 --- a/cmd/containerd-shim-runhcs-v1/task_hcs.go +++ b/cmd/containerd-shim-runhcs-v1/task_hcs.go @@ -31,13 +31,13 @@ import ( "github.com/Microsoft/hcsshim/internal/log" "github.com/Microsoft/hcsshim/internal/oci" "github.com/Microsoft/hcsshim/internal/processorinfo" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" "github.com/Microsoft/hcsshim/internal/resources" "github.com/Microsoft/hcsshim/internal/shimdiag" "github.com/Microsoft/hcsshim/internal/uvm" "github.com/Microsoft/hcsshim/osversion" "github.com/Microsoft/hcsshim/pkg/annotations" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) const bytesPerMB = 1024 * 1024 diff --git a/internal/guest/bridge/bridge_v2.go b/internal/guest/bridge/bridge_v2.go index 098add6800..f7924a2576 100644 --- a/internal/guest/bridge/bridge_v2.go +++ b/internal/guest/bridge/bridge_v2.go @@ -21,7 +21,7 @@ import ( "github.com/Microsoft/hcsshim/internal/guest/stdio" "github.com/Microsoft/hcsshim/internal/log" "github.com/Microsoft/hcsshim/internal/oc" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" ) // The capabilities of this GCS. diff --git a/internal/guest/prot/protocol.go b/internal/guest/prot/protocol.go index 39b7e85822..84d05ff446 100644 --- a/internal/guest/prot/protocol.go +++ b/internal/guest/prot/protocol.go @@ -13,8 +13,8 @@ import ( "github.com/Microsoft/hcsshim/internal/guest/commonutils" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" "github.com/Microsoft/hcsshim/pkg/securitypolicy" ) diff --git a/internal/guest/runtime/hcsv2/container.go b/internal/guest/runtime/hcsv2/container.go index 279552c8bd..d222842e6b 100644 --- a/internal/guest/runtime/hcsv2/container.go +++ b/internal/guest/runtime/hcsv2/container.go @@ -23,8 +23,8 @@ import ( "github.com/Microsoft/hcsshim/internal/guest/transport" "github.com/Microsoft/hcsshim/internal/log" "github.com/Microsoft/hcsshim/internal/logfields" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) type Container struct { diff --git a/internal/guest/runtime/hcsv2/network.go b/internal/guest/runtime/hcsv2/network.go index 277077f24d..9feb7afaed 100644 --- a/internal/guest/runtime/hcsv2/network.go +++ b/internal/guest/runtime/hcsv2/network.go @@ -18,7 +18,7 @@ import ( "github.com/Microsoft/hcsshim/internal/guest/network" "github.com/Microsoft/hcsshim/internal/guest/prot" "github.com/Microsoft/hcsshim/internal/oc" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) var ( diff --git a/internal/guest/runtime/hcsv2/network_test.go b/internal/guest/runtime/hcsv2/network_test.go index 2fe1f0457c..3ac4b9eed1 100644 --- a/internal/guest/runtime/hcsv2/network_test.go +++ b/internal/guest/runtime/hcsv2/network_test.go @@ -7,7 +7,7 @@ import ( "context" "testing" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) func Test_getNetworkNamespace_NotExist(t *testing.T) { diff --git a/internal/guest/runtime/hcsv2/uvm.go b/internal/guest/runtime/hcsv2/uvm.go index 9cac246208..bd359da0e1 100644 --- a/internal/guest/runtime/hcsv2/uvm.go +++ b/internal/guest/runtime/hcsv2/uvm.go @@ -30,9 +30,9 @@ import ( "github.com/Microsoft/hcsshim/internal/guest/storage/pmem" "github.com/Microsoft/hcsshim/internal/guest/storage/scsi" "github.com/Microsoft/hcsshim/internal/guest/transport" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" "github.com/Microsoft/hcsshim/pkg/annotations" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" "github.com/Microsoft/hcsshim/pkg/securitypolicy" ) diff --git a/internal/guest/storage/devicemapper/targets.go b/internal/guest/storage/devicemapper/targets.go index d9ff565873..82650e7562 100644 --- a/internal/guest/storage/devicemapper/targets.go +++ b/internal/guest/storage/devicemapper/targets.go @@ -12,7 +12,7 @@ import ( "github.com/Microsoft/hcsshim/ext4/dmverity" "github.com/Microsoft/hcsshim/internal/oc" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) // CreateZeroSectorLinearTarget creates dm-linear target for a device at `devPath` and `mappingInfo`, returns diff --git a/internal/guest/storage/pmem/pmem.go b/internal/guest/storage/pmem/pmem.go index 6dde7fff9c..9063d4b3da 100644 --- a/internal/guest/storage/pmem/pmem.go +++ b/internal/guest/storage/pmem/pmem.go @@ -16,7 +16,7 @@ import ( dm "github.com/Microsoft/hcsshim/internal/guest/storage/devicemapper" "github.com/Microsoft/hcsshim/internal/log" "github.com/Microsoft/hcsshim/internal/oc" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" "github.com/Microsoft/hcsshim/pkg/securitypolicy" ) diff --git a/internal/guest/storage/pmem/pmem_test.go b/internal/guest/storage/pmem/pmem_test.go index fb8b6e4c4b..7051733f96 100644 --- a/internal/guest/storage/pmem/pmem_test.go +++ b/internal/guest/storage/pmem/pmem_test.go @@ -13,7 +13,7 @@ import ( "golang.org/x/sys/unix" "github.com/Microsoft/hcsshim/internal/guest/storage/test/policy" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" "github.com/Microsoft/hcsshim/pkg/securitypolicy" ) diff --git a/internal/guest/storage/scsi/scsi.go b/internal/guest/storage/scsi/scsi.go index 611e8ade2d..f5231dfb9d 100644 --- a/internal/guest/storage/scsi/scsi.go +++ b/internal/guest/storage/scsi/scsi.go @@ -20,7 +20,7 @@ import ( dm "github.com/Microsoft/hcsshim/internal/guest/storage/devicemapper" "github.com/Microsoft/hcsshim/internal/log" "github.com/Microsoft/hcsshim/internal/oc" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" "github.com/Microsoft/hcsshim/pkg/securitypolicy" ) diff --git a/internal/guest/storage/scsi/scsi_test.go b/internal/guest/storage/scsi/scsi_test.go index de73a930a3..4ac33ebcb4 100644 --- a/internal/guest/storage/scsi/scsi_test.go +++ b/internal/guest/storage/scsi/scsi_test.go @@ -13,7 +13,7 @@ import ( "golang.org/x/sys/unix" "github.com/Microsoft/hcsshim/internal/guest/storage/test/policy" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" "github.com/Microsoft/hcsshim/pkg/securitypolicy" ) diff --git a/internal/hcs/schema2/modify_setting_request.go b/internal/hcs/schema2/modify_setting_request.go index 3f0309c0b2..6364da8e23 100644 --- a/internal/hcs/schema2/modify_setting_request.go +++ b/internal/hcs/schema2/modify_setting_request.go @@ -9,7 +9,7 @@ package hcsschema -import "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" +import "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" type ModifySettingRequest struct { ResourcePath string `json:"ResourcePath,omitempty"` diff --git a/internal/hcsoci/clone.go b/internal/hcsoci/clone.go index ef5b2babe2..5a8a5fa5d0 100644 --- a/internal/hcsoci/clone.go +++ b/internal/hcsoci/clone.go @@ -10,7 +10,7 @@ import ( "github.com/Microsoft/hcsshim/internal/cow" "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" ) // Usually mounts specified in the container config are added in the container doc diff --git a/internal/jobcontainers/process.go b/internal/jobcontainers/process.go index 7f66028bc8..f6df14f498 100644 --- a/internal/jobcontainers/process.go +++ b/internal/jobcontainers/process.go @@ -14,8 +14,8 @@ import ( "github.com/Microsoft/hcsshim/internal/exec" "github.com/Microsoft/hcsshim/internal/hcs" "github.com/Microsoft/hcsshim/internal/log" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" "github.com/Microsoft/hcsshim/internal/winapi" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) // JobProcess represents a process run in a job object. diff --git a/pkg/protocol/guestrequest/types.go b/internal/protocol/guestrequest/types.go similarity index 100% rename from pkg/protocol/guestrequest/types.go rename to internal/protocol/guestrequest/types.go diff --git a/pkg/protocol/guestresource/resources.go b/internal/protocol/guestresource/resources.go similarity index 99% rename from pkg/protocol/guestresource/resources.go rename to internal/protocol/guestresource/resources.go index 636f4c97c9..55ae09730c 100644 --- a/pkg/protocol/guestresource/resources.go +++ b/internal/protocol/guestresource/resources.go @@ -1,7 +1,7 @@ package guestresource import ( - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" "github.com/opencontainers/runtime-spec/specs-go" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" diff --git a/internal/signals/signal.go b/internal/signals/signal.go index a4f6fc7348..e375bc5a14 100644 --- a/internal/signals/signal.go +++ b/internal/signals/signal.go @@ -5,8 +5,8 @@ import ( "strconv" "strings" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) var ( diff --git a/internal/signals/signal_test.go b/internal/signals/signal_test.go index 8dddfb5705..6ac8ba2c97 100644 --- a/internal/signals/signal_test.go +++ b/internal/signals/signal_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" ) func Test_ValidateSigstr_LCOW_Empty_No_SignalsSupported(t *testing.T) { diff --git a/internal/uvm/combine_layers.go b/internal/uvm/combine_layers.go index 21aa03cfa1..fe06563488 100644 --- a/internal/uvm/combine_layers.go +++ b/internal/uvm/combine_layers.go @@ -4,8 +4,8 @@ import ( "context" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) // CombineLayersWCOW combines `layerPaths` with `containerRootPath` into the diff --git a/internal/uvm/hvsocket.go b/internal/uvm/hvsocket.go index 22b76d8988..03c1855796 100644 --- a/internal/uvm/hvsocket.go +++ b/internal/uvm/hvsocket.go @@ -6,7 +6,7 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" ) // UpdateHvSocketService calls HCS to update/create the hvsocket service for diff --git a/internal/uvm/modify.go b/internal/uvm/modify.go index 5646156453..009806e683 100644 --- a/internal/uvm/modify.go +++ b/internal/uvm/modify.go @@ -6,7 +6,7 @@ import ( hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/log" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" ) // Modify modifies the compute system by sending a request to HCS. diff --git a/internal/uvm/network.go b/internal/uvm/network.go index 2d2f2defcf..23c915cde9 100644 --- a/internal/uvm/network.go +++ b/internal/uvm/network.go @@ -17,9 +17,9 @@ import ( "github.com/Microsoft/hcsshim/internal/hns" "github.com/Microsoft/hcsshim/internal/log" "github.com/Microsoft/hcsshim/internal/ncproxyttrpc" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" "github.com/Microsoft/hcsshim/osversion" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) var ( diff --git a/internal/uvm/pipes.go b/internal/uvm/pipes.go index eb111662df..c4fcd34e82 100644 --- a/internal/uvm/pipes.go +++ b/internal/uvm/pipes.go @@ -7,7 +7,7 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" specs "github.com/opencontainers/runtime-spec/specs-go" ) diff --git a/internal/uvm/plan9.go b/internal/uvm/plan9.go index 13239ce500..3b86b392ae 100644 --- a/internal/uvm/plan9.go +++ b/internal/uvm/plan9.go @@ -8,9 +8,9 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" "github.com/Microsoft/hcsshim/osversion" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) // Plan9Share is a struct containing host paths for the UVM diff --git a/internal/uvm/scsi.go b/internal/uvm/scsi.go index e1b898e2dd..216da8dc43 100644 --- a/internal/uvm/scsi.go +++ b/internal/uvm/scsi.go @@ -19,9 +19,9 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/log" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" "github.com/Microsoft/hcsshim/internal/wclayer" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) // VMAccessType is used to determine the various types of access we can diff --git a/internal/uvm/security_policy.go b/internal/uvm/security_policy.go index 411b62ea92..f63b3ec64d 100644 --- a/internal/uvm/security_policy.go +++ b/internal/uvm/security_policy.go @@ -5,8 +5,8 @@ import ( "fmt" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" "github.com/Microsoft/hcsshim/pkg/securitypolicy" ) diff --git a/internal/uvm/share.go b/internal/uvm/share.go index d66ad6831d..db05448c68 100644 --- a/internal/uvm/share.go +++ b/internal/uvm/share.go @@ -7,8 +7,8 @@ import ( "path/filepath" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) // Share shares in file(s) from `reqHostPath` on the host machine to `reqUVMPath` inside the UVM. diff --git a/internal/uvm/start.go b/internal/uvm/start.go index 28152c1ab4..702815ed6a 100644 --- a/internal/uvm/start.go +++ b/internal/uvm/start.go @@ -21,8 +21,8 @@ import ( hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/log" "github.com/Microsoft/hcsshim/internal/logfields" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) // entropyBytes is the number of bytes of random data to send to a Linux UVM diff --git a/internal/uvm/virtual_device.go b/internal/uvm/virtual_device.go index ff4d7e01a8..0a729ecde5 100644 --- a/internal/uvm/virtual_device.go +++ b/internal/uvm/virtual_device.go @@ -8,8 +8,8 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) const ( diff --git a/internal/uvm/vpmem.go b/internal/uvm/vpmem.go index 23eb5b27f3..b41ed27aa6 100644 --- a/internal/uvm/vpmem.go +++ b/internal/uvm/vpmem.go @@ -13,8 +13,8 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/log" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) const ( diff --git a/internal/uvm/vpmem_mapped.go b/internal/uvm/vpmem_mapped.go index c690cada83..b98948ecfd 100644 --- a/internal/uvm/vpmem_mapped.go +++ b/internal/uvm/vpmem_mapped.go @@ -12,8 +12,8 @@ import ( hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/log" "github.com/Microsoft/hcsshim/internal/memory" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) const ( diff --git a/internal/uvm/vsmb.go b/internal/uvm/vsmb.go index d641e454df..b1e5f24434 100644 --- a/internal/uvm/vsmb.go +++ b/internal/uvm/vsmb.go @@ -16,9 +16,9 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/log" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" "github.com/Microsoft/hcsshim/internal/winapi" "github.com/Microsoft/hcsshim/osversion" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" ) const ( diff --git a/internal/vm/hcs/network.go b/internal/vm/hcs/network.go index bf4922af6c..71a30c1dc5 100644 --- a/internal/vm/hcs/network.go +++ b/internal/vm/hcs/network.go @@ -6,7 +6,7 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" ) func (uvm *utilityVM) AddNIC(ctx context.Context, nicID, endpointID, macAddr string) error { diff --git a/internal/vm/hcs/pci.go b/internal/vm/hcs/pci.go index 03db028a29..9936f3b45a 100644 --- a/internal/vm/hcs/pci.go +++ b/internal/vm/hcs/pci.go @@ -6,7 +6,7 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" ) func (uvm *utilityVM) AddDevice(ctx context.Context, instanceID, vmbusGUID string) error { diff --git a/internal/vm/hcs/plan9.go b/internal/vm/hcs/plan9.go index 88fb9afa60..3de9ed90ee 100644 --- a/internal/vm/hcs/plan9.go +++ b/internal/vm/hcs/plan9.go @@ -5,7 +5,7 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" ) func (uvm *utilityVM) AddPlan9(ctx context.Context, path, name string, port int32, flags int32, allowed []string) error { diff --git a/internal/vm/hcs/scsi.go b/internal/vm/hcs/scsi.go index 70b24508ea..ca238df974 100644 --- a/internal/vm/hcs/scsi.go +++ b/internal/vm/hcs/scsi.go @@ -9,8 +9,8 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" "github.com/Microsoft/hcsshim/internal/vm" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" ) func (uvmb *utilityVMBuilder) AddSCSIController(id uint32) error { diff --git a/internal/vm/hcs/vpmem.go b/internal/vm/hcs/vpmem.go index 04dca05c76..fb3a2dbc1a 100644 --- a/internal/vm/hcs/vpmem.go +++ b/internal/vm/hcs/vpmem.go @@ -9,8 +9,8 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" "github.com/Microsoft/hcsshim/internal/vm" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" ) func (uvmb *utilityVMBuilder) AddVPMemController(maximumDevices uint32, maximumSizeBytes uint64) error { diff --git a/internal/vm/hcs/vsmb.go b/internal/vm/hcs/vsmb.go index 9b140a4685..c48596fc2a 100644 --- a/internal/vm/hcs/vsmb.go +++ b/internal/vm/hcs/vsmb.go @@ -5,8 +5,8 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" "github.com/Microsoft/hcsshim/internal/vm" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" ) func (uvmb *utilityVMBuilder) AddVSMB(ctx context.Context, path string, name string, allowed []string, options *vm.VSMBOptions) error { diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/modify_setting_request.go b/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/modify_setting_request.go index 3f0309c0b2..6364da8e23 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/modify_setting_request.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/modify_setting_request.go @@ -9,7 +9,7 @@ package hcsschema -import "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" +import "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" type ModifySettingRequest struct { ResourcePath string `json:"ResourcePath,omitempty"` diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/hcsoci/clone.go b/test/vendor/github.com/Microsoft/hcsshim/internal/hcsoci/clone.go index ef5b2babe2..5a8a5fa5d0 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/hcsoci/clone.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/hcsoci/clone.go @@ -10,7 +10,7 @@ import ( "github.com/Microsoft/hcsshim/internal/cow" "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" ) // Usually mounts specified in the container config are added in the container doc diff --git a/test/vendor/github.com/Microsoft/hcsshim/pkg/protocol/guestrequest/types.go b/test/vendor/github.com/Microsoft/hcsshim/internal/protocol/guestrequest/types.go similarity index 100% rename from test/vendor/github.com/Microsoft/hcsshim/pkg/protocol/guestrequest/types.go rename to test/vendor/github.com/Microsoft/hcsshim/internal/protocol/guestrequest/types.go diff --git a/test/vendor/github.com/Microsoft/hcsshim/pkg/protocol/guestresource/resources.go b/test/vendor/github.com/Microsoft/hcsshim/internal/protocol/guestresource/resources.go similarity index 99% rename from test/vendor/github.com/Microsoft/hcsshim/pkg/protocol/guestresource/resources.go rename to test/vendor/github.com/Microsoft/hcsshim/internal/protocol/guestresource/resources.go index 636f4c97c9..55ae09730c 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/pkg/protocol/guestresource/resources.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/protocol/guestresource/resources.go @@ -1,7 +1,7 @@ package guestresource import ( - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" "github.com/opencontainers/runtime-spec/specs-go" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/combine_layers.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/combine_layers.go index 21aa03cfa1..fe06563488 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/combine_layers.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/combine_layers.go @@ -4,8 +4,8 @@ import ( "context" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) // CombineLayersWCOW combines `layerPaths` with `containerRootPath` into the diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/hvsocket.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/hvsocket.go index 22b76d8988..03c1855796 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/hvsocket.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/hvsocket.go @@ -6,7 +6,7 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" ) // UpdateHvSocketService calls HCS to update/create the hvsocket service for diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/modify.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/modify.go index 5646156453..009806e683 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/modify.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/modify.go @@ -6,7 +6,7 @@ import ( hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/log" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" ) // Modify modifies the compute system by sending a request to HCS. diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/network.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/network.go index 2d2f2defcf..23c915cde9 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/network.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/network.go @@ -17,9 +17,9 @@ import ( "github.com/Microsoft/hcsshim/internal/hns" "github.com/Microsoft/hcsshim/internal/log" "github.com/Microsoft/hcsshim/internal/ncproxyttrpc" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" "github.com/Microsoft/hcsshim/osversion" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) var ( diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/pipes.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/pipes.go index eb111662df..c4fcd34e82 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/pipes.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/pipes.go @@ -7,7 +7,7 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" specs "github.com/opencontainers/runtime-spec/specs-go" ) diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/plan9.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/plan9.go index 13239ce500..3b86b392ae 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/plan9.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/plan9.go @@ -8,9 +8,9 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" "github.com/Microsoft/hcsshim/osversion" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) // Plan9Share is a struct containing host paths for the UVM diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/scsi.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/scsi.go index e1b898e2dd..216da8dc43 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/scsi.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/scsi.go @@ -19,9 +19,9 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/log" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" "github.com/Microsoft/hcsshim/internal/wclayer" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) // VMAccessType is used to determine the various types of access we can diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/security_policy.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/security_policy.go index 411b62ea92..f63b3ec64d 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/security_policy.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/security_policy.go @@ -5,8 +5,8 @@ import ( "fmt" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" "github.com/Microsoft/hcsshim/pkg/securitypolicy" ) diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/share.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/share.go index d66ad6831d..db05448c68 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/share.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/share.go @@ -7,8 +7,8 @@ import ( "path/filepath" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) // Share shares in file(s) from `reqHostPath` on the host machine to `reqUVMPath` inside the UVM. diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/start.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/start.go index 28152c1ab4..702815ed6a 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/start.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/start.go @@ -21,8 +21,8 @@ import ( hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/log" "github.com/Microsoft/hcsshim/internal/logfields" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) // entropyBytes is the number of bytes of random data to send to a Linux UVM diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/virtual_device.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/virtual_device.go index ff4d7e01a8..0a729ecde5 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/virtual_device.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/virtual_device.go @@ -8,8 +8,8 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) const ( diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vpmem.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vpmem.go index 23eb5b27f3..b41ed27aa6 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vpmem.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vpmem.go @@ -13,8 +13,8 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/log" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) const ( diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vpmem_mapped.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vpmem_mapped.go index c690cada83..b98948ecfd 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vpmem_mapped.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vpmem_mapped.go @@ -12,8 +12,8 @@ import ( hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/log" "github.com/Microsoft/hcsshim/internal/memory" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" ) const ( diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vsmb.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vsmb.go index d641e454df..b1e5f24434 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vsmb.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vsmb.go @@ -16,9 +16,9 @@ import ( "github.com/Microsoft/hcsshim/internal/hcs/resourcepaths" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/log" + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" "github.com/Microsoft/hcsshim/internal/winapi" "github.com/Microsoft/hcsshim/osversion" - "github.com/Microsoft/hcsshim/pkg/protocol/guestrequest" ) const ( diff --git a/test/vendor/modules.txt b/test/vendor/modules.txt index 569213ac45..f3b797862a 100644 --- a/test/vendor/modules.txt +++ b/test/vendor/modules.txt @@ -49,6 +49,8 @@ github.com/Microsoft/hcsshim/internal/oc github.com/Microsoft/hcsshim/internal/oci github.com/Microsoft/hcsshim/internal/ospath github.com/Microsoft/hcsshim/internal/processorinfo +github.com/Microsoft/hcsshim/internal/protocol/guestrequest +github.com/Microsoft/hcsshim/internal/protocol/guestresource github.com/Microsoft/hcsshim/internal/regstate github.com/Microsoft/hcsshim/internal/resources github.com/Microsoft/hcsshim/internal/runhcs @@ -67,8 +69,6 @@ github.com/Microsoft/hcsshim/pkg/annotations github.com/Microsoft/hcsshim/pkg/go-runhcs github.com/Microsoft/hcsshim/pkg/ociwclayer github.com/Microsoft/hcsshim/pkg/octtrpc -github.com/Microsoft/hcsshim/pkg/protocol/guestrequest -github.com/Microsoft/hcsshim/pkg/protocol/guestresource github.com/Microsoft/hcsshim/pkg/securitypolicy # github.com/bits-and-blooms/bitset v1.2.0 github.com/bits-and-blooms/bitset From eb71f4a30b7b56bc3bce5ed9d2d0000e83302f6c Mon Sep 17 00:00:00 2001 From: Maksim An Date: Thu, 27 Jan 2022 11:25:05 -0800 Subject: [PATCH 3/5] pr feedback: update comments to reference new guestresource package Signed-off-by: Maksim An --- internal/hcs/process.go | 4 ++-- .../github.com/Microsoft/hcsshim/internal/hcs/process.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/hcs/process.go b/internal/hcs/process.go index 0eb2b6d063..605856f2a3 100644 --- a/internal/hcs/process.go +++ b/internal/hcs/process.go @@ -114,9 +114,9 @@ func (process *Process) processSignalResult(ctx context.Context, err error) (boo // Signal signals the process with `options`. // -// For LCOW `protocol.SignalProcessOptionsLCOW`. +// For LCOW `guestresource.SignalProcessOptionsLCOW`. // -// For WCOW `protocol.SignalProcessOptionsWCOW`. +// For WCOW `guestresource.SignalProcessOptionsWCOW`. func (process *Process) Signal(ctx context.Context, options interface{}) (bool, error) { process.handleLock.RLock() defer process.handleLock.RUnlock() diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go b/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go index 0eb2b6d063..605856f2a3 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go @@ -114,9 +114,9 @@ func (process *Process) processSignalResult(ctx context.Context, err error) (boo // Signal signals the process with `options`. // -// For LCOW `protocol.SignalProcessOptionsLCOW`. +// For LCOW `guestresource.SignalProcessOptionsLCOW`. // -// For WCOW `protocol.SignalProcessOptionsWCOW`. +// For WCOW `guestresource.SignalProcessOptionsWCOW`. func (process *Process) Signal(ctx context.Context, options interface{}) (bool, error) { process.handleLock.RLock() defer process.handleLock.RUnlock() From 9762d6c692955ebdb328b63a3e196fe380a0b868 Mon Sep 17 00:00:00 2001 From: Maksim An Date: Thu, 27 Jan 2022 14:04:39 -0800 Subject: [PATCH 4/5] Fix rebase artifacts and tests Signed-off-by: Maksim An --- internal/uvm/computeagent.go | 2 +- internal/uvm/computeagent_test.go | 6 +++--- internal/uvm/network.go | 16 ++++++++-------- .../hcsshim/internal/uvm/computeagent.go | 2 +- .../Microsoft/hcsshim/internal/uvm/network.go | 16 ++++++++-------- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/internal/uvm/computeagent.go b/internal/uvm/computeagent.go index 1668e30637..b87edf2796 100644 --- a/internal/uvm/computeagent.go +++ b/internal/uvm/computeagent.go @@ -18,8 +18,8 @@ import ( "github.com/Microsoft/hcsshim/internal/hns" "github.com/Microsoft/hcsshim/internal/log" ncproxynetworking "github.com/Microsoft/hcsshim/internal/ncproxy/networking" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" "github.com/Microsoft/hcsshim/pkg/octtrpc" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) func init() { diff --git a/internal/uvm/computeagent_test.go b/internal/uvm/computeagent_test.go index aa0cd882cd..8a404cb3ad 100644 --- a/internal/uvm/computeagent_test.go +++ b/internal/uvm/computeagent_test.go @@ -6,9 +6,9 @@ import ( "github.com/Microsoft/hcsshim/hcn" "github.com/Microsoft/hcsshim/internal/computeagent" - "github.com/Microsoft/hcsshim/internal/guestrequest" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" "github.com/Microsoft/hcsshim/internal/hns" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" "github.com/containerd/typeurl" "github.com/gogo/protobuf/types" ) @@ -37,11 +37,11 @@ func (t *testUtilityVM) RemoveDevice(ctx context.Context, deviceID string, index return nil } -func (t *testUtilityVM) AddNICInGuest(ctx context.Context, cfg *guestrequest.LCOWNetworkAdapter) error { +func (t *testUtilityVM) AddNICInGuest(ctx context.Context, cfg *guestresource.LCOWNetworkAdapter) error { return nil } -func (t *testUtilityVM) RemoveNICInGuest(ctx context.Context, cfg *guestrequest.LCOWNetworkAdapter) error { +func (t *testUtilityVM) RemoveNICInGuest(ctx context.Context, cfg *guestresource.LCOWNetworkAdapter) error { return nil } diff --git a/internal/uvm/network.go b/internal/uvm/network.go index 23c915cde9..eb800bc4db 100644 --- a/internal/uvm/network.go +++ b/internal/uvm/network.go @@ -679,14 +679,14 @@ func (uvm *UtilityVM) UpdateNIC(ctx context.Context, id string, settings *hcssch // AddNICInGuest makes a request to setup a network adapter's interface inside the lcow guest. // This is primarily used for adding NICs in the guest that have been VPCI assigned. -func (uvm *UtilityVM) AddNICInGuest(ctx context.Context, cfg *guestrequest.LCOWNetworkAdapter) error { +func (uvm *UtilityVM) AddNICInGuest(ctx context.Context, cfg *guestresource.LCOWNetworkAdapter) error { if !uvm.isNetworkNamespaceSupported() { return fmt.Errorf("guest does not support network namespaces and cannot add VF NIC %+v", cfg) } request := hcsschema.ModifySettingRequest{} - request.GuestRequest = guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeNetwork, - RequestType: requesttype.Add, + request.GuestRequest = guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeNetwork, + RequestType: guestrequest.RequestTypePreAdd, Settings: cfg, } @@ -695,14 +695,14 @@ func (uvm *UtilityVM) AddNICInGuest(ctx context.Context, cfg *guestrequest.LCOWN // RemoveNICInGuest makes a request to remove a network interface inside the lcow guest. // This is primarily used for removing NICs in the guest that were VPCI assigned. -func (uvm *UtilityVM) RemoveNICInGuest(ctx context.Context, cfg *guestrequest.LCOWNetworkAdapter) error { +func (uvm *UtilityVM) RemoveNICInGuest(ctx context.Context, cfg *guestresource.LCOWNetworkAdapter) error { if !uvm.isNetworkNamespaceSupported() { return fmt.Errorf("guest does not support network namespaces and cannot remove VF NIC %+v", cfg) } request := hcsschema.ModifySettingRequest{} - request.GuestRequest = guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeNetwork, - RequestType: requesttype.Remove, + request.GuestRequest = guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeNetwork, + RequestType: guestrequest.RequestTypeRemove, Settings: cfg, } diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/computeagent.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/computeagent.go index 1668e30637..b87edf2796 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/computeagent.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/computeagent.go @@ -18,8 +18,8 @@ import ( "github.com/Microsoft/hcsshim/internal/hns" "github.com/Microsoft/hcsshim/internal/log" ncproxynetworking "github.com/Microsoft/hcsshim/internal/ncproxy/networking" + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" "github.com/Microsoft/hcsshim/pkg/octtrpc" - "github.com/Microsoft/hcsshim/pkg/protocol/guestresource" ) func init() { diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/network.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/network.go index 23c915cde9..eb800bc4db 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/network.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/network.go @@ -679,14 +679,14 @@ func (uvm *UtilityVM) UpdateNIC(ctx context.Context, id string, settings *hcssch // AddNICInGuest makes a request to setup a network adapter's interface inside the lcow guest. // This is primarily used for adding NICs in the guest that have been VPCI assigned. -func (uvm *UtilityVM) AddNICInGuest(ctx context.Context, cfg *guestrequest.LCOWNetworkAdapter) error { +func (uvm *UtilityVM) AddNICInGuest(ctx context.Context, cfg *guestresource.LCOWNetworkAdapter) error { if !uvm.isNetworkNamespaceSupported() { return fmt.Errorf("guest does not support network namespaces and cannot add VF NIC %+v", cfg) } request := hcsschema.ModifySettingRequest{} - request.GuestRequest = guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeNetwork, - RequestType: requesttype.Add, + request.GuestRequest = guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeNetwork, + RequestType: guestrequest.RequestTypePreAdd, Settings: cfg, } @@ -695,14 +695,14 @@ func (uvm *UtilityVM) AddNICInGuest(ctx context.Context, cfg *guestrequest.LCOWN // RemoveNICInGuest makes a request to remove a network interface inside the lcow guest. // This is primarily used for removing NICs in the guest that were VPCI assigned. -func (uvm *UtilityVM) RemoveNICInGuest(ctx context.Context, cfg *guestrequest.LCOWNetworkAdapter) error { +func (uvm *UtilityVM) RemoveNICInGuest(ctx context.Context, cfg *guestresource.LCOWNetworkAdapter) error { if !uvm.isNetworkNamespaceSupported() { return fmt.Errorf("guest does not support network namespaces and cannot remove VF NIC %+v", cfg) } request := hcsschema.ModifySettingRequest{} - request.GuestRequest = guestrequest.GuestRequest{ - ResourceType: guestrequest.ResourceTypeNetwork, - RequestType: requesttype.Remove, + request.GuestRequest = guestrequest.ModificationRequest{ + ResourceType: guestresource.ResourceTypeNetwork, + RequestType: guestrequest.RequestTypeRemove, Settings: cfg, } From 438fe161e1576dfd3ab0eb6a3b8fe2e9162b5d0d Mon Sep 17 00:00:00 2001 From: Maksim An Date: Wed, 2 Feb 2022 17:01:12 -0800 Subject: [PATCH 5/5] pr feedback: don't replace invalid protocol references Signed-off-by: Maksim An --- internal/hcs/schema2/plan9_share.go | 2 +- internal/hns/hnspolicylist.go | 2 +- internal/uvm/capabilities.go | 2 +- .../Microsoft/hcsshim/internal/hcs/schema2/plan9_share.go | 2 +- .../github.com/Microsoft/hcsshim/internal/hns/hnspolicylist.go | 2 +- .../github.com/Microsoft/hcsshim/internal/uvm/capabilities.go | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/hcs/schema2/plan9_share.go b/internal/hcs/schema2/plan9_share.go index a7431f0e1b..41f8fdea02 100644 --- a/internal/hcs/schema2/plan9_share.go +++ b/internal/hcs/schema2/plan9_share.go @@ -12,7 +12,7 @@ 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 guestprotocol. + // 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"` diff --git a/internal/hns/hnspolicylist.go b/internal/hns/hnspolicylist.go index 9e1f1cbfe1..31322a6816 100644 --- a/internal/hns/hnspolicylist.go +++ b/internal/hns/hnspolicylist.go @@ -143,7 +143,7 @@ func (policylist *PolicyList) RemoveEndpoint(endpoint *HNSEndpoint) (*PolicyList 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, guestprotocol=%v, internalPort=%v, externalPort=%v", endpoints, isILB, sourceVIP, vip, protocol, internalPort, externalPort) + 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{} diff --git a/internal/uvm/capabilities.go b/internal/uvm/capabilities.go index 3bfa8fb182..d76bfdbef4 100644 --- a/internal/uvm/capabilities.go +++ b/internal/uvm/capabilities.go @@ -17,7 +17,7 @@ func (uvm *UtilityVM) DeleteContainerStateSupported() bool { return uvm.guestCaps.DeleteContainerStateSupported } -// Capabilities returns the guestprotocol version and the guest defined capabilities. +// Capabilities returns the protocol version and the guest defined capabilities. // This should only be used for testing. func (uvm *UtilityVM) Capabilities() (uint32, schema1.GuestDefinedCapabilities) { return uvm.protocol, uvm.guestCaps diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/plan9_share.go b/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/plan9_share.go index a7431f0e1b..41f8fdea02 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/plan9_share.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/plan9_share.go @@ -12,7 +12,7 @@ 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 guestprotocol. + // 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"` diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/hns/hnspolicylist.go b/test/vendor/github.com/Microsoft/hcsshim/internal/hns/hnspolicylist.go index 9e1f1cbfe1..31322a6816 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/hns/hnspolicylist.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/hns/hnspolicylist.go @@ -143,7 +143,7 @@ func (policylist *PolicyList) RemoveEndpoint(endpoint *HNSEndpoint) (*PolicyList 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, guestprotocol=%v, internalPort=%v, externalPort=%v", endpoints, isILB, sourceVIP, vip, protocol, internalPort, externalPort) + 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{} diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/capabilities.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/capabilities.go index 3bfa8fb182..d76bfdbef4 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/capabilities.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/capabilities.go @@ -17,7 +17,7 @@ func (uvm *UtilityVM) DeleteContainerStateSupported() bool { return uvm.guestCaps.DeleteContainerStateSupported } -// Capabilities returns the guestprotocol version and the guest defined capabilities. +// Capabilities returns the protocol version and the guest defined capabilities. // This should only be used for testing. func (uvm *UtilityVM) Capabilities() (uint32, schema1.GuestDefinedCapabilities) { return uvm.protocol, uvm.guestCaps