mirror of
https://github.com/apple/container.git
synced 2026-09-20 22:55:40 +00:00
VZVirtualMachineInstance: Adjust silent success behavior of nested virt (#88)
Fixes #85 The virtualization bool on LinuxContainer mostly just forwards to VZVirtualMachineInstance which today would silently take your boolean and do nothing if the underlying platform doesn't have support for it. This is (to me) arguably worse than erroring, as it gives the client a false security that the setting is on, and they should have virt capabilities in the container/guest now. This change makes it so that we throw a ContainerizationError for this case, with a code of .unsupported so it's checkable by a user if they want more information on the "why".
This commit is contained in:
@@ -294,16 +294,18 @@ extension VZVirtualMachineInstance.Configuration {
|
||||
try mount.configure(config: &config)
|
||||
}
|
||||
|
||||
#if arch(arm64)
|
||||
|
||||
let platform = VZGenericPlatformConfiguration()
|
||||
if VZGenericPlatformConfiguration.isNestedVirtualizationSupported {
|
||||
platform.isNestedVirtualizationEnabled = self.nestedVirtualization
|
||||
// We shouldn't silently succeed if the user asked for virt and their hardware does
|
||||
// not support it.
|
||||
if !VZGenericPlatformConfiguration.isNestedVirtualizationSupported && self.nestedVirtualization {
|
||||
throw ContainerizationError(
|
||||
.unsupported,
|
||||
message: "nested virtualization is not supported on the platform"
|
||||
)
|
||||
}
|
||||
platform.isNestedVirtualizationEnabled = self.nestedVirtualization
|
||||
config.platform = platform
|
||||
|
||||
#endif
|
||||
|
||||
try config.validate()
|
||||
return config
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user