diff --git a/cmd/minikube/cmd/start_flags.go b/cmd/minikube/cmd/start_flags.go index e83a1f59ecb9..261b1af978f8 100644 --- a/cmd/minikube/cmd/start_flags.go +++ b/cmd/minikube/cmd/start_flags.go @@ -136,6 +136,7 @@ const ( binaryMirror = "binary-mirror" disableOptimizations = "disable-optimizations" disableMetrics = "disable-metrics" + qemuFirmwarePath = "qemu-firmware-path" ) var ( @@ -253,6 +254,9 @@ func initDriverFlags() { startCmd.Flags().String(listenAddress, "", "IP Address to use to expose ports (docker and podman driver only)") startCmd.Flags().StringSlice(ports, []string{}, "List of ports that should be exposed (docker and podman driver only)") startCmd.Flags().String(subnet, "", "Subnet to be used on kic cluster. If left empty, minikube will choose subnet address, beginning from 192.168.49.0. (docker and podman driver only)") + + // qemu + startCmd.Flags().String(qemuFirmwarePath, "", "Path to the qemu firmware file. Defaults: For Linux, the default firmware location. For macOS, the brew installation location. For Windows, C:\\Program Files\\qemu\\share") } // initNetworkingFlags inits the commandline flags for connectivity related flags for start @@ -523,6 +527,7 @@ func generateNewConfigFromFlags(cmd *cobra.Command, k8sVersion string, rtime str BinaryMirror: viper.GetString(binaryMirror), DisableOptimizations: viper.GetBool(disableOptimizations), DisableMetrics: viper.GetBool(disableMetrics), + CustomQemuFirmwarePath: viper.GetString(qemuFirmwarePath), KubernetesConfig: config.KubernetesConfig{ KubernetesVersion: k8sVersion, ClusterName: ClusterFlagValue(), @@ -741,6 +746,7 @@ func updateExistingConfigFromFlags(cmd *cobra.Command, existing *config.ClusterC updateStringFromFlag(cmd, &cc.MountUID, mountUID) updateStringFromFlag(cmd, &cc.BinaryMirror, binaryMirror) updateBoolFromFlag(cmd, &cc.DisableOptimizations, disableOptimizations) + updateStringFromFlag(cmd, &cc.CustomQemuFirmwarePath, qemuFirmwarePath) if cmd.Flags().Changed(kubernetesVersion) { cc.KubernetesConfig.KubernetesVersion = getKubernetesVersion(existing) diff --git a/pkg/minikube/config/types.go b/pkg/minikube/config/types.go index c27454d2bdb4..0faaabec372e 100644 --- a/pkg/minikube/config/types.go +++ b/pkg/minikube/config/types.go @@ -101,6 +101,7 @@ type ClusterConfig struct { BinaryMirror string // Mirror location for kube binaries (kubectl, kubelet, & kubeadm) DisableOptimizations bool DisableMetrics bool + CustomQemuFirmwarePath string } // KubernetesConfig contains the parameters used to configure the VM Kubernetes. diff --git a/pkg/minikube/registry/drvs/qemu2/qemu2.go b/pkg/minikube/registry/drvs/qemu2/qemu2.go index 5cd70e58f1e3..7871bb3d41fa 100644 --- a/pkg/minikube/registry/drvs/qemu2/qemu2.go +++ b/pkg/minikube/registry/drvs/qemu2/qemu2.go @@ -26,6 +26,7 @@ import ( "runtime" "github.com/docker/machine/libmachine/drivers" + "github.com/spf13/viper" "k8s.io/minikube/pkg/drivers/qemu" "k8s.io/minikube/pkg/minikube/config" @@ -64,7 +65,10 @@ func qemuSystemProgram() (string, error) { } } -func qemuFirmwarePath() (string, error) { +func qemuFirmwarePath(customPath string) (string, error) { + if customPath != "" { + return customPath, nil + } arch := runtime.GOARCH // For macOS, find the correct brew installation path for qemu firmware if runtime.GOOS == "darwin" { @@ -126,7 +130,7 @@ func configure(cc config.ClusterConfig, n config.Node) (interface{}, error) { default: return nil, fmt.Errorf("unknown arch: %s", runtime.GOARCH) } - qemuFirmware, err := qemuFirmwarePath() + qemuFirmware, err := qemuFirmwarePath(cc.CustomQemuFirmwarePath) if err != nil { return nil, err } @@ -166,12 +170,12 @@ func status() registry.State { return registry.State{Error: err, Fix: "Install qemu-system", Doc: docURL} } - qemuFirmware, err := qemuFirmwarePath() + qemuFirmware, err := qemuFirmwarePath(viper.GetString("qemu-firmware-path")) if err != nil { return registry.State{Error: err, Doc: docURL} } - if _, err := os.Stat(qemuFirmware); err != nil && runtime.GOARCH == "arm64" { + if _, err := os.Stat(qemuFirmware); err != nil { return registry.State{Error: err, Fix: "Install uefi firmware", Doc: docURL} }