@@ -55,12 +55,14 @@ func (s *ApiService) GetCapabilities(ctx context.Context, _ oapi.GetCapabilities
5555 if s .InstanceManager != nil {
5656 defaultRuntime = s .InstanceManager .DefaultHypervisor ()
5757 }
58- caps , capsKnown := hypervisor .CapabilitiesForType (defaultRuntime )
58+ supported := supportedRuntimes (runtime .GOOS )
59+ caps , capsKnown := capabilitiesForDefaultRuntime (defaultRuntime , supported )
5960 if ! capsKnown {
60- // The configured default runtime is not available on this platform ;
61+ // The configured default runtime is not usable on this host ;
6162 // report zeroed features rather than guessing.
62- log .WarnContext (ctx , "default runtime has no registered capabilities on this host" ,
63- "runtime" , string (defaultRuntime ))
63+ log .WarnContext (ctx , "default runtime has no usable capabilities on this host" ,
64+ "runtime" , string (defaultRuntime ),
65+ "supported" , supported )
6466 }
6567
6668 emulation := emulationSupported (runtime .GOOS , runtime .GOARCH , defaultRuntime )
@@ -85,7 +87,7 @@ func (s *ApiService) GetCapabilities(ctx context.Context, _ oapi.GetCapabilities
8587 },
8688 Runtime : oapi.CapabilitiesRuntime {
8789 Default : string (defaultRuntime ),
88- Supported : supportedRuntimes ( runtime . GOOS ) ,
90+ Supported : supported ,
8991 Snapshot : caps .SupportsSnapshot ,
9092 Standby : standbySupported (caps ),
9193 Pause : caps .SupportsPause ,
@@ -157,6 +159,23 @@ func supportedRuntimes(goos string) []string {
157159 }
158160}
159161
162+ func capabilitiesForDefaultRuntime (defaultRuntime hypervisor.Type , supported []string ) (hypervisor.Capabilities , bool ) {
163+ if ! runtimeSupported (defaultRuntime , supported ) {
164+ return hypervisor.Capabilities {}, false
165+ }
166+ return hypervisor .CapabilitiesForType (defaultRuntime )
167+ }
168+
169+ func runtimeSupported (defaultRuntime hypervisor.Type , supported []string ) bool {
170+ defaultRuntimeName := string (defaultRuntime )
171+ for _ , runtimeName := range supported {
172+ if runtimeName == defaultRuntimeName {
173+ return true
174+ }
175+ }
176+ return false
177+ }
178+
160179// emulationSupported reports whether the host can boot images built for the
161180// other CPU architecture. This mirrors the create-path rule for attaching
162181// the Rosetta share: vz on Apple Silicon macOS.
0 commit comments