Skip to content

[shimV2] add plan9 device controller#2641

Open
rawahars wants to merge 8 commits intomicrosoft:mainfrom
rawahars:plan9-dev-controller
Open

[shimV2] add plan9 device controller#2641
rawahars wants to merge 8 commits intomicrosoft:mainfrom
rawahars:plan9-dev-controller

Conversation

@rawahars
Copy link
Copy Markdown
Contributor

@rawahars rawahars commented Mar 21, 2026

Summary

This change adds the plan9 device controller which can add/remove plan9 shares from a VM. The guest side operations are part of mount controller responsibility.

Whenever a new request for AddToVM comes, we call into HCS to hot-add the path via HcsModifyComputeSystem, where you inject a Plan9Share entry into the VM’s Devices → Plan9 → Shares schema, and HCS plumbs the corresponding endpoints so the guest can mount it using the Plan 9 (9P) protocol.

Note

For the same host path, we add a new share to the UVM. This pattern is similar to the existing pattern.
Ref- https://github.com/microsoft/hcsshim/blob/87708ff3150b7bceca4dbb3f7cdb7147428e42c3/internal/uvm/plan9.go

Imagine that the caller wants to add the same host path at two different guest locations-

Location 1: /tools
Location2: /tools2

If we do not create a new share for the UVM, we are likely to send a second GCS request asking the same share to be mounted at tools2. When the guest receives the GuestRequest of type ResourceTypeMappedDirectory, the handler unconditionally calls plan9.Mount(). This will, regardless of whether the same share name / aname was already mounted, dials a brand new vsock connection to the Plan9 server, opens a file descriptor from it, and performs a fresh unix.Mount(..., "9p", ...) syscall. This leads to error.

If we need to perform refCounting for plan9, it would need changes on both shim and guest side.

@rawahars rawahars requested a review from a team as a code owner March 21, 2026 12:14
rawahars added 2 commits April 5, 2026 06:33
This change adds the plan9 device controller which can add/remove plan9 shares from a VM. The guest side operations are part of mount controller responsibility.

Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
@rawahars rawahars force-pushed the plan9-dev-controller branch from 2ecafc6 to 4a697a8 Compare April 5, 2026 02:05
Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
@rawahars rawahars force-pushed the plan9-dev-controller branch from 4a697a8 to b2cff99 Compare April 5, 2026 04:19
rawahars added 3 commits April 7, 2026 08:55
Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
…attempts

Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
@rawahars rawahars force-pushed the plan9-dev-controller branch from e289573 to 2d9f924 Compare April 8, 2026 01:50
Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
@@ -1,12 +1,12 @@
//go:build windows
//go:build windows && lcow
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this not just lcow?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a general rule in the repo, we always add the windows tag too.
It's banal though since HCS is Windows based and this shim can only be built for Windows.
But in short this is just for consistency across package.

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.

4 participants