[shimV2] add plan9 device controller#2641
Conversation
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>
2ecafc6 to
4a697a8
Compare
4a697a8 to
b2cff99
Compare
Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
…attempts Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
e289573 to
2d9f924
Compare
Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
| } | ||
|
|
||
| m.state = StateMounted | ||
| // Note we don't increment the ref count here as the caller of |
There was a problem hiding this comment.
This comment isnt true. All callers follow the pattern.
Reserve
MountToGuest
UnmountFromGuest
There was a problem hiding this comment.
Right. It was unnecessary. Removing it in the revision.
| // Share was never added — move directly to removed. | ||
| s.state = StateRemoved | ||
|
|
||
| case StateAdded: |
There was a problem hiding this comment.
cant you just say StateAdded, StateInvalid.
Then do the identical code here.
handle the mount if not nil.
Handle the remove.
If remove error set to StateInvalid.
This prevents any new leases to be acquired while in the tearing down state.
If no error, just set to Removed.
The biggest difference is that they reuse the same code, but prevent new leases
| @@ -1,12 +1,12 @@ | |||
| //go:build windows | |||
| //go:build windows && lcow | |||
There was a problem hiding this comment.
Why is this not just lcow?
| return c.HostPath == other.HostPath && | ||
| c.ReadOnly == other.ReadOnly && | ||
| c.Restrict == other.Restrict && | ||
| slices.Equal(c.AllowedNames, other.AllowedNames) |
There was a problem hiding this comment.
similar to elsewhere, this is order and case sensitive
| vmPlan9 vmPlan9 | ||
|
|
||
| // linuxGuest is the guest-side interface for LCOW Plan9 operations. | ||
| // Immutable after construction. | ||
| linuxGuest guestPlan9 |
There was a problem hiding this comment.
linux is probably a redundant/unnecessary prefix
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
AddToVMcomes, we call into HCS to hot-add the path viaHcsModifyComputeSystem, 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-
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 theGuestRequestof typeResourceTypeMappedDirectory, the handler unconditionally callsplan9.Mount(). This will, regardless of whether the same sharename / anamewas already mounted, dials a brand newvsockconnection to the Plan9 server, opens a file descriptor from it, and performs a freshunix.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.