diff --git a/internal/hcsoci/hcsdoc_wcow.go b/internal/hcsoci/hcsdoc_wcow.go index 7423668dda..221730853c 100644 --- a/internal/hcsoci/hcsdoc_wcow.go +++ b/internal/hcsoci/hcsdoc_wcow.go @@ -37,7 +37,9 @@ 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}) @@ -61,17 +63,18 @@ 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 { - return nil, err + 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 + } } mdv2.HostPath = uvmPath } diff --git a/internal/hcsoci/resources_wcow.go b/internal/hcsoci/resources_wcow.go index 46599be037..79443290a5 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 _, mount := range coi.Spec.Mounts { + for i, 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,6 +139,7 @@ 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") @@ -146,6 +147,7 @@ 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) {