mirror of
https://github.com/apple/container.git
synced 2026-09-22 07:35:36 +00:00
Vminitd: Sync(2) on shutdown (#400)
This commit is contained in:
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user