Merge branch 'master' of github.com:AlexSSD7/linsk

This commit is contained in:
AlexSSD7 2023-08-31 16:24:03 +01:00
commit ba426c0c9e
2 changed files with 21 additions and 14 deletions

View file

@ -33,9 +33,6 @@ func checkIfRoot() (bool, error) {
func doUSBRootCheck() { func doUSBRootCheck() {
switch runtime.GOOS { switch runtime.GOOS {
case "darwin":
// Root privileges is not required in macOS.
return
case "windows": case "windows":
// Administrator privileges are not required in Windows. // Administrator privileges are not required in Windows.
return return

View file

@ -112,29 +112,39 @@ func NewVM(logger *slog.Logger, cfg VMConfig) (*VM, error) {
baseCmd := "qemu-system" baseCmd := "qemu-system"
switch runtime.GOARCH { var accel string
case "amd64": switch runtime.GOOS {
accel := "kvm" case "windows":
if runtime.GOOS == "windows" { // TODO: whpx accel is broken in Windows. Long term solution looks to be use Hyper-V.
// For Windows, we need to install QEMU using an installer and add it to PATH. // For Windows, we need to install QEMU using an installer and add it to PATH.
// Then, we should enable Windows Hypervisor Platform in "Turn Windows features on or off". // Then, we should enable Windows Hypervisor Platform in "Turn Windows features on or off".
// IMPORTANT: We should also install libusbK drivers for USB devices we want to pass through. // IMPORTANT: We should also install libusbK drivers for USB devices we want to pass through.
// This can be easily done with a program called Zadiag by Akeo. // This can be easily done with a program called Zadiag by Akeo.
accel = "whpx,kernel-irqchip=off" accel = "whpx,kernel-irqchip=off"
case "darwin":
accel = "hvf"
default:
accel = "kvm"
} }
cmdArgs = append(cmdArgs, "-accel", accel) switch runtime.GOARCH {
case "amd64":
baseCmd += "-x86_64" baseCmd += "-x86_64"
case "arm64": case "arm64":
if cfg.BIOSPath == "" { if cfg.BIOSPath == "" {
logger.Warn("BIOS image path is not specified while attempting to run an aarch64 (arm64) VM. The VM will not boot.") logger.Warn("BIOS image path is not specified while attempting to run an aarch64 (arm64) VM. The VM will not boot.")
} }
cmdArgs = append(cmdArgs, "-accel", "hvf", "-M", "virt,highmem=off", "-cpu", "cortex-a57")
// ",highmem=off" is required for M1.
cmdArgs = append(cmdArgs, "-M", "virt,highmem=off", "-cpu", "host")
baseCmd += "-aarch64" baseCmd += "-aarch64"
default: default:
return nil, fmt.Errorf("arch '%v' is not supported", runtime.GOARCH) return nil, fmt.Errorf("arch '%v' is not supported", runtime.GOARCH)
} }
cmdArgs = append(cmdArgs, "-accel", accel)
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
baseCmd += ".exe" baseCmd += ".exe"
} }