Skip to content
Open
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
3 changes: 2 additions & 1 deletion internal/devices/assigned_devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/Microsoft/hcsshim/internal/cmd"
"github.com/Microsoft/hcsshim/internal/log"
"github.com/Microsoft/hcsshim/internal/uvm"
"github.com/Microsoft/hcsshim/internal/vm/vmutils"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -40,7 +41,7 @@ func AddDevice(ctx context.Context, vm *uvm.UtilityVM, idType, deviceID string,
}
}()

if uvm.IsValidDeviceType(idType) {
if vmutils.IsValidDeviceType(idType) {
vpci, err = vm.AssignDevice(ctx, deviceID, index, "")
if err != nil {
return vpci, nil, errors.Wrapf(err, "failed to assign device %s of type %s to pod %s", deviceID, idType, vm.ID())
Expand Down
10 changes: 10 additions & 0 deletions internal/hcs/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type System struct {
exitError error
os, typ, owner string
startTime time.Time
stopTime time.Time
}

var _ cow.Container = &System{}
Expand Down Expand Up @@ -292,6 +293,7 @@ func (computeSystem *System) waitBackground() {
}
computeSystem.closedWaitOnce.Do(func() {
computeSystem.waitError = err
computeSystem.stopTime = time.Now()
close(computeSystem.waitBlock)
})
oc.SetSpanStatus(span, err)
Expand Down Expand Up @@ -871,3 +873,11 @@ func (computeSystem *System) Modify(ctx context.Context, config interface{}) err

return nil
}

func (computeSystem *System) StoppedTime() time.Time {
return computeSystem.stopTime
}

func (computeSystem *System) StartedTime() time.Time {
return computeSystem.startTime
}
3 changes: 2 additions & 1 deletion internal/hcsoci/devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/Microsoft/hcsshim/internal/oci"
"github.com/Microsoft/hcsshim/internal/resources"
"github.com/Microsoft/hcsshim/internal/uvm"
"github.com/Microsoft/hcsshim/internal/vm/vmutils"
"github.com/Microsoft/hcsshim/osversion"
"github.com/Microsoft/hcsshim/pkg/annotations"
)
Expand Down Expand Up @@ -174,7 +175,7 @@ func handleAssignedDevicesLCOW(

// assign device into UVM and create corresponding spec windows devices
for _, d := range specDevs {
if !uvm.IsValidDeviceType(d.IDType) {
if !vmutils.IsValidDeviceType(d.IDType) {
return resultDevs, closers, errors.Errorf("specified device %s has unsupported type %s", d.ID, d.IDType)
}

Expand Down
13 changes: 7 additions & 6 deletions internal/oci/uvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strconv"

runhcsopts "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options"
"github.com/Microsoft/hcsshim/internal/vm/vmutils"
"github.com/Microsoft/hcsshim/pkg/annotations"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -156,7 +157,7 @@ func handleAnnotationBootFilesPath(ctx context.Context, a map[string]string, lop
func handleAnnotationKernelDirectBoot(ctx context.Context, a map[string]string, lopts *uvm.OptionsLCOW) {
lopts.KernelDirect = ParseAnnotationsBool(ctx, a, annotations.KernelDirectBoot, lopts.KernelDirect)
if !lopts.KernelDirect {
lopts.KernelFile = uvm.KernelFile
lopts.KernelFile = vmutils.KernelFile
}
}

Expand All @@ -166,9 +167,9 @@ func handleAnnotationPreferredRootFSType(ctx context.Context, a map[string]strin
lopts.PreferredRootFSType = parseAnnotationsPreferredRootFSType(ctx, a, annotations.PreferredRootFSType, lopts.PreferredRootFSType)
switch lopts.PreferredRootFSType {
case uvm.PreferredRootFSTypeInitRd:
lopts.RootFSFile = uvm.InitrdFile
lopts.RootFSFile = vmutils.InitrdFile
case uvm.PreferredRootFSTypeVHD:
lopts.RootFSFile = uvm.VhdFile
lopts.RootFSFile = vmutils.VhdFile
}
}

Expand Down Expand Up @@ -206,7 +207,7 @@ func handleLCOWSecurityPolicy(ctx context.Context, a map[string]string, lopts *u
// VPMem not supported by the enlightened kernel for SNP so set count to zero.
lopts.VPMemDeviceCount = 0
// set the default GuestState filename.
lopts.GuestStateFilePath = uvm.GuestStateFile
lopts.GuestStateFilePath = vmutils.DefaultGuestStateFile
lopts.KernelBootOptions = ""
lopts.AllowOvercommit = false
lopts.SecurityPolicyEnabled = true
Expand All @@ -219,7 +220,7 @@ func handleLCOWSecurityPolicy(ctx context.Context, a map[string]string, lopts *u
// The default behavior is to use kernel.vmgs and a rootfs-verity.vhd file with Merkle tree appended to ext4 filesystem.
lopts.PreferredRootFSType = uvm.PreferredRootFSTypeNA
lopts.RootFSFile = ""
lopts.DmVerityRootFsVhd = uvm.DefaultDmVerityRootfsVhd
lopts.DmVerityRootFsVhd = vmutils.DefaultDmVerityRootfsVhd
lopts.DmVerityMode = true
}

Expand Down Expand Up @@ -286,7 +287,7 @@ func parseDevices(ctx context.Context, specWindows *specs.Windows) []uvm.VPCIDev
extraDevices := []uvm.VPCIDeviceID{}
for _, d := range specWindows.Devices {
pciID, index := devices.GetDeviceInfoFromPath(d.ID)
if uvm.IsValidDeviceType(d.IDType) {
if vmutils.IsValidDeviceType(d.IDType) {
key := uvm.NewVPCIDeviceID(pciID, index)
extraDevices = append(extraDevices, key)
} else {
Expand Down
17 changes: 9 additions & 8 deletions internal/tools/uvmboot/lcow.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/Microsoft/hcsshim/internal/memory"
"github.com/Microsoft/hcsshim/internal/oci"
"github.com/Microsoft/hcsshim/internal/uvm"
"github.com/Microsoft/hcsshim/internal/vm/vmutils"
)

const (
Expand Down Expand Up @@ -196,10 +197,10 @@ func createLCOWOptions(ctx context.Context, c *cli.Context, id string) (*uvm.Opt
}
if c.IsSet(kernelFileArgName) {
switch strings.ToLower(c.String(kernelFileArgName)) {
case uvm.KernelFile:
options.KernelFile = uvm.KernelFile
case uvm.UncompressedKernelFile:
options.KernelFile = uvm.UncompressedKernelFile
case vmutils.KernelFile:
options.KernelFile = vmutils.KernelFile
case vmutils.UncompressedKernelFile:
options.KernelFile = vmutils.UncompressedKernelFile
default:
return nil, unrecognizedError(c.String(kernelFileArgName), kernelFileArgName)
}
Expand All @@ -212,10 +213,10 @@ func createLCOWOptions(ctx context.Context, c *cli.Context, id string) (*uvm.Opt
if c.IsSet(rootFSTypeArgName) {
switch strings.ToLower(c.String(rootFSTypeArgName)) {
case "initrd":
options.RootFSFile = uvm.InitrdFile
options.RootFSFile = vmutils.InitrdFile
options.PreferredRootFSType = uvm.PreferredRootFSTypeInitRd
case "vhd":
options.RootFSFile = uvm.VhdFile
options.RootFSFile = vmutils.VhdFile
options.PreferredRootFSType = uvm.PreferredRootFSTypeVHD
case "none":
options.RootFSFile = ""
Expand Down Expand Up @@ -247,7 +248,7 @@ func createLCOWOptions(ctx context.Context, c *cli.Context, id string) (*uvm.Opt
if c.IsSet(outputHandlingArgName) {
switch strings.ToLower(c.String(outputHandlingArgName)) {
case "stdout":
options.OutputHandlerCreator = func(*uvm.Options) uvm.OutputHandler {
options.OutputHandlerCreator = func(string) vmutils.OutputHandler {
return func(r io.Reader) {
_, _ = io.Copy(os.Stdout, r)
}
Expand All @@ -274,7 +275,7 @@ func createLCOWOptions(ctx context.Context, c *cli.Context, id string) (*uvm.Opt
options.SecurityPolicyEnforcer = c.String(securityPolicyEnforcerArgName)
}
if c.IsSet(securityHardwareFlag) {
options.GuestStateFilePath = uvm.GuestStateFile
options.GuestStateFilePath = vmutils.DefaultGuestStateFile
options.SecurityPolicyEnabled = true
options.AllowOvercommit = false
}
Expand Down
15 changes: 0 additions & 15 deletions internal/uvm/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,9 @@ package uvm
import (
"errors"

"github.com/Microsoft/hcsshim/internal/memory"
"github.com/Microsoft/hcsshim/internal/protocol/guestrequest"
)

const (
// MaxVPMEMCount is the maximum number of VPMem devices that may be added to an LCOW
// utility VM
MaxVPMEMCount = 128

// DefaultVPMEMCount is the default number of VPMem devices that may be added to an LCOW
// utility VM if the create request doesn't specify how many.
DefaultVPMEMCount = 64

// DefaultVPMemSizeBytes is the default size of a VPMem device if the create request
// doesn't specify.
DefaultVPMemSizeBytes = 4 * memory.GiB // 4GB
)

var (
errNotSupported = errors.New("not supported")
errBadUVMOpts = errors.New("UVM options incorrect")
Expand Down
3 changes: 0 additions & 3 deletions internal/uvm/cpugroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ import (
"github.com/Microsoft/hcsshim/internal/cpugroup"
"github.com/Microsoft/hcsshim/internal/hcs/resourcepaths"
hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2"
"github.com/Microsoft/hcsshim/osversion"
)

var errCPUGroupCreateNotSupported = fmt.Errorf("cpu group assignment on create requires a build of %d or higher", osversion.V21H1)

// ReleaseCPUGroup unsets the cpugroup from the VM
func (uvm *UtilityVM) ReleaseCPUGroup(ctx context.Context) error {
if err := uvm.unsetCPUGroup(ctx); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/uvm/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ func verifyOptions(_ context.Context, options interface{}) error {
if opts.SCSIControllerCount > MaxSCSIControllers {
return fmt.Errorf("SCSI controller count can't be more than %d", MaxSCSIControllers)
}
if opts.VPMemDeviceCount > MaxVPMEMCount {
return fmt.Errorf("VPMem device count cannot be greater than %d", MaxVPMEMCount)
if opts.VPMemDeviceCount > vmutils.MaxVPMEMCount {
return fmt.Errorf("VPMem device count cannot be greater than %d", vmutils.MaxVPMEMCount)
}
if opts.VPMemDeviceCount > 0 {
if opts.VPMemSizeBytes%4096 != 0 {
Expand Down
Loading