forked from Code-Hex/vz
-
Notifications
You must be signed in to change notification settings - Fork 1
/
memory_balloon.go
53 lines (43 loc) · 1.72 KB
/
memory_balloon.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package vz
/*
#cgo darwin CFLAGS: -mmacosx-version-min=11 -x objective-c -fno-objc-arc
#cgo darwin LDFLAGS: -lobjc -framework Foundation -framework Virtualization
# include "virtualization_11.h"
*/
import "C"
import (
"github.com/Code-Hex/vz/v3/internal/objc"
)
// MemoryBalloonDeviceConfiguration for a memory balloon device configuration.
type MemoryBalloonDeviceConfiguration interface {
objc.NSObject
memoryBalloonDeviceConfiguration()
}
type baseMemoryBalloonDeviceConfiguration struct{}
func (*baseMemoryBalloonDeviceConfiguration) memoryBalloonDeviceConfiguration() {}
var _ MemoryBalloonDeviceConfiguration = (*VirtioTraditionalMemoryBalloonDeviceConfiguration)(nil)
// VirtioTraditionalMemoryBalloonDeviceConfiguration is a configuration of the Virtio traditional memory balloon device.
//
// see: https://developer.apple.com/documentation/virtualization/vzvirtiotraditionalmemoryballoondeviceconfiguration?language=objc
type VirtioTraditionalMemoryBalloonDeviceConfiguration struct {
*pointer
*baseMemoryBalloonDeviceConfiguration
}
// NewVirtioTraditionalMemoryBalloonDeviceConfiguration creates a new VirtioTraditionalMemoryBalloonDeviceConfiguration.
//
// This is only supported on macOS 11 and newer, error will
// be returned on older versions.
func NewVirtioTraditionalMemoryBalloonDeviceConfiguration() (*VirtioTraditionalMemoryBalloonDeviceConfiguration, error) {
if err := macOSAvailable(11); err != nil {
return nil, err
}
config := &VirtioTraditionalMemoryBalloonDeviceConfiguration{
pointer: objc.NewPointer(
C.newVZVirtioTraditionalMemoryBalloonDeviceConfiguration(),
),
}
objc.SetFinalizer(config, func(self *VirtioTraditionalMemoryBalloonDeviceConfiguration) {
objc.Release(self)
})
return config, nil
}