From 69445b91b30c8dac6ebaebd7af9bf63d9526c572 Mon Sep 17 00:00:00 2001 From: jwhur <57657645+JaewonHur@users.noreply.github.com> Date: Mon, 19 Jan 2026 13:09:34 -0800 Subject: [PATCH] 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. --- Sources/ContainerCommands/Container/ContainerStart.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sources/ContainerCommands/Container/ContainerStart.swift b/Sources/ContainerCommands/Container/ContainerStart.swift index 226cabd4..df93268c 100644 --- a/Sources/ContainerCommands/Container/ContainerStart.swift +++ b/Sources/ContainerCommands/Container/ContainerStart.swift @@ -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,