Skip to content

Commit

Permalink
Merge pull request #149 from Code-Hex/add/validation-save-restore
Browse files Browse the repository at this point in the history
added ValidateSaveRestoreSupport in Save/Restore methods
  • Loading branch information
Code-Hex authored Oct 22, 2023
2 parents b9079bb + f02f617 commit bd29a7e
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 bd29a7e

Please sign in to comment.