allow users to supply custom QEMU firmware path

pull/14283/head
Sharif Elgamal 2022-06-06 12:43:59 -07:00
parent fddd3d9440
commit 9cc18c0aa6
3 changed files with 15 additions and 4 deletions

View File

@ -136,6 +136,7 @@ const (
binaryMirror = "binary-mirror" binaryMirror = "binary-mirror"
disableOptimizations = "disable-optimizations" disableOptimizations = "disable-optimizations"
disableMetrics = "disable-metrics" disableMetrics = "disable-metrics"
qemuFirmwarePath = "qemu-firmware-path"
) )
var ( 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().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().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)") 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 // 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), BinaryMirror: viper.GetString(binaryMirror),
DisableOptimizations: viper.GetBool(disableOptimizations), DisableOptimizations: viper.GetBool(disableOptimizations),
DisableMetrics: viper.GetBool(disableMetrics), DisableMetrics: viper.GetBool(disableMetrics),
CustomQemuFirmwarePath: viper.GetString(qemuFirmwarePath),
KubernetesConfig: config.KubernetesConfig{ KubernetesConfig: config.KubernetesConfig{
KubernetesVersion: k8sVersion, KubernetesVersion: k8sVersion,
ClusterName: ClusterFlagValue(), ClusterName: ClusterFlagValue(),
@ -741,6 +746,7 @@ func updateExistingConfigFromFlags(cmd *cobra.Command, existing *config.ClusterC
updateStringFromFlag(cmd, &cc.MountUID, mountUID) updateStringFromFlag(cmd, &cc.MountUID, mountUID)
updateStringFromFlag(cmd, &cc.BinaryMirror, binaryMirror) updateStringFromFlag(cmd, &cc.BinaryMirror, binaryMirror)
updateBoolFromFlag(cmd, &cc.DisableOptimizations, disableOptimizations) updateBoolFromFlag(cmd, &cc.DisableOptimizations, disableOptimizations)
updateStringFromFlag(cmd, &cc.CustomQemuFirmwarePath, qemuFirmwarePath)
if cmd.Flags().Changed(kubernetesVersion) { if cmd.Flags().Changed(kubernetesVersion) {
cc.KubernetesConfig.KubernetesVersion = getKubernetesVersion(existing) cc.KubernetesConfig.KubernetesVersion = getKubernetesVersion(existing)

View File

@ -101,6 +101,7 @@ type ClusterConfig struct {
BinaryMirror string // Mirror location for kube binaries (kubectl, kubelet, & kubeadm) BinaryMirror string // Mirror location for kube binaries (kubectl, kubelet, & kubeadm)
DisableOptimizations bool DisableOptimizations bool
DisableMetrics bool DisableMetrics bool
CustomQemuFirmwarePath string
} }
// KubernetesConfig contains the parameters used to configure the VM Kubernetes. // KubernetesConfig contains the parameters used to configure the VM Kubernetes.

View File

@ -26,6 +26,7 @@ import (
"runtime" "runtime"
"github.com/docker/machine/libmachine/drivers" "github.com/docker/machine/libmachine/drivers"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/drivers/qemu" "k8s.io/minikube/pkg/drivers/qemu"
"k8s.io/minikube/pkg/minikube/config" "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 arch := runtime.GOARCH
// For macOS, find the correct brew installation path for qemu firmware // For macOS, find the correct brew installation path for qemu firmware
if runtime.GOOS == "darwin" { if runtime.GOOS == "darwin" {
@ -126,7 +130,7 @@ func configure(cc config.ClusterConfig, n config.Node) (interface{}, error) {
default: default:
return nil, fmt.Errorf("unknown arch: %s", runtime.GOARCH) return nil, fmt.Errorf("unknown arch: %s", runtime.GOARCH)
} }
qemuFirmware, err := qemuFirmwarePath() qemuFirmware, err := qemuFirmwarePath(cc.CustomQemuFirmwarePath)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -166,12 +170,12 @@ func status() registry.State {
return registry.State{Error: err, Fix: "Install qemu-system", Doc: docURL} 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 { if err != nil {
return registry.State{Error: err, Doc: docURL} 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} return registry.State{Error: err, Fix: "Install uefi firmware", Doc: docURL}
} }