From 5980d9bcfeacb4fe5e46356bdc60911f82056c58 Mon Sep 17 00:00:00 2001 From: Hamza El-Saawy <84944216+helsaawy@users.noreply.github.com> Date: Mon, 8 Jul 2024 14:47:48 -0400 Subject: [PATCH] [test] Add Hyper-V socket functional tests (#1979) * [test] Add hvsock connection tests Add tests for binding to and listening on hyper-v sockets from within a uVM (as well as a hyper-v isolated containers). Tests verify default SDDL and wildcard bind settings, as well updating the settings for a particular service ID. In order to test HVSocket communication, an agent is needed to run from within the uVM (or container within that). To accomplish that, the ability to re-exec the (functional) testing binary is added, so that it can be shared into the uVM (or container) and then run a separate code path that is defined within the same test case that is running on the host. For example, while running the test case `TestHVSock_Container_GuestBind/default`, the functional testing binary that is being run (i.e. `functional.test.exe`) is shared within the running container and then run with the flag `-run=^TestHVSock_Container_GuestBind$/^default$`. This causes the guest to bind to the agreed-upon Service GUID, and then (after the host connects to the same Service GUID), the guest verifies the expected VM and service GUIDs, and then ensures communication is possible. Signed-off-by: Hamza El-Saawy * PR: remove hvsock feature Signed-off-by: Hamza El-Saawy --------- Signed-off-by: Hamza El-Saawy --- uvm/create.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/uvm/create.go b/uvm/create.go index 7d9ee8fa66..ecbe9ab975 100644 --- a/uvm/create.go +++ b/uvm/create.go @@ -10,6 +10,7 @@ import ( "path/filepath" "runtime" + "github.com/Microsoft/go-winio/pkg/guid" "github.com/sirupsen/logrus" "go.opencensus.io/trace" "golang.org/x/sys/windows" @@ -174,6 +175,13 @@ func (uvm *UtilityVM) ID() string { return uvm.hcsSystem.ID() } +// RuntimeID returns Hyper-V VM GUID. +// +// Only valid after the utility VM has been created. +func (uvm *UtilityVM) RuntimeID() guid.GUID { + return uvm.runtimeID +} + // OS returns the operating system of the utility VM. func (uvm *UtilityVM) OS() string { return uvm.operatingSystem