Skip to content

Commit

Permalink
Merge pull request #1021 from ambarve/scsi_vsmb_fix
Browse files Browse the repository at this point in the history
Fix bug with VSMB & SCSI mounts on the same host path
  • Loading branch information
ambarve authored May 18, 2021
2 parents 2643334 + 4cd8e71 commit 0feed3f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
21 changes: 9 additions & 12 deletions internal/hcsoci/hcsdoc_wcow.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ func createMountsConfig(ctx context.Context, coi *createOptionsInternal) (*mount
// TODO: Mapped pipes to add in v2 schema.
var config mountsConfig
for _, mount := range coi.Spec.Mounts {
if mount.Type != "" {
return nil, fmt.Errorf("invalid container spec - Mount.Type '%s' must not be set", mount.Type)
}

if uvm.IsPipe(mount.Source) {
src, dst := uvm.GetContainerPipeMapping(coi.HostingSystem, mount)
config.mpsv1 = append(config.mpsv1, schema1.MappedPipe{HostPath: src, ContainerPipeName: dst})
Expand All @@ -63,18 +61,17 @@ func createMountsConfig(ctx context.Context, coi *createOptionsInternal) (*mount
return nil, fmt.Errorf("failed to eval symlinks for mount source %q: %s", mount.Source, err)
}
mdv2.HostPath = src
} else if mount.Type == "virtual-disk" || mount.Type == "physical-disk" {
uvmPath, err := coi.HostingSystem.GetScsiUvmPath(ctx, mount.Source)
if err != nil {
return nil, err
}
mdv2.HostPath = uvmPath
} else {
// vsmb mount
uvmPath, err := coi.HostingSystem.GetVSMBUvmPath(ctx, mount.Source, readOnly)
if err != nil {
if err == uvm.ErrNotAttached {
// It could also be a scsi mount.
uvmPath, err = coi.HostingSystem.GetScsiUvmPath(ctx, mount.Source)
if err != nil {
return nil, err
}
} else {
return nil, err
}
return nil, err
}
mdv2.HostPath = uvmPath
}
Expand Down
4 changes: 1 addition & 3 deletions internal/hcsoci/resources_wcow.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func setupMounts(ctx context.Context, coi *createOptionsInternal, r *resources.R
// Validate each of the mounts. If this is a V2 Xenon, we have to add them as
// VSMB shares to the utility VM. For V1 Xenon and Argons, there's nothing for
// us to do as it's done by HCS.
for i, mount := range coi.Spec.Mounts {
for _, mount := range coi.Spec.Mounts {
if mount.Destination == "" || mount.Source == "" {
return fmt.Errorf("invalid OCI spec - a mount must have both source and a destination: %+v", mount)
}
Expand Down Expand Up @@ -139,15 +139,13 @@ func setupMounts(ctx context.Context, coi *createOptionsInternal, r *resources.R
if err != nil {
return errors.Wrapf(err, "adding SCSI physical disk mount %+v", mount)
}
coi.Spec.Mounts[i].Type = ""
r.Add(scsiMount)
} else if mount.Type == "virtual-disk" {
l.Debug("hcsshim::allocateWindowsResources Hot-adding SCSI virtual disk for OCI mount")
scsiMount, err := coi.HostingSystem.AddSCSI(ctx, mount.Source, uvmPath, readOnly, mount.Options, uvm.VMAccessTypeIndividual)
if err != nil {
return errors.Wrapf(err, "adding SCSI virtual disk mount %+v", mount)
}
coi.Spec.Mounts[i].Type = ""
r.Add(scsiMount)
} else {
if uvm.IsPipe(mount.Source) {
Expand Down

0 comments on commit 0feed3f

Please sign in to comment.