Vminitd: Sync(2) on shutdown (#400)

This commit is contained in:
Danny Canter
2025-11-12 09:39:46 -08:00
committed by GitHub
parent bbe9ebd8fa
commit 01437a44a2
3 changed files with 12 additions and 1 deletions
@@ -563,6 +563,8 @@ extension LinuxContainer {
path: Self.guestRootfsPath(self.id),
flags: 0
)
try await agent.sync()
}
// Lets free up the init procs resources, as this includes the open agent conn.
@@ -42,6 +42,7 @@ public protocol VirtualMachineAgent: Sendable {
func mkdir(path: String, all: Bool, perms: UInt32) async throws
@discardableResult
func kill(pid: Int32, signal: Int32) async throws -> Int32
func sync() async throws
func writeFile(path: String, data: Data, flags: WriteFileFlags, mode: UInt32) async throws
// Process lifecycle
@@ -89,4 +90,8 @@ extension VirtualMachineAgent {
public func containerStatistics(containerIDs: [String]) async throws -> [ContainerStatistics] {
throw ContainerizationError(.unsupported, message: "containerStatistics")
}
public func sync() async throws {
throw ContainerizationError(.unsupported, message: "sync")
}
}
+5 -1
View File
@@ -114,7 +114,11 @@ struct Application {
do {
log.info("serving vminitd API")
try await server.serve(port: vsockPort)
log.info("vminitd API returned")
log.info("vminitd API returned, syncing filesystems")
#if os(Linux)
Musl.sync()
#endif
} catch {
log.error("vminitd boot error \(error)")
exit(1)