1 package vm 2 3 import ( 4 "context" 5 ) 6 7 type UVMBuilder interface { 8 // Create will create the Utility VM in a paused/powered off state with whatever is present in the implementation 9 // of the interfaces config at the time of the call. 10 Create(ctx context.Context) (UVM, error) 11 } 12 13 type MemoryBackingType uint8 14 15 const ( 16 MemoryBackingTypeVirtual MemoryBackingType = iota 17 MemoryBackingTypePhysical 18 ) 19 20 // MemoryConfig holds the memory options that should be configurable for a Utility VM. 21 type MemoryConfig struct { 22 BackingType MemoryBackingType 23 DeferredCommit bool 24 HotHint bool 25 ColdHint bool 26 ColdDiscardHint bool 27 } 28 29 // MemoryManager handles setting and managing memory configurations for the Utility VM. 30 type MemoryManager interface { 31 // SetMemoryLimit sets the amount of memory in megabytes that the Utility VM will be assigned. 32 SetMemoryLimit(memoryMB uint64) error 33 // SetMemoryConfig sets an array of different memory configuration options available. This includes things like the 34 // type of memory to back the VM (virtual/physical). 35 SetMemoryConfig(config *MemoryConfig) error 36 // SetMMIOConfig sets memory mapped IO configurations for the Utility VM. 37 SetMMIOConfig(lowGapMB uint64, highBaseMB uint64, highGapMB uint64) error 38 } 39 40 // ProcessorManager handles setting and managing processor configurations for the Utility VM. 41 type ProcessorManager interface { 42 // SetProcessorCount sets the number of virtual processors that will be assigned to the Utility VM. 43 SetProcessorCount(count uint32) error 44 } 45 46 // SerialManager manages setting up serial consoles for the Utility VM. 47 type SerialManager interface { 48 // SetSerialConsole sets up a serial console for `port`. Output will be relayed to the listener specified 49 // by `listenerPath`. For HCS `listenerPath` this is expected to be a path to a named pipe. 50 SetSerialConsole(port uint32, listenerPath string) error 51 } 52 53 // BootManager manages boot configurations for the Utility VM. 54 type BootManager interface { 55 // SetUEFIBoot sets UEFI configurations for booting a Utility VM. 56 SetUEFIBoot(dir string, path string, args string) error 57 // SetLinuxKernelDirectBoot sets Linux direct boot configurations for booting a Utility VM. 58 SetLinuxKernelDirectBoot(kernel string, initRD string, cmd string) error 59 } 60 61 // StorageQosManager manages setting storage limits on the Utility VM. 62 type StorageQosManager interface { 63 // SetStorageQos sets storage related options for the Utility VM 64 SetStorageQos(iopsMaximum int64, bandwidthMaximum int64) error 65 } 66 67 // WindowsConfigManager manages options specific to a Windows host (cpugroups etc.) 68 type WindowsConfigManager interface { 69 // SetCPUGroup sets the CPU group that the Utility VM will belong to on a Windows host. 70 SetCPUGroup(ctx context.Context, id string) error 71 } 72 73 // LinuxConfigManager manages options specific to a Linux host. 74 type LinuxConfigManager interface{} 75