File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -105,6 +105,8 @@ func macOSBuildTargetAvailable(version float64) error {
105105 target = 130000 // __MAC_13_0
106106 case 14 :
107107 target = 140000 // __MAC_14_0
108+ case 15 :
109+ target = 150000 // __MAC_15_0
108110 }
109111 if allowedVersion < target {
110112 return fmt .Errorf ("%w for %.1f (the binary was built with __MAC_OS_X_VERSION_MAX_ALLOWED=%d; needs recompilation)" ,
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ package vz
66# include "virtualization_11.h"
77# include "virtualization_12.h"
88# include "virtualization_13.h"
9+ # include "virtualization_15.h"
910*/
1011import "C"
1112import (
@@ -40,6 +41,28 @@ func (m *GenericPlatformConfiguration) MachineIdentifier() *GenericMachineIdenti
4041 return m .machineIdentifier
4142}
4243
44+ // IsNestedVirtualizationSupported reports if nested virtualization is supported.
45+ func IsNestedVirtualizationSupported () bool {
46+ if err := macOSAvailable (15 ); err != nil {
47+ return false
48+ }
49+
50+ return (bool )(C .isNestedVirtualizationSupported ())
51+ }
52+
53+ // SetNestedVirtualizationEnabled toggles nested virtualization.
54+ func (m * GenericPlatformConfiguration ) SetNestedVirtualizationEnabled (enable bool ) error {
55+ if err := macOSAvailable (15 ); err != nil {
56+ return err
57+ }
58+
59+ C .setNestedVirtualizationEnabled (
60+ objc .Ptr (m ),
61+ C .bool (enable ),
62+ )
63+ return nil
64+ }
65+
4366var _ PlatformConfiguration = (* GenericPlatformConfiguration )(nil )
4467
4568// NewGenericPlatformConfiguration creates a new generic platform configuration.
Original file line number Diff line number Diff line change 1+ //
2+ // virtualization_15.h
3+
4+ #pragma once
5+
6+ // FIXME(codehex): this is dirty hack to avoid clang-format error like below
7+ // "Configuration file(s) do(es) not support C++: /github.com/Code-Hex/vz/.clang-format"
8+ #define NSURLComponents NSURLComponents
9+
10+ #import " virtualization_helper.h"
11+ #import < Virtualization/Virtualization.h>
12+
13+ /* macOS 15 API */
14+ bool isNestedVirtualizationSupported ();
15+ void setNestedVirtualizationEnabled (void *config, bool nestedVirtualizationEnabled);
Original file line number Diff line number Diff line change 1+ //
2+ // virtualization_15.m
3+ //
4+ #import " virtualization_15.h"
5+
6+ /* !
7+ @abstract Check if nested virtualization is supported.
8+ @return true if supported.
9+ */
10+ bool isNestedVirtualizationSupported ()
11+ {
12+ #ifdef INCLUDE_TARGET_OSX_15
13+ if (@available (macOS 15 , *)) {
14+ return (bool ) VZGenericPlatformConfiguration.isNestedVirtualizationSupported ;
15+ }
16+ #endif
17+ RAISE_UNSUPPORTED_MACOS_EXCEPTION ();
18+ }
19+
20+ /* !
21+ @abstract Set nestedVirtualizationEnabled. The default is false.
22+ */
23+ void setNestedVirtualizationEnabled (void *config, bool nestedVirtualizationEnabled)
24+ {
25+ #ifdef INCLUDE_TARGET_OSX_15
26+ if (@available (macOS 15 , *)) {
27+ VZGenericPlatformConfiguration *platformConfig = (VZGenericPlatformConfiguration *)config;
28+ platformConfig.nestedVirtualizationEnabled = (BOOL ) nestedVirtualizationEnabled;
29+ return ;
30+ }
31+ #endif
32+ RAISE_UNSUPPORTED_MACOS_EXCEPTION ();
33+ }
Original file line number Diff line number Diff line change @@ -39,6 +39,13 @@ NSDictionary *dumpProcessinfo();
3939#pragma message("macOS 14 API has been disabled")
4040#endif
4141
42+ // for macOS 15 API
43+ #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 150000
44+ #define INCLUDE_TARGET_OSX_15 1
45+ #else
46+ #pragma message("macOS 15 API has been disabled")
47+ #endif
48+
4249static inline int mac_os_x_version_max_allowed ()
4350{
4451#ifdef __MAC_OS_X_VERSION_MAX_ALLOWED
You can’t perform that action at this time.
0 commit comments