Adapt Intel VM suspend/resume to driver.SuspendDriver and lifecycle.Service, move native VM close confirmation into internal/host, migrate vm-suspend legacy capability detection, drop moved runtime build tooling, and regenerate i18n and Wails bindings.
50 lines
1.4 KiB
Go
50 lines
1.4 KiB
Go
package app
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
|
|
"github.com/Nwflower/reims-go/internal/driver"
|
|
"github.com/Nwflower/reims-go/internal/i18n"
|
|
"github.com/Nwflower/reims-go/internal/macos/guest"
|
|
"github.com/Nwflower/reims-go/internal/macos/reims"
|
|
rt "github.com/Nwflower/reims-go/internal/runtime"
|
|
)
|
|
|
|
// requireMacOSEnabled refuses native macOS flows while the user has disabled
|
|
// macOS VM Support: its VMs then show as driver_unavailable, and the native
|
|
// pages must not act on them behind the plugin's back. It reads the persisted
|
|
// choice rather than the live driver so startup work racing plugin activation
|
|
// is not refused.
|
|
func (a *App) requireMacOSEnabled() error {
|
|
a.mu.Lock()
|
|
mgr, loc := a.pluginMgr, a.cfg.Locale
|
|
a.mu.Unlock()
|
|
if mgr == nil || mgr.DesiredFor(guest.ID, true) {
|
|
return nil
|
|
}
|
|
return errors.New(i18n.T(i18n.EffectiveLocale(loc), "err.macos.disabled"))
|
|
}
|
|
|
|
func (a *App) client() (*reims.Client, error) {
|
|
if err := a.requireMacOSEnabled(); err != nil {
|
|
return nil, err
|
|
}
|
|
a.mu.Lock()
|
|
cfg := a.cfg
|
|
a.mu.Unlock()
|
|
active, err := rt.ResolveActive(cfg)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("%s", i18n.T(cfg.Locale, "err.runtime_not_installed"))
|
|
}
|
|
return reims.NewClient(cfg, *active), nil
|
|
}
|
|
|
|
func enrichMacOSVMListStates(vms []driver.VMListItem) {
|
|
for i := range vms {
|
|
if vms[i].State == "stopped" && reims.HasSuspendState(vms[i].Dir) {
|
|
vms[i].State = "suspended"
|
|
}
|
|
}
|
|
}
|