Throw error when starting a container with invalid virtiofs source (#1051)

Run = Create + Start

1) Mount source points to a valid directory
- Run and Create + Start both correctly create the container with mount.

2) Mount source points to a file
   - Run fails bootstrapping the container, thus container not created.
- Create creates the container, but Start fails bootstrapping, removing
the container. (Thus, both are the same.)

3) Mount source deleted or replaced to file after container created
   - Start throw errors but do not delete the container.
This commit is contained in:
jwhur
2026-01-19 13:09:34 -08:00
committed by GitHub
parent 08f48d9ab9
commit 69445b91b3
@@ -18,6 +18,7 @@ import ArgumentParser
import ContainerAPIClient
import ContainerizationError
import ContainerizationOS
import Foundation
import TerminalProgress
extension Application {
@@ -69,6 +70,12 @@ extension Application {
return
}
for mount in container.configuration.mounts where mount.isVirtiofs {
if !FileManager.default.fileExists(atPath: mount.source) {
throw ContainerizationError(.invalidState, message: "path '\(mount.source)' is not a directory")
}
}
do {
let io = try ProcessIO.create(
tty: container.configuration.initProcess.terminal,