Skip to content
Merged
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
39 changes: 22 additions & 17 deletions internal/annotations/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
// Do not rely on these annotations to customize production workload behavior.
package annotations

// uVM specific annotations

// uVM annotations.
const (
// UVMHyperVSocketConfigPrefix is the prefix of an annotation to map a [hyper-v socket] service GUID
// to a JSON-encoded string of its [configuration].
Expand All @@ -30,24 +29,15 @@ const (
// [configuration]: https://learn.microsoft.com/en-us/virtualization/api/hcs/schemareference#HvSocketServiceConfig
UVMHyperVSocketConfigPrefix = "io.microsoft.virtualmachine.hv-socket.service-table."

// AdditionalRegistryValues specifies additional registry keys and their values to set in the WCOW UVM.
// The format is a JSON-encoded string of an array containing [HCS RegistryValue] objects.
//
// Registry values will be available under `HKEY_LOCAL_MACHINE` root key.
//
// For example:
//
// "[{\"Key\": {\"Hive\": \"System\", \"Name\": \"registry\\key\\path"}, \"Name\": \"ValueName\", \"Type\": \"String\", \"StringValue\": \"value\"}]"
//
// [HCS RegistryValue]: https://learn.microsoft.com/en-us/virtualization/api/hcs/schemareference#registryvalue
AdditionalRegistryValues = "io.microsoft.virtualmachine.wcow.additional-reg-keys"

// ExtraVSockPorts adds additional ports to the list of ports that the UVM is allowed to use.
ExtraVSockPorts = "io.microsoft.virtualmachine.lcow.extra-vsock-ports"

// UVMConsolePipe is the name of the named pipe that the UVM console is connected to. This works only for non-SNP
// scenario, for SNP use a debugger.
UVMConsolePipe = "io.microsoft.virtualmachine.console.pipe"
)

// LCOW uVM annotations.
const (
// ExtraVSockPorts adds additional ports to the list of ports that the UVM is allowed to use.
ExtraVSockPorts = "io.microsoft.virtualmachine.lcow.extra-vsock-ports"

// NetworkingPolicyBasedRouting toggles on the ability to set policy based routing in the
// guest for LCOW.
Expand All @@ -57,3 +47,18 @@ const (
// LCOW scenarios. Ideally, this annotation should be removed if no issues are found.
NetworkingPolicyBasedRouting = "io.microsoft.virtualmachine.lcow.network.policybasedrouting"
)

// WCOW uVM annotations.
const (
// AdditionalRegistryValues specifies additional registry keys and their values to set in the WCOW UVM.
// The format is a JSON-encoded string of an array containing [HCS RegistryValue] objects.
//
// Registry values will be available under `HKEY_LOCAL_MACHINE` root key.
//
// For example:
//
// "[{\"Key\": {\"Hive\": \"System\", \"Name\": \"registry\\key\\path"}, \"Name\": \"ValueName\", \"Type\": \"String\", \"StringValue\": \"value\"}]"
//
// [HCS RegistryValue]: https://learn.microsoft.com/en-us/virtualization/api/hcs/schemareference#registryvalue
AdditionalRegistryValues = "io.microsoft.virtualmachine.wcow.additional-reg-keys"
)
2 changes: 1 addition & 1 deletion internal/oci/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func ProcessAnnotations(ctx context.Context, s *specs.Spec) error {

// expand annotations
var errs []error
for key, exps := range annotations.AnnotationExpansions {
for key, exps := range annotations.AnnotationExpansionMap() {
// check if annotation is present
if val, ok := s.Annotations[key]; ok {
// ideally, some normalization would occur here (ie, "True" -> "true")
Expand Down
3 changes: 2 additions & 1 deletion internal/oci/annotations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ func TestProccessAnnotations_Expansion(t *testing.T) {
subtest.Fatalf("could not update spec from options: %v", err)
}

for _, k := range annotations.AnnotationExpansions[annotations.DisableUnsafeOperations] {
ae := annotations.AnnotationExpansionMap()
for _, k := range ae[annotations.DisableUnsafeOperations] {
if vv := tt.spec.Annotations[k]; vv != v {
subtest.Fatalf("annotation %q was incorrectly expanded to %q, expected %q", k, vv, v)
}
Expand Down
Loading
Loading