@@ -133,7 +133,7 @@ extension FileMountContext {
133133 let resolvedSource = URL ( fileURLWithPath: mount. source) . resolvingSymlinksInPath ( )
134134 let filename = resolvedSource. lastPathComponent
135135 let parentDirectory = resolvedSource. deletingLastPathComponent ( )
136- let tag = try hashMountSource ( source : parentDirectory. path)
136+ let tag = try hashFilePath ( path : parentDirectory. path)
137137
138138 let prepared = PreparedMount (
139139 hostFilePath: mount. source,
@@ -151,48 +151,33 @@ extension FileMountContext {
151151}
152152
153153extension FileMountContext {
154- /// Mount the holding directories in the guest for all file mounts.
154+ /// Set up the holding directory paths for all file mounts.
155+ /// Since virtiofs shares are now mounted once at /run/virtiofs, the holding
156+ /// directories appear as subdirectories there automatically.
155157 /// - Parameters:
156158 /// - vmMounts: The AttachedFilesystem array from the VM for this container
157- /// - agent: The VM agent for RPCs
159+ /// - agent: The VM agent for RPCs (unused, kept for API compatibility)
158160 mutating func mountHoldingDirectories(
159161 vmMounts: [ AttachedFilesystem ] ,
160162 agent: any VirtualMachineAgent
161163 ) async throws {
162- // Track which tags we've already mounted to avoid duplicate mounts
163- // when multiple files share the same parent directory.
164- var mountedTags : Set < String > = [ ]
165-
166164 for i in preparedMounts. indices {
167165 let prepared = preparedMounts [ i]
168166
169- let guestPath = " /run/file-mounts/ \( prepared. tag) "
170-
171- if !mountedTags. contains ( prepared. tag) {
172- // Find the attached filesystem by matching the virtiofs tag
173- guard
174- let attached = vmMounts. first ( where: {
175- $0. type == " virtiofs " && $0. source == prepared. tag
176- } )
177- else {
178- throw ContainerizationError (
179- . notFound,
180- message: " could not find attached filesystem for file mount \( prepared. hostFilePath) "
181- )
182- }
183-
184- try await agent. mkdir ( path: guestPath, all: true , perms: 0o755 )
185- try await agent. mount (
186- ContainerizationOCI . Mount (
187- type: " virtiofs " ,
188- source: attached. source,
189- destination: guestPath,
190- options: [ ]
191- ) )
192-
193- mountedTags. insert ( prepared. tag)
167+ // Verify the attached filesystem exists
168+ guard
169+ vmMounts. first ( where: {
170+ $0. type == " virtiofs " && $0. source == prepared. tag
171+ } ) != nil
172+ else {
173+ throw ContainerizationError (
174+ . notFound,
175+ message: " could not find attached filesystem for file mount \( prepared. hostFilePath) "
176+ )
194177 }
195178
179+ // With unified virtiofs, holding directories are subdirectories under /run/virtiofs
180+ let guestPath = " /run/virtiofs/ \( prepared. tag) "
196181 preparedMounts [ i] . guestHoldingPath = guestPath
197182 }
198183 }
0 commit comments