Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow users to supply custom QEMU firmware path #14283

Merged
merged 2 commits into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cmd/minikube/cmd/start_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ const (
binaryMirror = "binary-mirror"
disableOptimizations = "disable-optimizations"
disableMetrics = "disable-metrics"
qemuFirmwarePath = "qemu-firmware-path"
)

var (
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions pkg/minikube/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 8 additions & 4 deletions pkg/minikube/registry/drvs/qemu2/qemu2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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" {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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}
}

Expand Down