From 5e46208ed433f2015f5e2c7c306e05485f9bfbd4 Mon Sep 17 00:00:00 2001 From: Predrag Rogic Date: Mon, 17 Apr 2023 23:56:30 +0100 Subject: [PATCH 1/9] add support for 'vmnet-*' networks in qemu with root privs --- cmd/minikube/cmd/start_flags.go | 4 +++- pkg/drivers/qemu/qemu.go | 36 ++++++++++++++++++++++++++++----- pkg/minikube/cluster/ip.go | 4 ++-- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/cmd/minikube/cmd/start_flags.go b/cmd/minikube/cmd/start_flags.go index aac3a8a270b9..49bce3e0f682 100644 --- a/cmd/minikube/cmd/start_flags.go +++ b/cmd/minikube/cmd/start_flags.go @@ -473,6 +473,8 @@ func getNetwork(driverName string) string { return n } switch n { + case "vmnet-host", "vmnet-shared", "vmnet-bridged": + //TODO: check if QEMU v7.1+ version is installed case "socket_vmnet": if runtime.GOOS != "darwin" { exit.Message(reason.Usage, "The socket_vmnet network is only supported on macOS") @@ -491,7 +493,7 @@ func getNetwork(driverName string) string { n = "builtin" case "builtin": default: - exit.Message(reason.Usage, "--network with QEMU must be 'builtin' or 'socket_vmnet'") + exit.Message(reason.Usage, "--network with QEMU must be 'builtin' (aka 'user') or 'socket_vmnet', and for QEMU v7.1+, it can also be 'vmnet-host', 'vmnet-shared' or 'vmnet-bridged'") } if n == "builtin" { msg := "You are using the QEMU driver without a dedicated network, which doesn't support `minikube service` & `minikube tunnel` commands." diff --git a/pkg/drivers/qemu/qemu.go b/pkg/drivers/qemu/qemu.go index 5ccc8659da71..01db801bf551 100644 --- a/pkg/drivers/qemu/qemu.go +++ b/pkg/drivers/qemu/qemu.go @@ -26,6 +26,7 @@ import ( "net" "os" "os/exec" + "os/user" "path/filepath" "runtime" "strconv" @@ -176,7 +177,11 @@ func checkPid(pid int) error { if err != nil { return err } - return process.Signal(syscall.Signal(0)) + // when user sends a signal to an existing privileged process, "operation not permitted" error is returned, but the process exists, which is all we care about here + if err = process.Signal(syscall.Signal(0)); strings.Contains(err.Error(), "operation not permitted") { + return nil + } + return err } func (d *Driver) GetState() (state.State, error) { @@ -254,7 +259,7 @@ func (d *Driver) Create() error { } break } - case "socket_vmnet": + case "socket_vmnet", "vmnet-host", "vmnet-shared", "vmnet-bridged": d.SSHPort, err = d.GetSSHPort() if err != nil { return err @@ -366,7 +371,7 @@ func getAvailableTCPPortFromRange(minPort, maxPort int) (int, error) { return 0, fmt.Errorf("unable to allocate tcp port") } -func (d *Driver) Start() error { +func (d *Driver) Start() error { //nolint to suppress cyclomatic complexity 31 is high (> 30) (gocyclo) machineDir := filepath.Join(d.StorePath, "machines", d.GetMachineName()) var startCmd []string @@ -446,6 +451,10 @@ func (d *Driver) Start() error { startCmd = append(startCmd, "-device", fmt.Sprintf("virtio-net-pci,netdev=net0,mac=%s", d.MACAddress), "-netdev", "socket,id=net0,fd=3", ) + case "vmnet-host", "vmnet-shared", "vmnet-bridged": + startCmd = append(startCmd, + "-netdev", fmt.Sprintf("%s,id=net0,isolated=off", d.Network), "-device", fmt.Sprintf("virtio-net-pci,netdev=net0,mac=%s", d.MACAddress), + ) default: return fmt.Errorf("unknown network: %s", d.Network) } @@ -482,13 +491,20 @@ func (d *Driver) Start() error { d.diskPath()) } - // If socket network, start with socket_vmnet. + // for "socket_vmnet" network, start with socket_vmnet startProgram := d.Program if d.Network == "socket_vmnet" { startProgram = d.SocketVMNetClientPath startCmd = append([]string{d.SocketVMNetPath, d.Program}, startCmd...) } + // "vmnet-*" network requires elevated privileges + if strings.HasPrefix(d.Network, "vmnet-") { + //TODO: handle windows + startProgram = "sudo" + startCmd = append([]string{d.Program}, startCmd...) + } + startFunc := cmdOutErr if runtime.GOOS == "windows" { startFunc = cmdStart @@ -502,7 +518,17 @@ func (d *Driver) Start() error { switch d.Network { case "builtin", "user": d.IPAddress = "127.0.0.1" - case "socket_vmnet": + case "socket_vmnet", "vmnet-host", "vmnet-shared", "vmnet-bridged": + // for "vmnet-*" network, we need to restore user's access to qemu.pid and monitor in minikube's home dir + if strings.HasPrefix(d.Network, "vmnet-") { + if user, err := user.Current(); err != nil { + log.Errorf("cannot get current user and thus cannot take ownership of %s and %s (continuing anyway, but will likely fail): %v", d.pidfilePath(), d.monitorPath(), err) + } else if stdout, stderr, err := startFunc("sudo", "chown", user.Username, d.pidfilePath(), d.monitorPath()); err != nil { + fmt.Printf("OUTPUT: %s\n", stdout) + fmt.Printf("ERROR: %s\n", stderr) + } + } + var err error getIP := func() error { d.IPAddress, err = pkgdrivers.GetIPAddressByMACAddress(d.MACAddress) diff --git a/pkg/minikube/cluster/ip.go b/pkg/minikube/cluster/ip.go index 1f28d50c2083..f1ef431d55fc 100644 --- a/pkg/minikube/cluster/ip.go +++ b/pkg/minikube/cluster/ip.go @@ -67,8 +67,8 @@ func HostIP(host *host.Host, clusterName string) (net.IP, error) { // user network case return net.ParseIP("10.0.2.2"), nil } - // socket_vmnet network case - return net.ParseIP("192.168.105.1"), nil + // "socket_vmnet" and "vmnet-*" network case + return net.ParseIP(ipString), nil case driver.HyperV: v := reflect.ValueOf(host.Driver).Elem() var hypervVirtualSwitch string From 7037a8b7869843977dad159d8d07c48118be8b65 Mon Sep 17 00:00:00 2001 From: Predrag Rogic Date: Tue, 18 Apr 2023 01:07:24 +0100 Subject: [PATCH 2/9] fix nil err handling --- pkg/drivers/qemu/qemu.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/drivers/qemu/qemu.go b/pkg/drivers/qemu/qemu.go index 01db801bf551..45943bb9f1ad 100644 --- a/pkg/drivers/qemu/qemu.go +++ b/pkg/drivers/qemu/qemu.go @@ -178,7 +178,7 @@ func checkPid(pid int) error { return err } // when user sends a signal to an existing privileged process, "operation not permitted" error is returned, but the process exists, which is all we care about here - if err = process.Signal(syscall.Signal(0)); strings.Contains(err.Error(), "operation not permitted") { + if err = process.Signal(syscall.Signal(0)); err == nil || strings.Contains(err.Error(), "operation not permitted") { return nil } return err From 563a98c461356b22125c11d428b1a3f1bb1de723 Mon Sep 17 00:00:00 2001 From: Predrag Rogic Date: Tue, 18 Apr 2023 01:20:22 +0100 Subject: [PATCH 3/9] fix HostIP --- pkg/minikube/cluster/ip.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/minikube/cluster/ip.go b/pkg/minikube/cluster/ip.go index f1ef431d55fc..80df02728c42 100644 --- a/pkg/minikube/cluster/ip.go +++ b/pkg/minikube/cluster/ip.go @@ -67,8 +67,12 @@ func HostIP(host *host.Host, clusterName string) (net.IP, error) { // user network case return net.ParseIP("10.0.2.2"), nil } - // "socket_vmnet" and "vmnet-*" network case - return net.ParseIP(ipString), nil + // "socket_vmnet" and "vmnet-*" network case: host ip should be start address of subnet + vmIP := net.ParseIP(ipString).To4() + if vmIP == nil { + return []byte{}, errors.Wrap(err, "Error converting VM IP address to IPv4 address") + } + return net.IPv4(vmIP[0], vmIP[1], vmIP[2], byte(1)), nil case driver.HyperV: v := reflect.ValueOf(host.Driver).Elem() var hypervVirtualSwitch string From cd90520a6c0abffdeb0a2fcfba3cfe6b8bde751a Mon Sep 17 00:00:00 2001 From: Predrag Rogic Date: Tue, 18 Apr 2023 20:05:30 +0100 Subject: [PATCH 4/9] add sudo password handling --- cmd/minikube/cmd/start_flags.go | 3 ++ pkg/drivers/qemu/qemu.go | 67 +++++++++++++++++++++++++++++---- pkg/minikube/cluster/ip.go | 2 +- translations/de.json | 2 + translations/es.json | 3 +- translations/fr.json | 2 + translations/ja.json | 2 + translations/ko.json | 2 + translations/pl.json | 3 +- translations/ru.json | 3 +- translations/strings.txt | 5 ++- translations/zh-CN.json | 2 + 12 files changed, 82 insertions(+), 14 deletions(-) diff --git a/cmd/minikube/cmd/start_flags.go b/cmd/minikube/cmd/start_flags.go index 49bce3e0f682..22e7b7cf768e 100644 --- a/cmd/minikube/cmd/start_flags.go +++ b/cmd/minikube/cmd/start_flags.go @@ -475,6 +475,9 @@ func getNetwork(driverName string) string { switch n { case "vmnet-host", "vmnet-shared", "vmnet-bridged": //TODO: check if QEMU v7.1+ version is installed + if runtime.GOOS == "windows" { + exit.Message(reason.Usage, "The vmnet network is not yet supported on windows") + } case "socket_vmnet": if runtime.GOOS != "darwin" { exit.Message(reason.Usage, "The socket_vmnet network is only supported on macOS") diff --git a/pkg/drivers/qemu/qemu.go b/pkg/drivers/qemu/qemu.go index 45943bb9f1ad..a80d8e31eafb 100644 --- a/pkg/drivers/qemu/qemu.go +++ b/pkg/drivers/qemu/qemu.go @@ -18,6 +18,7 @@ package qemu import ( "archive/tar" + "bufio" "bytes" "encoding/json" "fmt" @@ -491,18 +492,18 @@ func (d *Driver) Start() error { //nolint to suppress cyclomatic complexity 31 i d.diskPath()) } - // for "socket_vmnet" network, start with socket_vmnet + // for socket_vmnet network, start with socket_vmnet startProgram := d.Program if d.Network == "socket_vmnet" { startProgram = d.SocketVMNetClientPath startCmd = append([]string{d.SocketVMNetPath, d.Program}, startCmd...) } - // "vmnet-*" network requires elevated privileges + // vmnet network requires elevated privileges if strings.HasPrefix(d.Network, "vmnet-") { //TODO: handle windows startProgram = "sudo" - startCmd = append([]string{d.Program}, startCmd...) + startCmd = append([]string{"-S", d.Program}, startCmd...) } startFunc := cmdOutErr @@ -519,11 +520,11 @@ func (d *Driver) Start() error { //nolint to suppress cyclomatic complexity 31 i case "builtin", "user": d.IPAddress = "127.0.0.1" case "socket_vmnet", "vmnet-host", "vmnet-shared", "vmnet-bridged": - // for "vmnet-*" network, we need to restore user's access to qemu.pid and monitor in minikube's home dir + // for vmnet network, we need to restore user's access to qemu.pid and monitor in minikube's home dir if strings.HasPrefix(d.Network, "vmnet-") { if user, err := user.Current(); err != nil { log.Errorf("cannot get current user and thus cannot take ownership of %s and %s (continuing anyway, but will likely fail): %v", d.pidfilePath(), d.monitorPath(), err) - } else if stdout, stderr, err := startFunc("sudo", "chown", user.Username, d.pidfilePath(), d.monitorPath()); err != nil { + } else if stdout, stderr, err := startFunc("sudo", "-S", "chown", user.Username, d.pidfilePath(), d.monitorPath()); err != nil { fmt.Printf("OUTPUT: %s\n", stdout) fmt.Printf("ERROR: %s\n", stderr) } @@ -592,11 +593,61 @@ func isBootpdError(err error) bool { func cmdOutErr(cmdStr string, args ...string) (string, string, error) { cmd := exec.Command(cmdStr, args...) log.Debugf("executing: %s %s", cmdStr, strings.Join(args, " ")) + + var err error + + // allow using ROOT_PASSWORD env var for ci/cd automation, if present + // otherwise, prompt user to enter root password without echoing it using os.Stdin + var stdin io.WriteCloser + cmd.Stdin = os.Stdin + secret, found := os.LookupEnv("ROOT_PASSWORD") + if found { + cmd.Stdin = nil // unset to avoid "Stdin already set" error + if stdin, err = cmd.StdinPipe(); err != nil { + return "", "", fmt.Errorf("cannont create StdinPipe: %v", err) + } + } + var stdout bytes.Buffer - var stderr bytes.Buffer cmd.Stdout = &stdout - cmd.Stderr = &stderr - err := cmd.Run() + + // try detecting password prompt for sudo in StdErr (sudo has to be run with '-S' flag for this to work), + // while preserving original StdErr content by using tee reader + var stderr bytes.Buffer + errPipe, err := cmd.StderrPipe() + if err != nil { + return "", "", fmt.Errorf("cannont create StderrPipe: %v", err) + } + errTee := io.TeeReader(errPipe, &stderr) + + go func() { + var buf []byte + r := bufio.NewReader(errTee) + for { + b, err := r.ReadByte() + if err != nil && !errors.Is(err, io.EOF) && !errors.Is(err, os.ErrClosed) { + log.Errorf("reading from stderr failed: %v", err) + break + } + buf = append(buf, b) + + // macOS has "Password:" and Linux has "[sudo] password for root:" prompt + if strings.Contains(string(buf), "assword") && strings.HasSuffix(string(buf), ":") { + // try ROOT_PASSWORD first, if one exists + if stdin != nil { + if _, err := io.WriteString(stdin, fmt.Sprintf("%s\n", secret)); err != nil { + log.Errorf("writing to stdin failed: %v", err) + break + } + continue + } + // alternatively, use os.Stdin for prompt + fmt.Printf("\n[sudo] password for root: ") + } + } + }() + + err = cmd.Run() stdoutStr := stdout.String() stderrStr := stderr.String() log.Debugf("STDOUT: %s", stdoutStr) diff --git a/pkg/minikube/cluster/ip.go b/pkg/minikube/cluster/ip.go index 80df02728c42..dcdd86c001cc 100644 --- a/pkg/minikube/cluster/ip.go +++ b/pkg/minikube/cluster/ip.go @@ -67,7 +67,7 @@ func HostIP(host *host.Host, clusterName string) (net.IP, error) { // user network case return net.ParseIP("10.0.2.2"), nil } - // "socket_vmnet" and "vmnet-*" network case: host ip should be start address of subnet + // socket_vmnet and vmnet network case: host ip should be start address of subnet vmIP := net.ParseIP(ipString).To4() if vmIP == nil { return []byte{}, errors.Wrap(err, "Error converting VM IP address to IPv4 address") diff --git a/translations/de.json b/translations/de.json index 05feaaa325bf..72685f20305d 100644 --- a/translations/de.json +++ b/translations/de.json @@ -24,6 +24,7 @@ "--kvm-numa-count range is 1-8": "Der Wertebereich für --kvm-numa-count ist 1-8", "--network flag is only valid with the docker/podman and KVM drivers, it will be ignored": "Der Parameter --network kann nur mit dem docker/podman und den KVM Treibern verwendet werden, er wird ignoriert werden", "--network flag is only valid with the docker/podman, KVM and Qemu drivers, it will be ignored": "--network flag kann nur mit docker/podman, KVM und Qemu Treibern verwendet werden", + "--network with QEMU must be 'builtin' (aka 'user') or 'socket_vmnet', and for QEMU v7.1+, it can also be 'vmnet-host', 'vmnet-shared' or 'vmnet-bridged'": "", "--network with QEMU must be 'builtin' or 'socket_vmnet'": "--network muss entweder 'builtin' oder 'socket_vmnet' enthalten, wenn der QEMU Treiber verwendet wird", "--static-ip is only implemented on Docker and Podman drivers, flag will be ignored": "--static-ip ist nur für Docker und Podman Treiber implementiert, der Parameter wird ignoriert", "--static-ip overrides --subnet, --subnet will be ignored": "--static-ip überschreibt --subnet, --subnet wird ignoriert werden", @@ -809,6 +810,7 @@ "The total number of nodes to spin up. Defaults to 1.": "Die Gesamtzahl der zu startenden Nodes. Default: 1.", "The value passed to --format is invalid": "Der mit --format angegebene Wert ist ungültig", "The value passed to --format is invalid: {{.error}}": "Der mit --format angegebene Wert ist ungültig: {{.error}}", + "The vmnet network is not yet supported on windows": "", "The {{.addon}} addon is only supported with the KVM driver.\n\nFor GPU setup instructions see: https://minikube.sigs.k8s.io/docs/tutorials/nvidia/": "", "The {{.driver_name}} driver should not be used with root privileges.": "Der Treiber {{.driver_name}} sollte nicht mit Root-Rechten verwendet werden.", "There are a couple ways to enable the required file sharing:\n1. Enable \"Use the WSL 2 based engine\" in Docker Desktop\nor\n2. Enable file sharing in Docker Desktop for the %s%s directory": "Es gibt mehrere Möglichkeiten das benötigte File-Sharing zu aktivieren:\n1. Aktiviere \"Use the WSL 2 based engine\" in Docker Desktop\noder\n2. Aktiviere File-Sharing in Docker Desktop für das %s%s Verzeichnis", diff --git a/translations/es.json b/translations/es.json index 46f4a453cd92..c4d4b1e4487a 100644 --- a/translations/es.json +++ b/translations/es.json @@ -25,7 +25,7 @@ "--kvm-numa-count range is 1-8": "--kvm-numa-count el rango es 1-8", "--network flag is only valid with the docker/podman and KVM drivers, it will be ignored": "el flag --network es válido solamente con docker/podman y KVM, será ignorado", "--network flag is only valid with the docker/podman, KVM and Qemu drivers, it will be ignored": "", - "--network with QEMU must be 'builtin' or 'socket_vmnet'": "", + "--network with QEMU must be 'builtin' (aka 'user') or 'socket_vmnet', and for QEMU v7.1+, it can also be 'vmnet-host', 'vmnet-shared' or 'vmnet-bridged'": "", "--static-ip is only implemented on Docker and Podman drivers, flag will be ignored": "", "--static-ip overrides --subnet, --subnet will be ignored": "", "1) Recreate the cluster with Kubernetes {{.new}}, by running:\n\t \n\t\t minikube delete{{.profile}}\n\t\t minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t2) Create a second cluster with Kubernetes {{.new}}, by running:\n\t \n\t\t minikube start -p {{.suggestedName}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t3) Use the existing cluster at version Kubernetes {{.old}}, by running:\n\t \n\t\t minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.old}}\n\t\t": "", @@ -786,6 +786,7 @@ "The total number of nodes to spin up. Defaults to 1.": "", "The value passed to --format is invalid": "", "The value passed to --format is invalid: {{.error}}": "", + "The vmnet network is not yet supported on windows": "", "The {{.addon}} addon is only supported with the KVM driver.\n\nFor GPU setup instructions see: https://minikube.sigs.k8s.io/docs/tutorials/nvidia/": "", "The {{.driver_name}} driver should not be used with root privileges.": "El controlador {{.driver_name}} no se debe utilizar con privilegios de raíz.", "There are a couple ways to enable the required file sharing:\n1. Enable \"Use the WSL 2 based engine\" in Docker Desktop\nor\n2. Enable file sharing in Docker Desktop for the %s%s directory": "", diff --git a/translations/fr.json b/translations/fr.json index a1f4f274cefc..bb9fba2e3ad9 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -25,6 +25,7 @@ "--kvm-numa-count range is 1-8": "la tranche de --kvm-numa-count est 1 à 8", "--network flag is only valid with the docker/podman and KVM drivers, it will be ignored": "l'indicateur --network est valide uniquement avec les pilotes docker/podman et KVM, il va être ignoré", "--network flag is only valid with the docker/podman, KVM and Qemu drivers, it will be ignored": "L'indicateur --network n'est valide qu'avec les pilotes docker/podman, KVM et Qemu, il sera ignoré", + "--network with QEMU must be 'builtin' (aka 'user') or 'socket_vmnet', and for QEMU v7.1+, it can also be 'vmnet-host', 'vmnet-shared' or 'vmnet-bridged'": "", "--network with QEMU must be 'builtin' or 'socket_vmnet'": "--network avec QEMU doit être 'builtin' ou 'socket_vmnet'", "--network with QEMU must be 'user' or 'socket_vmnet'": "--network avec QEMU doit être 'user' ou 'socket_vmnet'", "--static-ip is only implemented on Docker and Podman drivers, flag will be ignored": "--static-ip n'est implémenté que sur les pilotes Docker et Podman, l'indicateur sera ignoré", @@ -794,6 +795,7 @@ "The total number of nodes to spin up. Defaults to 1.": "Le nombre total de nœuds à faire tourner. La valeur par défaut est 1.", "The value passed to --format is invalid": "La valeur passée à --format n'est pas valide", "The value passed to --format is invalid: {{.error}}": "La valeur passée à --format n'est pas valide : {{.error}}", + "The vmnet network is not yet supported on windows": "", "The {{.addon}} addon is only supported with the KVM driver.\n\nFor GPU setup instructions see: https://minikube.sigs.k8s.io/docs/tutorials/nvidia/": "Le module complémentaire {{.addon}} n'est pris en charge qu'avec le pilote KVM.\n\nPour les instructions de configuration du GPU, consultez : https://minikube.sigs.k8s.io/docs/tutorials/nvidia/", "There are a couple ways to enable the required file sharing:\n1. Enable \"Use the WSL 2 based engine\" in Docker Desktop\nor\n2. Enable file sharing in Docker Desktop for the %s%s directory": "Il existe plusieurs manières d'activer le partage de fichiers requis :\n1. Activez \"Utiliser le moteur basé sur WSL 2\" dans Docker Desktop\nou\n2. Activer le partage de fichiers dans Docker Desktop pour le répertoire %s%s", "These --extra-config parameters are invalid: {{.invalid_extra_opts}}": "Ces paramètres --extra-config ne sont pas valides : {{.invalid_extra_opts}}", diff --git a/translations/ja.json b/translations/ja.json index 86400896c847..9dbdc446c7cd 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -24,6 +24,7 @@ "--kvm-numa-count range is 1-8": "--kvm-numa-count の範囲は 1~8 です", "--network flag is only valid with the docker/podman and KVM drivers, it will be ignored": "--network フラグは、docker/podman および KVM ドライバーでのみ有効であるため、無視されます", "--network flag is only valid with the docker/podman, KVM and Qemu drivers, it will be ignored": "--network フラグは、docker/podman, KVM および Qemu ドライバーでのみ有効であるため、無視されます", + "--network with QEMU must be 'builtin' (aka 'user') or 'socket_vmnet', and for QEMU v7.1+, it can also be 'vmnet-host', 'vmnet-shared' or 'vmnet-bridged'": "", "--network with QEMU must be 'builtin' or 'socket_vmnet'": "QEMU を用いる場合、--network は、'builtin' か 'socket_vmnet' でなければなりません", "--network with QEMU must be 'user' or 'socket_vmnet'": "QEMU を用いる場合、--network は、'user' か 'socket_vmnet' でなければなりません", "--static-ip is only implemented on Docker and Podman drivers, flag will be ignored": "--static-ip フラグは、Docker および Podman ドライバー上でのみ実装されているため、無視されます", @@ -761,6 +762,7 @@ "The total number of nodes to spin up. Defaults to 1.": "", "The value passed to --format is invalid": "--format の値が無効です", "The value passed to --format is invalid: {{.error}}": "--format の値が無効です: {{.error}}", + "The vmnet network is not yet supported on windows": "", "The {{.addon}} addon is only supported with the KVM driver.\n\nFor GPU setup instructions see: https://minikube.sigs.k8s.io/docs/tutorials/nvidia/": "", "There are a couple ways to enable the required file sharing:\n1. Enable \"Use the WSL 2 based engine\" in Docker Desktop\nor\n2. Enable file sharing in Docker Desktop for the %s%s directory": "必要なファイル共有を有効にする方法が 2 つあります:\n1. Docker Desktop 中の「Use the WSL 2 based engine」を有効にする\nまたは\n2. %s%s ディレクトリー用の Docker Desktop でファイル共有を有効にする", "These --extra-config parameters are invalid: {{.invalid_extra_opts}}": "次の --extra-config パラメーターは無効です: {{.invalid_extra_opts}}", diff --git a/translations/ko.json b/translations/ko.json index 40ff84cd2332..486b5f619e95 100644 --- a/translations/ko.json +++ b/translations/ko.json @@ -28,6 +28,7 @@ "- Restart your {{.driver_name}} service": "{{.driver_name}} 서비스를 다시 시작하세요", "--kvm-numa-count range is 1-8": "--kvm-numa-count 범위는 1-8 입니다", "--network flag is only valid with the docker/podman, KVM and Qemu drivers, it will be ignored": "--network 는 docker나 podman 에서만 유효합니다. KVM이나 Qemu 드라이버에서는 인자가 무시됩니다", + "--network with QEMU must be 'builtin' (aka 'user') or 'socket_vmnet', and for QEMU v7.1+, it can also be 'vmnet-host', 'vmnet-shared' or 'vmnet-bridged'": "", "--network with QEMU must be 'builtin' or 'socket_vmnet'": "QEMU 에서 --network 는 'builtin' 이나 'socket_vmnet' 이어야 합니다", "--static-ip is only implemented on Docker and Podman drivers, flag will be ignored": "--static-ip 는 Docker와 Podman 드라이버에서만 구현되었습니다. 인자는 무시됩니다", "--static-ip overrides --subnet, --subnet will be ignored": "--static-ip 는 --subnet 을 재정의하기 때문에, --subnet 은 무시됩니다", @@ -796,6 +797,7 @@ "The total number of nodes to spin up. Defaults to 1.": "", "The value passed to --format is invalid": "", "The value passed to --format is invalid: {{.error}}": "", + "The vmnet network is not yet supported on windows": "", "The {{.addon}} addon is only supported with the KVM driver.\n\nFor GPU setup instructions see: https://minikube.sigs.k8s.io/docs/tutorials/nvidia/": "", "There are a couple ways to enable the required file sharing:\n1. Enable \"Use the WSL 2 based engine\" in Docker Desktop\nor\n2. Enable file sharing in Docker Desktop for the %s%s directory": "", "These --extra-config parameters are invalid: {{.invalid_extra_opts}}": "", diff --git a/translations/pl.json b/translations/pl.json index 99db202497e1..247ec37679f4 100644 --- a/translations/pl.json +++ b/translations/pl.json @@ -27,7 +27,7 @@ "- Restart your {{.driver_name}} service": "", "--kvm-numa-count range is 1-8": "", "--network flag is only valid with the docker/podman, KVM and Qemu drivers, it will be ignored": "", - "--network with QEMU must be 'builtin' or 'socket_vmnet'": "", + "--network with QEMU must be 'builtin' (aka 'user') or 'socket_vmnet', and for QEMU v7.1+, it can also be 'vmnet-host', 'vmnet-shared' or 'vmnet-bridged'": "", "--static-ip is only implemented on Docker and Podman drivers, flag will be ignored": "", "--static-ip overrides --subnet, --subnet will be ignored": "", "1) Recreate the cluster with Kubernetes {{.new}}, by running:\n\t \n\t\t minikube delete{{.profile}}\n\t\t minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t2) Create a second cluster with Kubernetes {{.new}}, by running:\n\t \n\t\t minikube start -p {{.suggestedName}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t3) Use the existing cluster at version Kubernetes {{.old}}, by running:\n\t \n\t\t minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.old}}\n\t\t": "", @@ -798,6 +798,7 @@ "The total number of nodes to spin up. Defaults to 1.": "", "The value passed to --format is invalid": "Wartość przekazana do --format jest nieprawidłowa", "The value passed to --format is invalid: {{.error}}": "Wartość przekazana do --format jest nieprawidłowa: {{.error}}", + "The vmnet network is not yet supported on windows": "", "The {{.addon}} addon is only supported with the KVM driver.\n\nFor GPU setup instructions see: https://minikube.sigs.k8s.io/docs/tutorials/nvidia/": "", "The {{.driver_name}} driver should not be used with root privileges.": "{{.driver_name}} nie powinien być używany z przywilejami root'a.", "There are a couple ways to enable the required file sharing:\n1. Enable \"Use the WSL 2 based engine\" in Docker Desktop\nor\n2. Enable file sharing in Docker Desktop for the %s%s directory": "", diff --git a/translations/ru.json b/translations/ru.json index 33124128ed36..3b71c10b660f 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -22,7 +22,7 @@ "- Restart your {{.driver_name}} service": "", "--kvm-numa-count range is 1-8": "", "--network flag is only valid with the docker/podman, KVM and Qemu drivers, it will be ignored": "", - "--network with QEMU must be 'builtin' or 'socket_vmnet'": "", + "--network with QEMU must be 'builtin' (aka 'user') or 'socket_vmnet', and for QEMU v7.1+, it can also be 'vmnet-host', 'vmnet-shared' or 'vmnet-bridged'": "", "--static-ip is only implemented on Docker and Podman drivers, flag will be ignored": "", "--static-ip overrides --subnet, --subnet will be ignored": "", "1) Recreate the cluster with Kubernetes {{.new}}, by running:\n\t \n\t\t minikube delete{{.profile}}\n\t\t minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t2) Create a second cluster with Kubernetes {{.new}}, by running:\n\t \n\t\t minikube start -p {{.suggestedName}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t3) Use the existing cluster at version Kubernetes {{.old}}, by running:\n\t \n\t\t minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.old}}\n\t\t": "1) Пересоздайте кластер с Kubernetes {{.new}}, выполнив:\n\t \n\t\t minikube delete{{.profile}}\n\t\t minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t2) Создайье второй кластер с Kubernetes {{.new}}, выполнив:\n\t \n\t\t minikube start -p {{.suggestedName}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t3) Используйте существующий кластер с версией Kubernetes {{.old}}, выполнив:\n\t \n\t\t minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.old}}\n\t\t", @@ -728,6 +728,7 @@ "The total number of nodes to spin up. Defaults to 1.": "", "The value passed to --format is invalid": "", "The value passed to --format is invalid: {{.error}}": "", + "The vmnet network is not yet supported on windows": "", "The {{.addon}} addon is only supported with the KVM driver.\n\nFor GPU setup instructions see: https://minikube.sigs.k8s.io/docs/tutorials/nvidia/": "", "There are a couple ways to enable the required file sharing:\n1. Enable \"Use the WSL 2 based engine\" in Docker Desktop\nor\n2. Enable file sharing in Docker Desktop for the %s%s directory": "", "These --extra-config parameters are invalid: {{.invalid_extra_opts}}": "", diff --git a/translations/strings.txt b/translations/strings.txt index a22ec186d6be..b3d537ed13e4 100644 --- a/translations/strings.txt +++ b/translations/strings.txt @@ -22,7 +22,7 @@ "- Restart your {{.driver_name}} service": "", "--kvm-numa-count range is 1-8": "", "--network flag is only valid with the docker/podman, KVM and Qemu drivers, it will be ignored": "", - "--network with QEMU must be 'builtin' or 'socket_vmnet'": "", + "--network with QEMU must be 'builtin' (aka 'user') or 'socket_vmnet', and for QEMU v7.1+, it can also be 'vmnet-host', 'vmnet-shared' or 'vmnet-bridged'": "", "--static-ip is only implemented on Docker and Podman drivers, flag will be ignored": "", "--static-ip overrides --subnet, --subnet will be ignored": "", "1) Recreate the cluster with Kubernetes {{.new}}, by running:\n\t \n\t\t minikube delete{{.profile}}\n\t\t minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t2) Create a second cluster with Kubernetes {{.new}}, by running:\n\t \n\t\t minikube start -p {{.suggestedName}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t3) Use the existing cluster at version Kubernetes {{.old}}, by running:\n\t \n\t\t minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.old}}\n\t\t": "", @@ -726,6 +726,7 @@ "The total number of nodes to spin up. Defaults to 1.": "", "The value passed to --format is invalid": "", "The value passed to --format is invalid: {{.error}}": "", + "The vmnet network is not yet supported on windows": "", "The {{.addon}} addon is only supported with the KVM driver.\n\nFor GPU setup instructions see: https://minikube.sigs.k8s.io/docs/tutorials/nvidia/": "", "There are a couple ways to enable the required file sharing:\n1. Enable \"Use the WSL 2 based engine\" in Docker Desktop\nor\n2. Enable file sharing in Docker Desktop for the %s%s directory": "", "These --extra-config parameters are invalid: {{.invalid_extra_opts}}": "", @@ -1053,4 +1054,4 @@ "{{.profile}} profile is not valid: {{.err}}": "", "{{.type}} is not yet a supported filesystem. We will try anyways!": "", "{{.url}} is not accessible: {{.error}}": "" -} \ No newline at end of file +} diff --git a/translations/zh-CN.json b/translations/zh-CN.json index 3bf849bc5e00..3ed4d0f12787 100644 --- a/translations/zh-CN.json +++ b/translations/zh-CN.json @@ -31,6 +31,7 @@ "--kvm-numa-count range is 1-8": "--kvm-numa-count 取值范围为 1-8", "--network flag is only valid with the docker/podman and KVM drivers, it will be ignored": "--network 标识仅对 docker/podman 和 KVM 驱动程序有效,它将被忽略", "--network flag is only valid with the docker/podman, KVM and Qemu drivers, it will be ignored": "--network 标识仅对 docker/podman KVM 和 Qemu 驱动程序有效,它将被忽略", + "--network with QEMU must be 'builtin' (aka 'user') or 'socket_vmnet', and for QEMU v7.1+, it can also be 'vmnet-host', 'vmnet-shared' or 'vmnet-bridged'": "", "--network with QEMU must be 'builtin' or 'socket_vmnet'": "--network 参数与 QEMU 必须为 'builtin' 或 'socket_vmnet'", "--static-ip is only implemented on Docker and Podman drivers, flag will be ignored": "--static-ip 只在 Docker 和 Podman 驱动上实现,flag 将被忽略", "--static-ip overrides --subnet, --subnet will be ignored": "--static-ip 重写 --subnet,--subnet 将被忽略", @@ -907,6 +908,7 @@ "The total number of nodes to spin up. Defaults to 1.": "要启动的节点总数。默认值为 1。", "The value passed to --format is invalid": "传递给 --format 的值无效。", "The value passed to --format is invalid: {{.error}}": "传递给 --format 的值无效:{{.error}}。", + "The vmnet network is not yet supported on windows": "", "The {{.addon}} addon is only supported with the KVM driver.\n\nFor GPU setup instructions see: https://minikube.sigs.k8s.io/docs/tutorials/nvidia/": "", "The {{.driver_name}} driver should not be used with root privileges.": "不应以根权限使用 {{.driver_name}} 驱动程序。", "There are a couple ways to enable the required file sharing:\n1. Enable \"Use the WSL 2 based engine\" in Docker Desktop\nor\n2. Enable file sharing in Docker Desktop for the %s%s directory": "", From e8af3c03198377a7edcfc738ec8379114a6edd1f Mon Sep 17 00:00:00 2001 From: Predrag Rogic Date: Tue, 18 Apr 2023 20:21:03 +0100 Subject: [PATCH 5/9] add sudo password handling --- pkg/drivers/qemu/qemu.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/drivers/qemu/qemu.go b/pkg/drivers/qemu/qemu.go index a80d8e31eafb..f44ae6988a75 100644 --- a/pkg/drivers/qemu/qemu.go +++ b/pkg/drivers/qemu/qemu.go @@ -596,11 +596,11 @@ func cmdOutErr(cmdStr string, args ...string) (string, string, error) { var err error - // allow using ROOT_PASSWORD env var for ci/cd automation, if present - // otherwise, prompt user to enter root password without echoing it using os.Stdin + // allow using SUDO_PASSWORD env var for ci/cd automation, if present + // otherwise, prompt user to enter sudo password without echoing it using os.Stdin var stdin io.WriteCloser cmd.Stdin = os.Stdin - secret, found := os.LookupEnv("ROOT_PASSWORD") + secret, found := os.LookupEnv("SUDO_PASSWORD") if found { cmd.Stdin = nil // unset to avoid "Stdin already set" error if stdin, err = cmd.StdinPipe(); err != nil { @@ -633,7 +633,7 @@ func cmdOutErr(cmdStr string, args ...string) (string, string, error) { // macOS has "Password:" and Linux has "[sudo] password for root:" prompt if strings.Contains(string(buf), "assword") && strings.HasSuffix(string(buf), ":") { - // try ROOT_PASSWORD first, if one exists + // try SUDO_PASSWORD first, if one exists if stdin != nil { if _, err := io.WriteString(stdin, fmt.Sprintf("%s\n", secret)); err != nil { log.Errorf("writing to stdin failed: %v", err) @@ -642,7 +642,7 @@ func cmdOutErr(cmdStr string, args ...string) (string, string, error) { continue } // alternatively, use os.Stdin for prompt - fmt.Printf("\n[sudo] password for root: ") + fmt.Printf("\nsudo password: ") } } }() From dfbf3cf1330c9b67c8cce986c00ca716290ee438 Mon Sep 17 00:00:00 2001 From: Predrag Rogic Date: Mon, 7 Aug 2023 21:48:07 +0100 Subject: [PATCH 6/9] fix 'sudo: qemu-system-aarch64: command not found' --- pkg/drivers/qemu/qemu.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/drivers/qemu/qemu.go b/pkg/drivers/qemu/qemu.go index f44ae6988a75..73214400e57f 100644 --- a/pkg/drivers/qemu/qemu.go +++ b/pkg/drivers/qemu/qemu.go @@ -503,7 +503,7 @@ func (d *Driver) Start() error { //nolint to suppress cyclomatic complexity 31 i if strings.HasPrefix(d.Network, "vmnet-") { //TODO: handle windows startProgram = "sudo" - startCmd = append([]string{"-S", d.Program}, startCmd...) + startCmd = append([]string{"--stdin", "env", fmt.Sprintf("PATH=%q", os.Getenv("PATH")), d.Program}, startCmd...) } startFunc := cmdOutErr From 7e3855462392e9294dbb57e5cb77f8bd93fa3e29 Mon Sep 17 00:00:00 2001 From: Predrag Rogic Date: Tue, 27 Feb 2024 21:30:49 +0000 Subject: [PATCH 7/9] alessiodionisi: update cmd/minikube/cmd/start_flags.go make check and exit message consistent with socket_vmnet Co-authored-by: Alessio Dionisi --- cmd/minikube/cmd/start_flags.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/minikube/cmd/start_flags.go b/cmd/minikube/cmd/start_flags.go index 22e7b7cf768e..7459a4565bb2 100644 --- a/cmd/minikube/cmd/start_flags.go +++ b/cmd/minikube/cmd/start_flags.go @@ -475,8 +475,8 @@ func getNetwork(driverName string) string { switch n { case "vmnet-host", "vmnet-shared", "vmnet-bridged": //TODO: check if QEMU v7.1+ version is installed - if runtime.GOOS == "windows" { - exit.Message(reason.Usage, "The vmnet network is not yet supported on windows") + if runtime.GOOS != "Darwin" { + exit.Message(reason.Usage, "The vmnet-* network is only supported on macOS") } case "socket_vmnet": if runtime.GOOS != "darwin" { From 2b91019ec9f423830ed8d5da7dbafe58b87ef8b4 Mon Sep 17 00:00:00 2001 From: Predrag Rogic Date: Fri, 25 Oct 2024 18:17:25 +0100 Subject: [PATCH 8/9] Update cmd/minikube/cmd/start_flags.go Co-authored-by: Steven Powell <44844360+spowelljr@users.noreply.github.com> --- cmd/minikube/cmd/start_flags.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/minikube/cmd/start_flags.go b/cmd/minikube/cmd/start_flags.go index 7459a4565bb2..dcabd0228631 100644 --- a/cmd/minikube/cmd/start_flags.go +++ b/cmd/minikube/cmd/start_flags.go @@ -475,7 +475,7 @@ func getNetwork(driverName string) string { switch n { case "vmnet-host", "vmnet-shared", "vmnet-bridged": //TODO: check if QEMU v7.1+ version is installed - if runtime.GOOS != "Darwin" { + if runtime.GOOS != "darwin" { exit.Message(reason.Usage, "The vmnet-* network is only supported on macOS") } case "socket_vmnet": From 797d2529e5e2b7eeecd10ac6fb925bcc39a92a80 Mon Sep 17 00:00:00 2001 From: Predrag Rogic Date: Fri, 25 Oct 2024 18:32:24 +0100 Subject: [PATCH 9/9] Update pkg/drivers/qemu/qemu.go Co-authored-by: Steven Powell <44844360+spowelljr@users.noreply.github.com> --- pkg/drivers/qemu/qemu.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/drivers/qemu/qemu.go b/pkg/drivers/qemu/qemu.go index 73214400e57f..9a4872379c2c 100644 --- a/pkg/drivers/qemu/qemu.go +++ b/pkg/drivers/qemu/qemu.go @@ -604,7 +604,7 @@ func cmdOutErr(cmdStr string, args ...string) (string, string, error) { if found { cmd.Stdin = nil // unset to avoid "Stdin already set" error if stdin, err = cmd.StdinPipe(); err != nil { - return "", "", fmt.Errorf("cannont create StdinPipe: %v", err) + return "", "", fmt.Errorf("cannot create StdinPipe: %v", err) } }