diff --git a/cmd/utils.go b/cmd/utils.go index 1ce515a..96d48fa 100644 --- a/cmd/utils.go +++ b/cmd/utils.go @@ -78,6 +78,12 @@ func runVM(passthroughArg string, fn func(context.Context, *vm.VM, *vm.FileManag os.Exit(1) } + biosPath, err := store.CheckDownloadVMBIOS() + if err != nil { + slog.Error("Failed to check/download VM BIOS", "error", err) + os.Exit(1) + } + var passthroughConfig vm.PassthroughConfig if passthroughArg != "" { @@ -92,6 +98,7 @@ func runVM(passthroughArg string, fn func(context.Context, *vm.VM, *vm.FileManag }}, MemoryAlloc: vmMemAllocFlag, + BIOSPath: biosPath, PassthroughConfig: passthroughConfig, ExtraPortForwardingRules: forwardPortsRules, diff --git a/constants/arch.go b/constants/arch.go deleted file mode 100644 index 9baf32f..0000000 --- a/constants/arch.go +++ /dev/null @@ -1,14 +0,0 @@ -package constants - -import "runtime" - -func GetUnixWorkArch() string { - arch := "x86_64" - if runtime.GOOS == "arm64" { - arch = "arm64" - } - - // CPU architectures other than amd64 and arm64 are not yet natively supported. - // Running on a non-officially-supported arch will result in use of x86_64 VM. - return arch -} diff --git a/constants/image.go b/constants/image.go index f312192..1cb9bb1 100644 --- a/constants/image.go +++ b/constants/image.go @@ -19,7 +19,7 @@ var alpineBaseImageHash []byte func init() { baseAlpineArch = "x86_64" alpineBaseImageHash = utils.MustDecodeHex("925f6bc1039a0abcd0548d2c3054d54dce31cfa03c7eeba22d10d85dc5817c98") - if runtime.GOOS == "arm64" { + if runtime.GOARCH == "arm64" { baseAlpineArch = "aarch64" alpineBaseImageHash = utils.MustDecodeHex("c94593729e4577650d9e73ada28e3cbe56964ab2a27240364f8616e920ed6d4e") } diff --git a/storage/storage.go b/storage/storage.go index c0d7c41..cd34bfb 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -81,9 +81,9 @@ func (s *Storage) BuildVMImageWithInterruptHandler(showBuilderVMDisplay bool, ov return errors.Wrap(err, "check/download base image") } - biosPath, err := s.CheckDownloadCPUArchSpecifics() + biosPath, err := s.CheckDownloadVMBIOS() if err != nil { - return errors.Wrap(err, "check/download cpu arch specifics") + return errors.Wrap(err, "check/download vm bios") } s.logger.Info("Building VM image", "tags", constants.GetAlpineBaseImageTags(), "overwriting", removed, "dst", vmImagePath) @@ -116,7 +116,7 @@ func (s *Storage) DataDirPath() string { return s.path } -func (s *Storage) CheckDownloadCPUArchSpecifics() (string, error) { +func (s *Storage) CheckDownloadVMBIOS() (string, error) { if runtime.GOARCH == "arm64" { p, err := s.CheckDownloadAarch64EFIImage() if err != nil { @@ -126,6 +126,8 @@ func (s *Storage) CheckDownloadCPUArchSpecifics() (string, error) { return p, nil } + // On x86_64, there is no requirement to supply QEMU with any BIOS images. + return "", nil } diff --git a/vm/vm.go b/vm/vm.go index 67714d0..7632e44 100644 --- a/vm/vm.go +++ b/vm/vm.go @@ -168,7 +168,13 @@ func NewVM(logger *slog.Logger, cfg VMConfig) (*VM, error) { driveArgs += ",snapshot=on" } - cmdArgs = append(cmdArgs, "-drive", driveArgs, "-device", "virtio-blk-pci,drive=disk"+fmt.Sprint(i)+",bootindex="+fmt.Sprint(i)) + devArgs := "virtio-blk-pci,drive=disk" + fmt.Sprint(i) + + if cfg.CdromImagePath == "" { + devArgs += ",bootindex=" + fmt.Sprint(i) + } + + cmdArgs = append(cmdArgs, "-drive", driveArgs, "-device", devArgs) } if len(cfg.PassthroughConfig.USB) != 0 {