|
| 1 | +package vm |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + |
| 6 | + "github.com/Microsoft/hcsshim/internal/gcs" |
| 7 | + hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" |
| 8 | + "github.com/Microsoft/hcsshim/internal/protocol/guestrequest" |
| 9 | + "github.com/Microsoft/hcsshim/internal/protocol/guestresource" |
| 10 | +) |
| 11 | + |
| 12 | +// ConfigOption defines a function that modifies the GCS connection config. |
| 13 | +type ConfigOption func(*gcs.GuestConnectionConfig) error |
| 14 | + |
| 15 | +// GuestOps is an interface to interact with |
| 16 | +type GuestOps interface { |
| 17 | + // CreateConnection creates a connection to the guest. |
| 18 | + CreateConnection(ctx context.Context, opts ...ConfigOption) error |
| 19 | + // CloseConnection closes the connection to the guest. |
| 20 | + CloseConnection() error |
| 21 | + // Capabilities returns the guest's declared capabilities. |
| 22 | + Capabilities() gcs.GuestDefinedCapabilities |
| 23 | + // LayersManager returns an interface to manage combined layers in the guest. |
| 24 | + LayersManager() LayersManager |
| 25 | + // GuestNetworkManager returns an interface to manage networking in the guest. |
| 26 | + GuestNetworkManager() GuestNetworkManager |
| 27 | + // DirectoryManager returns an interface to manage mapped directories in the guest. |
| 28 | + DirectoryManager() DirectoryManager |
| 29 | + // SecurityPolicyManager returns an interface to manage guest security policy operations. |
| 30 | + SecurityPolicyManager() SecurityPolicyManager |
| 31 | + // GuestDeviceManager returns an interface to manage device operations in the guest. |
| 32 | + GuestDeviceManager() GuestDeviceManager |
| 33 | + // BlockCIMsManager returns an interface to manage WCOW block CIMs in the guest. |
| 34 | + BlockCIMsManager() BlockCIMsManager |
| 35 | + // ScsiManager returns an interface to manage SCSI-related operations in the guest. |
| 36 | + ScsiManager() ScsiManager |
| 37 | +} |
| 38 | + |
| 39 | +// LayersManager exposes combined layer operations in the guest. |
| 40 | +type LayersManager interface { |
| 41 | + AddCombinedLayers(ctx context.Context, settings interface{}) error |
| 42 | + AddCWCOWCombinedLayers(ctx context.Context, settings interface{}) error |
| 43 | + RemoveCombinedLayers(ctx context.Context, settings interface{}) error |
| 44 | + RemoveCWCOWCombinedLayers(ctx context.Context, settings interface{}) error |
| 45 | +} |
| 46 | + |
| 47 | +// GuestNetworkManager exposes guest network operations. |
| 48 | +type GuestNetworkManager interface { |
| 49 | + AddNetworkNamespace(ctx context.Context, settings interface{}) error |
| 50 | + RemoveNetworkNamespace(ctx context.Context, settings interface{}) error |
| 51 | + AddNetworkInterface(ctx context.Context, adapterID string, requestType guestrequest.RequestType, settings interface{}) error |
| 52 | + AddNetworkInterfaceLCOW(ctx context.Context, settings *guestresource.LCOWNetworkAdapter) error |
| 53 | + RemoveNetworkInterface(ctx context.Context, adapterID string, requestType guestrequest.RequestType, settings interface{}) error |
| 54 | + RemoveNetworkInterfaceLCOW(ctx context.Context, settings *guestresource.LCOWNetworkAdapter) error |
| 55 | +} |
| 56 | + |
| 57 | +// DirectoryManager exposes mapped directory operations in the guest. |
| 58 | +type DirectoryManager interface { |
| 59 | + AddMappedDirectory(ctx context.Context, settings *hcsschema.MappedDirectory) error |
| 60 | + AddMappedDirectoryLCOW(ctx context.Context, settings guestresource.LCOWMappedDirectory) error |
| 61 | + RemoveMappedDirectoryLCOW(ctx context.Context, settings guestresource.LCOWMappedDirectory) error |
| 62 | +} |
| 63 | + |
| 64 | +// SecurityPolicyManager exposes guest security policy operations. |
| 65 | +type SecurityPolicyManager interface { |
| 66 | + AddSecurityPolicy(ctx context.Context, settings interface{}) error |
| 67 | + InjectPolicyFragment(ctx context.Context, settings guestresource.SecurityPolicyFragment) error |
| 68 | +} |
| 69 | + |
| 70 | +// GuestDeviceManager exposes guest device operations. |
| 71 | +type GuestDeviceManager interface { |
| 72 | + AddVPCIDevice(ctx context.Context, vmBusGUID string) error |
| 73 | + AddVPMemDevice(ctx context.Context, settings guestresource.LCOWMappedVPMemDevice) error |
| 74 | + RemoveVPMemDevice(ctx context.Context, settings guestresource.LCOWMappedVPMemDevice) error |
| 75 | +} |
| 76 | + |
| 77 | +// BlockCIMsManager exposes guest WCOW block CIM operations. |
| 78 | +type BlockCIMsManager interface { |
| 79 | + AddWCOWBlockCIMs(ctx context.Context, settings *guestresource.CWCOWBlockCIMMounts) error |
| 80 | + RemoveWCOWBlockCIMs(ctx context.Context, settings *guestresource.CWCOWBlockCIMMounts) error |
| 81 | +} |
| 82 | + |
| 83 | +// ScsiManager exposes guest SCSI operations. |
| 84 | +type ScsiManager interface { |
| 85 | + AddMappedVirtualDisk(ctx context.Context, settings interface{}) error |
| 86 | + AddMappedVirtualDiskForContainerScratch(ctx context.Context, settings interface{}) error |
| 87 | + RemoveMappedVirtualDisk(ctx context.Context, settings interface{}) error |
| 88 | + RemoveSCSIDevice(ctx context.Context, settings guestresource.SCSIDevice) error |
| 89 | +} |
0 commit comments