@@ -5,57 +5,83 @@ configuration, host-side management, and guest-side actions distinct so each lay
55
661 . ** Builder** : constructs an HCS compute system configuration used to create a VM.
772 . ** VM Manager** : manages host-side VM configuration and lifecycle (NICs, SCSI, VPMem, etc.).
8- 3 . ** Guest Manager** : intended for guest-side actions (for example, mounting a disk).
8+ 3 . ** Guest Manager** : guest-side actions executed via the GCS connection (for example, mounting a mapped disk).
99
1010** Note that** this layer does not store UVM host or guest side state. That will be part of the orchestration layer above it.
1111
1212## Packages and Responsibilities
1313
1414- ` internal/vm `
15- - Shared types used across layers (for example, ` GuestOS ` , ` SCSIDisk ` ).
15+ - Shared types used across layers (currently ` GuestOS ` ).
1616- ` internal/vm/builder `
17- - Interface definitions for shaping the VM configuration (` Builder ` interface).
18- - Concrete implementation of ` Builder ` for building ` hcsschema.ComputeSystem ` documents.
19- - Provides a fluent API for configuring all aspects of the VM document.
20- - Presently, this package is tightly coupled with HCS backend.
17+ - Interface definitions for shaping the VM configuration (` BootOptions ` , ` MemoryOptions ` , ` ProcessorOptions ` , ` DeviceOptions ` ,
18+ ` NumaOptions ` , ` StorageQoSOptions ` ).
19+ - Concrete implementation of ` UtilityVMBuilder ` for building ` hcsschema.ComputeSystem ` documents (` UtilityVM ` ).
20+ - Provies a fluent API for constructing the ` hcsschema.ComputeSystem ` document used to create a UVM.
21+ - Presently, this package is tightly coupled with the HCS backend.
2122- ` internal/vm/vmmanager `
2223 - Interface definitions for UVM lifecycle and host-side management.
23- - Concrete implementation of ` UVM ` for running and managing a UVM instance.
24- - Presently, this package is tightly coupled with HCS backend and only runs HCS backed UVMs.
25- - Owns lifecycle calls (start/terminate/close) and host-side modifications (NICs, SCSI, VPMem, pipes, VSMB, Plan9).
26- - Allows creation of the UVM using ` vmmanager.Create ` which takes a ` Builder ` and produces a running UVM.
24+ - Concrete implementation of ` UtilityVM ` for running and managing a UVM instance created from a builder document.
25+ - Owns lifecycle calls (start/terminate/close/pause/resume/save/wait) and host-side modifications:
26+ - Network adapters (` NetworkManager ` ), SCSI disks (` SCSIManager ` ), VPMem (` VPMemManager ` ), VSMB (` VSMBManager ` ), Plan9 (` Plan9Manager ` ).
27+ - Named pipes (` PipeManager ` ), virtual PCI devices (` PCIManager ` ), HvSocket services (` VMSocketManager ` ).
28+ - Resource updates such as CPU group/limits and memory (` ResourceManager ` ).
29+ - Presently, this package is tightly coupled with the HCS backend and only runs HCS-backed UVMs.
2730- ` internal/vm/guestmanager `
28- - Reserved for guest-level actions such as mounting disks or performing in-guest configuration.
29- - Currently empty and intended to grow as guest actions are formalized.
31+ - Interface definitions for guest-side operations executed via the GCS connection.
32+ - Manages GCS connection lifecycle, including HvSocket setup and initial guest state.
33+ - Implements operations for guest resources, split by LCOW/WCOW where needed:
34+ - Network interfaces/namespaces, mapped directories, mapped virtual disks, combined layers, block CIMs (WCOW),
35+ VPCI/VPMem devices (LCOW), and security policy operations.
36+ - Translates guest operations into GCS modify requests.
3037
3138## Typical Flow
3239
33- 1 . Build the config using the builder interfaces .
40+ 1 . Build the config using the builder options .
34412 . Create the VM using the VM manager.
35- 3 . Use manager interfaces for lifecycle and host-side changes.
36- 4 . Use guest manager interfaces for in-guest actions (when available) .
42+ 3 . Use manager methods for lifecycle and host-side changes.
43+ 4 . Establish a GCS connection and use guest manager interfaces for in-guest actions.
3744
3845## Example (High Level)
3946
4047```
41- builder, _ := builder.New("owner", vm.Linux)
48+ b, _ := builder.New("owner", vm.Linux)
49+
50+ // Parse into the correct builder option.
51+ memoryOpts := builder.MemoryOptions(b)
52+ processorOpts := builder.ProcessorOptions(b)
4253
4354// Configure the VM document.
44- builder.Memory() .SetMemoryLimit(1024)
45- builder.Processor().SetProcessorConfig(&vm.ProcessorConfig {Count: 2})
55+ memoryOpts .SetMemoryLimit(1024)
56+ processorOpts.SetProcessorLimits(&hcsschema.VirtualMachineProcessor {Count: 2})
4657// ... other builder configuration
4758
48- // Create and start the VM.
49- uvm, _ := vmmanager.Create(ctx, "uvm-id", builder)
50- _ = uvm.LifetimeManager().Start(ctx)
59+ // Create the VM.
60+ uvm, _ := vmmanager.Create(ctx, "uvm-id", b)
61+ _ = uvm.Start(ctx)
62+
63+ // Create the Guest Connection.
64+ g, _ := guestmanager.New(ctx, uvm)
65+
66+ // Start the UVM.
67+ lifetime := vmmanager.LifetimeManager(uvm)
68+ _ = lifetime.Start(ctx)
69+
70+ // Create the connection.
71+ guest := guestmanager.Manager(g)
72+ _ = guest.CreateConnection(ctx)
5173
5274// Apply host-side updates.
53- _ = uvm.NetworkManager().AddNIC(ctx, nicID, endpointID, macAddr)
75+ network := vmmanager.NetworkManager(uvm)
76+ _ = network.AddNIC(ctx, nicID, &hcsschema.NetworkAdapter{})
77+
78+ // Apply guest-side updates.
79+ guestNetwork := guestmanager.LCOWNetworkManager(g)
80+ _ = guestNetwork.AddLCOWNetworkInterface(ctx, &guestresource.LCOWNetworkAdapter{})
5481```
5582
5683## Layer Boundaries (Quick Reference)
5784
5885- ** Builder** : static, pre-create configuration only. No host mutations.
5986- ** VM Manager** : host-side changes and lifecycle operations on an existing UVM.
60- - ** Guest Manager** : guest-side actions, scoped to work that requires in-guest context.
61-
87+ - ** Guest Manager** : guest-side actions, scoped to work that requires in-guest context (GCS-backed).
0 commit comments