Skip to content

Refactor GCS logging and guest management for reusability#2612

Open
rawahars wants to merge 7 commits intomicrosoft:mainfrom
rawahars:refactor-into-vmutils
Open

Refactor GCS logging and guest management for reusability#2612
rawahars wants to merge 7 commits intomicrosoft:mainfrom
rawahars:refactor-into-vmutils

Conversation

@rawahars
Copy link
Contributor

This pull request refactors the handling of LCOW utility VM constants, device type validation, and related utility functions. The main goal is to centralize constants and helper functions into a new vmutils package, which improves code maintainability and consistency.

Additionally, it introduces a StoppedTime method to the System struct. This will be used in SandboxWait API response.

The most important changes are:

Centralization of Constants and Utility Functions

  • Moved various LCOW boot file names (e.g., KernelFile, InitrdFile, VhdFile, etc.), default values (e.g., DefaultVPMEMCount, DefaultVPMemSizeBytes), and error variables (e.g., ErrCPUGroupCreateNotSupported) from the uvm package to a new vmutils package. Updated all references throughout the codebase to use the new locations.

  • Centralized the device type validation function by moving IsValidDeviceType from the uvm package to vmutils, and updated all usages accordingly.

Refactoring and Type Improvements

  • Updated the OptionsLCOW struct to use vmutils.OutputHandlerCreator for output handling, and updated default assignments to use vmutils.ParseGCSLogrus.

System Lifecycle Tracking

  • Added a stopTime field and a StoppedTime() method to the System struct in internal/hcs/system.go to record and expose the time when a system stops.

Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
WaitSandbox API expects the exit code and exit timestamp in it's response. Therefore, adding and capturing the same to the actual compute system struct.

Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
There were few issues in the initial draft of guest manager code-
- Guest connection listener was created during New method and then used in CreateConnection. This can be simplified by creating the listener prior to start accepting connections on the same.
- Instead of hardcoding the GCS Service GUID, it can be made into a configurable parameter so that it can be used across shims.
- Updation of HvSocket was needed only for WCOW and hence that responsibility can be deferred to the caller and hence hvSocket API was introduced.

Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
AcceptConnection method was incorrectly part of guestmanager package. Moreover, we needed stop time in SandboxWait API and hence the same is added to the manager.

Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
@rawahars rawahars requested a review from a team as a code owner February 27, 2026 21:05
Start time is needed to be returned in the StartSandbox API and SandboxStatus API. Therefore, we need the plumbing for the same.

Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant