Backend - Per-VM CPU affinity (vmstart/affinity.go, affinity_flow.go): modes auto / all / P-cores / non-LP-E / custom, saved in the VM folder, applied to the QEMU process on start (GUI and CLI) and live via SetVMAffinity; copied on clone. Start summary logs the resolved mapping. Host report gains CPU topology helpers (mask <-> CPU list). - Offline qcow2 restore points via qemu-img (driver/reims/snapshot.go, snapshot_flow.go): list / create / restore / delete. - SSH helpers (ssh_flow.go): remembered user, open a terminal, write an ~/.ssh/config entry, open VS Code Remote-SSH. - FocusVMWindow brings the QEMU window forward (restoring it if minimized); CopyVMScreenshot copies a full-resolution frame to the clipboard. - DeliverPathsToGuest copies dropped host files into the shared folder; main.go enables Wails file drop on elements marked --wails-drop-target. - VM note (.reims-go-note) and a storage breakdown (extras_flow.go). Frontend - VM page: running state's "Show Window" and the screen preview use FocusVMWindow; camera button and More-menu item copy a screenshot; editable note under the name; SSH row shows the saved user with Terminal / config / VS Code actions; restore-point list; install guide steps can be ticked off; drop files onto the page to send them. - Sidebar right-click menu per VM (start, show window, screenshot, stop, restart, settings, folders, clone, delete); double-click and Ctrl+Enter still run the main action. - AffinityDialog opened from the VM menu and VM settings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
92 lines
2.6 KiB
Go
92 lines
2.6 KiB
Go
package app
|
|
|
|
import (
|
|
"fmt"
|
|
"path/filepath"
|
|
"sort"
|
|
"strings"
|
|
|
|
"github.com/Nwflower/reims-go/internal/driver/reims"
|
|
rt "github.com/Nwflower/reims-go/internal/runtime"
|
|
wailsRuntime "github.com/wailsapp/wails/v2/pkg/runtime"
|
|
)
|
|
|
|
// ListSnapshots returns all internal qcow2 restore points for a VM, newest first.
|
|
func (a *App) ListSnapshots(name string) ([]reims.DiskSnapshot, error) {
|
|
a.mu.Lock()
|
|
cfgCopy := *a.cfg
|
|
a.mu.Unlock()
|
|
active, err := rt.ResolveActive(&cfgCopy)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
d, err := a.GetVMDetail(name)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
diskPath := resolveVMDiskPath(d)
|
|
if diskPath == "" || !strings.EqualFold(filepath.Ext(diskPath), ".qcow2") {
|
|
return nil, nil
|
|
}
|
|
env := rt.BuildChildEnv(&cfgCopy, *active)
|
|
snaps, err := reims.ListDiskSnapshots(a.baseCtx(), active.QemuImgPath(), env, diskPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
sort.SliceStable(snaps, func(i, j int) bool {
|
|
return snaps[i].CreatedAt > snaps[j].CreatedAt
|
|
})
|
|
return snaps, nil
|
|
}
|
|
|
|
// CreateSnapshot creates a named offline restore point inside a stopped VM's qcow2 disk.
|
|
func (a *App) CreateSnapshot(name, snapName string) error {
|
|
return a.runSnapshotOp(name, "-c", snapName, "Created restore point")
|
|
}
|
|
|
|
// RestoreSnapshot rolls back a stopped VM's qcow2 disk to the named restore point.
|
|
func (a *App) RestoreSnapshot(name, snapName string) error {
|
|
return a.runSnapshotOp(name, "-a", snapName, "Restored restore point")
|
|
}
|
|
|
|
// DeleteSnapshot removes a named restore point from a stopped VM's qcow2 disk.
|
|
func (a *App) DeleteSnapshot(name, snapName string) error {
|
|
return a.runSnapshotOp(name, "-d", snapName, "Deleted restore point")
|
|
}
|
|
|
|
func (a *App) runSnapshotOp(name, flag, snapName, verb string) error {
|
|
a.mu.Lock()
|
|
cfgCopy := *a.cfg
|
|
a.mu.Unlock()
|
|
active, err := rt.ResolveActive(&cfgCopy)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
c := reims.NewClient(&cfgCopy, *active)
|
|
ctx := a.baseCtx()
|
|
|
|
d, err := a.GetVMDetail(name)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if a.isVMRunning(ctx, c, name, d) {
|
|
return fmt.Errorf("stop %s before managing restore points", name)
|
|
}
|
|
diskPath := resolveVMDiskPath(d)
|
|
if diskPath == "" {
|
|
return fmt.Errorf("VM %s has no disk path", name)
|
|
}
|
|
if !strings.EqualFold(filepath.Ext(diskPath), ".qcow2") {
|
|
return fmt.Errorf("restore points are only supported on .qcow2 disks")
|
|
}
|
|
env := rt.BuildChildEnv(&cfgCopy, *active)
|
|
if err := reims.RunDiskSnapshot(ctx, active.QemuImgPath(), env, flag, snapName, diskPath); err != nil {
|
|
return err
|
|
}
|
|
a.emitLog(name, fmt.Sprintf("%s %q", verb, strings.TrimSpace(snapName)))
|
|
if a.ctx != nil {
|
|
wailsRuntime.EventsEmit(a.ctx, "reims:state-changed", true)
|
|
}
|
|
return nil
|
|
}
|