Some OS-specific adjustments
This commit is contained in:
parent
c31f193096
commit
7f13a79c9b
2 changed files with 21 additions and 14 deletions
|
|
@ -32,9 +32,6 @@ func checkIfRoot() (bool, error) {
|
|||
|
||||
func doUSBRootCheck() {
|
||||
switch runtime.GOOS {
|
||||
case "darwin":
|
||||
// Root privileges is not required in macOS.
|
||||
return
|
||||
case "windows":
|
||||
// Administrator privileges are not required in Windows.
|
||||
return
|
||||
|
|
|
|||
32
vm/vm.go
32
vm/vm.go
|
|
@ -104,29 +104,39 @@ func NewVM(logger *slog.Logger, cfg VMConfig) (*VM, error) {
|
|||
|
||||
baseCmd := "qemu-system"
|
||||
|
||||
var accel string
|
||||
switch runtime.GOOS {
|
||||
case "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.
|
||||
// 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.
|
||||
// This can be easily done with a program called Zadiag by Akeo.
|
||||
accel = "whpx,kernel-irqchip=off"
|
||||
case "darwin":
|
||||
accel = "hvf"
|
||||
default:
|
||||
accel = "kvm"
|
||||
}
|
||||
|
||||
switch runtime.GOARCH {
|
||||
case "amd64":
|
||||
accel := "kvm"
|
||||
if runtime.GOOS == "windows" {
|
||||
// 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".
|
||||
// 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.
|
||||
accel = "whpx,kernel-irqchip=off"
|
||||
}
|
||||
|
||||
cmdArgs = append(cmdArgs, "-accel", accel)
|
||||
baseCmd += "-x86_64"
|
||||
case "arm64":
|
||||
if cfg.BIOSPath == "" {
|
||||
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"
|
||||
default:
|
||||
return nil, fmt.Errorf("arch '%v' is not supported", runtime.GOARCH)
|
||||
}
|
||||
|
||||
cmdArgs = append(cmdArgs, "-accel", accel)
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
baseCmd += ".exe"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue