Skip to content

Commit

Permalink
added ValidateSaveRestoreSupport in Save/Restore methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Code-Hex committed Oct 22, 2023
1 parent 877edb3 commit f02f617
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions virtualization.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ type VirtualMachine struct {
machineState *machineState

finalizeOnce sync.Once

config *VirtualMachineConfiguration
}

type machineState struct {
Expand Down Expand Up @@ -134,6 +136,7 @@ func NewVirtualMachine(config *VirtualMachineConfiguration) (*VirtualMachine, er
),
dispatchQueue: dispatchQueue,
machineState: machineState,
config: config,
}

objc.SetFinalizer(v, func(self *VirtualMachine) {
Expand Down
6 changes: 6 additions & 0 deletions virtualization_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,9 @@ func (v *VirtualMachine) SaveMachineStateToPath(saveFilePath string) error {
if err := macOSAvailable(14); err != nil {
return err
}
if _, err := v.config.ValidateSaveRestoreSupport(); err != nil {
return err
}
cs := charWithGoString(saveFilePath)
defer cs.Free()
h, errCh := makeHandler()
Expand Down Expand Up @@ -629,6 +632,9 @@ func (v *VirtualMachine) RestoreMachineStateFromURL(saveFilePath string) error {
if err := macOSAvailable(14); err != nil {
return err
}
if _, err := v.config.ValidateSaveRestoreSupport(); err != nil {
return err
}
cs := charWithGoString(saveFilePath)
defer cs.Free()
h, errCh := makeHandler()
Expand Down

0 comments on commit f02f617

Please sign in to comment.