diff --git a/internal/hcsoci/hcsdoc_wcow.go b/internal/hcsoci/hcsdoc_wcow.go index 439740fe9b..3dad366df9 100644 --- a/internal/hcsoci/hcsdoc_wcow.go +++ b/internal/hcsoci/hcsdoc_wcow.go @@ -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}) @@ -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 } diff --git a/internal/hcsoci/resources_wcow.go b/internal/hcsoci/resources_wcow.go index f2984a423b..0b09edc579 100644 --- a/internal/hcsoci/resources_wcow.go +++ b/internal/hcsoci/resources_wcow.go @@ -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) } @@ -139,7 +139,6 @@ 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") @@ -147,7 +146,6 @@ func setupMounts(ctx context.Context, coi *createOptionsInternal, r *resources.R 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) {