Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/oci/uvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ const (
annotationStorageQoSIopsMaximum = "io.microsoft.virtualmachine.storageqos.iopsmaximum"
annotationFullyPhysicallyBacked = "io.microsoft.virtualmachine.fullyphysicallybacked"
annotationDisableCompartmentNamespace = "io.microsoft.virtualmachine.disablecompartmentnamespace"
annotationVSMBNoDirectMap = "io.microsoft.virtualmachine.wcow.virtualSMB.nodirectmap"
// A boolean annotation to control whether to use an external bridge or the
// HCS-GCS bridge. Default value is true which means external bridge will be used
// by default.
Expand Down Expand Up @@ -490,6 +491,7 @@ func SpecToUVMCreateOpts(ctx context.Context, s *specs.Spec, id, owner string) (
wopts.DisableCompartmentNamespace = parseAnnotationsBool(ctx, s.Annotations, annotationDisableCompartmentNamespace, wopts.DisableCompartmentNamespace)
wopts.CPUGroupID = parseAnnotationsString(s.Annotations, annotationCPUGroupID, wopts.CPUGroupID)
wopts.NetworkConfigProxy = parseAnnotationsString(s.Annotations, annotationNetworkConfigProxy, wopts.NetworkConfigProxy)
wopts.NoDirectMap = parseAnnotationsBool(ctx, s.Annotations, annotationVSMBNoDirectMap, wopts.NoDirectMap)
handleAnnotationFullyPhysicallyBacked(ctx, s.Annotations, wopts)
if err := handleCloneAnnotations(ctx, s.Annotations, wopts); err != nil {
return nil, err
Expand Down
5 changes: 5 additions & 0 deletions internal/uvm/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,11 @@ func (uvm *UtilityVM) DevicesPhysicallyBacked() bool {
return uvm.devicesPhysicallyBacked
}

// VSMBNoDirectMap returns if VSMB devices should be mounted with `NoDirectMap` set to true
func (uvm *UtilityVM) VSMBNoDirectMap() bool {
return uvm.vsmbNoDirectMap
}

// Closes the external GCS connection if it is being used and also closes the
// listener for GCS connection.
func (uvm *UtilityVM) CloseGCSConnection() (err error) {
Expand Down
4 changes: 4 additions & 0 deletions internal/uvm/create_wcow.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ type OptionsWCOW struct {
// which holds all the information about the template from
// which this clone should be created.
TemplateConfig *UVMTemplateConfig

// NoDirectMap specifies that no direct mapping should be used for any VSMBs added to the UVM
NoDirectMap bool
}

// NewDefaultOptionsWCOW creates the default options for a bootable version of
Expand Down Expand Up @@ -225,6 +228,7 @@ func CreateWCOW(ctx context.Context, opts *OptionsWCOW) (_ *UtilityVM, err error
vpciDevices: make(map[string]*VPCIDevice),
physicallyBacked: !opts.AllowOvercommit,
devicesPhysicallyBacked: opts.FullyPhysicallyBacked,
vsmbNoDirectMap: opts.NoDirectMap,
createOpts: *opts,
}

Expand Down
7 changes: 4 additions & 3 deletions internal/uvm/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ type UtilityVM struct {
// unrestricted mappings of directories. `vsmbFileShares` tracks shares that
// are restricted to some subset of files in the directory. This is used as
// part of a temporary fix to allow WCOW single-file mapping to function.
vsmbDirShares map[string]*VSMBShare
vsmbFileShares map[string]*VSMBShare
vsmbCounter uint64 // Counter to generate a unique share name for each VSMB share.
vsmbDirShares map[string]*VSMBShare
vsmbFileShares map[string]*VSMBShare
vsmbCounter uint64 // Counter to generate a unique share name for each VSMB share.
vsmbNoDirectMap bool // indicates if VSMB devices should be added with the `NoDirectMap` option

// VPMEM devices that are mapped into a Linux UVM. These are used for read-only layers, or for
// booting from VHD.
Expand Down
2 changes: 1 addition & 1 deletion internal/uvm/vsmb.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (vsmb *VSMBShare) Release(ctx context.Context) error {
// returns the default VSMB options for a readonly share.
func (uvm *UtilityVM) DefaultVSMBOptions(readOnly bool) *hcsschema.VirtualSmbShareOptions {
opts := &hcsschema.VirtualSmbShareOptions{
NoDirectmap: uvm.DevicesPhysicallyBacked(),
NoDirectmap: uvm.DevicesPhysicallyBacked() || uvm.VSMBNoDirectMap(),
}
if readOnly {
opts.ShareRead = true
Expand Down
12 changes: 12 additions & 0 deletions test/cri-containerd/runpodsandbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,18 @@ func Test_RunPodSandbox_FullyPhysicallyBacked_WCOW_Hypervisor(t *testing.T) {
runPodSandboxTest(t, request)
}

func Test_RunPodSandbox_VSMBNoDirectMap_WCOW_Hypervisor(t *testing.T) {
requireFeatures(t, featureWCOWHypervisor)

pullRequiredImages(t, []string{imageWindowsNanoserver})

request := getRunPodSandboxRequest(t, wcowHypervisorRuntimeHandler)
request.Config.Annotations = map[string]string{
"io.microsoft.virtualmachine.wcow.virtualSMB.nodirectmap": "true",
}
runPodSandboxTest(t, request)
}

func Test_RunPodSandbox_PhysicalMemory_LCOW(t *testing.T) {
requireFeatures(t, featureLCOW)

Expand Down