Add the qemu driver to the minikube registry

Since the machine drivers are hardcoded in minikube,
drivers need to be added to the registry to be tested.

Add a basic sanity check for the qemu-system binary,
and set up the basic configuration such as cpus/memory.
pull/13639/head
Anders F Björklund 2022-02-20 10:15:48 +01:00
parent add0bc6366
commit 284ad62394
12 changed files with 136 additions and 0 deletions

1
go.mod
View File

@ -155,6 +155,7 @@ require (
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.13.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/machine-drivers/docker-machine-driver-qemu v0.1.0
github.com/magiconair/properties v1.8.5 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect

2
go.sum
View File

@ -756,6 +756,8 @@ github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9
github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
github.com/machine-drivers/docker-machine-driver-qemu v0.1.0 h1:r5bMzOqca0dZuCkn/8vCM8QNpdsLPCVZ6VP5z/IU0HM=
github.com/machine-drivers/docker-machine-driver-qemu v0.1.0/go.mod h1:1gevpWYcs2Gmvt9G9T6AbeRw9tGnQdQiKt56B7n2X7g=
github.com/machine-drivers/docker-machine-driver-vmware v0.1.5 h1:51GqJ84u9EBATnn8rWsHNavcuRPlCLnDmvjzZVuliwY=
github.com/machine-drivers/docker-machine-driver-vmware v0.1.5/go.mod h1:dTnTzUH3uzhMo0ddV1zRjGYWcVhQWwqiHPxz5l+HPd0=
github.com/machine-drivers/machine v0.7.1-0.20211105063445-78a84df85426 h1:gVDPCmqwvHQ4ox/9svvnkomYJAAiV59smbPdTK4DIm4=

View File

@ -46,6 +46,8 @@ const (
SSH = "ssh"
// KVM2 driver
KVM2 = "kvm2"
// QEMU driver
QEMU = "qemu"
// VirtualBox driver
VirtualBox = "virtualbox"
// HyperKit driver

View File

@ -27,6 +27,7 @@ var supportedDrivers = func() []string {
if runtime.GOARCH == "arm64" {
// on darwin/arm64 only docker and ssh are supported yet
return []string{
QEMU,
Docker,
Podman,
SSH,
@ -50,6 +51,7 @@ var supportedDrivers = func() []string {
VMwareFusion,
HyperKit,
VMware,
QEMU,
Docker,
Podman,
SSH,

View File

@ -25,6 +25,7 @@ var supportedDrivers = []string{
VirtualBox,
VMwareFusion,
KVM2,
QEMU,
VMware,
None,
Docker,

View File

@ -66,6 +66,7 @@ func TestMachineType(t *testing.T) {
None: "bare metal machine",
SSH: "bare metal machine",
KVM2: "VM",
QEMU: "VM",
VirtualBox: "VM",
HyperKit: "VM",
VMware: "VM",

View File

@ -32,6 +32,7 @@ var supportedDrivers = []string{
VMwareFusion,
HyperV,
VMware,
QEMU,
Docker,
Podman,
SSH,

View File

@ -25,6 +25,7 @@ import (
_ "k8s.io/minikube/pkg/minikube/registry/drvs/none"
_ "k8s.io/minikube/pkg/minikube/registry/drvs/parallels"
_ "k8s.io/minikube/pkg/minikube/registry/drvs/podman"
_ "k8s.io/minikube/pkg/minikube/registry/drvs/qemu"
_ "k8s.io/minikube/pkg/minikube/registry/drvs/ssh"
_ "k8s.io/minikube/pkg/minikube/registry/drvs/virtualbox"
_ "k8s.io/minikube/pkg/minikube/registry/drvs/vmware"

View File

@ -0,0 +1,17 @@
/*
Copyright 2018 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package qemu

View File

@ -0,0 +1,83 @@
/*
Copyright 2018 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package qemu
import (
"fmt"
"os/exec"
"runtime"
"github.com/docker/machine/libmachine/drivers"
drvqemu "github.com/machine-drivers/docker-machine-driver-qemu"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/download"
"k8s.io/minikube/pkg/minikube/driver"
"k8s.io/minikube/pkg/minikube/localpath"
"k8s.io/minikube/pkg/minikube/registry"
)
const (
docURL = "https://minikube.sigs.k8s.io/docs/reference/drivers/qemu/"
)
func init() {
if err := registry.Register(registry.DriverDef{
Name: driver.QEMU,
Config: configure,
Status: status,
Default: true,
Priority: registry.Experimental,
}); err != nil {
panic(fmt.Sprintf("register failed: %v", err))
}
}
func configure(cc config.ClusterConfig, n config.Node) (interface{}, error) {
name := config.MachineName(cc, n)
return drvqemu.Driver{
BaseDriver: &drivers.BaseDriver{
MachineName: name,
StorePath: localpath.MiniPath(),
SSHUser: "docker",
},
Boot2DockerURL: download.LocalISOResource(cc.MinikubeISO),
DiskSize: cc.DiskSize,
Memory: cc.Memory,
CPU: cc.CPUs,
}, nil
}
func status() registry.State {
var qemuSystem string
arch := runtime.GOARCH
switch arch {
case "amd64":
qemuSystem = "qemu-system-x86_64"
case "arm64":
qemuSystem = "qemu-system-aarch64"
default:
return registry.State{Error: fmt.Errorf("unknown arch: %s", arch), Doc: docURL}
}
_, err := exec.LookPath(qemuSystem)
if err != nil {
return registry.State{Error: err, Fix: "Install qemu-system", Doc: docURL}
}
return registry.State{Installed: true, Healthy: true, Running: true}
}

View File

@ -17,6 +17,7 @@ To do so, we use the [Docker Machine](https://github.com/docker/machine) library
* [Docker]({{<ref "docker.md">}}) - container-based (preferred)
* [KVM2]({{<ref "kvm2.md">}}) - VM-based (preferred)
* [VirtualBox]({{<ref "virtualbox.md">}}) - VM
* [QEMU]({{<ref "qemu.md">}}) - VM (experimental)
* [None]({{<ref "none.md">}}) - bare-metal
* [Podman]({{<ref "podman.md">}}) - container (experimental)
* [SSH]({{<ref "ssh.md">}}) - remote ssh
@ -29,6 +30,7 @@ To do so, we use the [Docker Machine](https://github.com/docker/machine) library
* [VirtualBox]({{<ref "virtualbox.md">}}) - VM
* [Parallels]({{<ref "parallels.md">}}) - VM
* [VMware Fusion]({{<ref "vmware.md">}}) - VM
* [QEMU]({{<ref "qemu.md">}}) - VM (experimental)
* [SSH]({{<ref "ssh.md">}}) - remote ssh
## Windows
@ -37,4 +39,5 @@ To do so, we use the [Docker Machine](https://github.com/docker/machine) library
* [Docker]({{<ref "docker.md">}}) - VM + Container (preferred)
* [VirtualBox]({{<ref "virtualbox.md">}}) - VM
* [VMware Workstation]({{<ref "vmware.md">}}) - VM
* [QEMU]({{<ref "qemu.md">}}) - VM (experimental)
* [SSH]({{<ref "ssh.md">}}) - remote ssh

View File

@ -0,0 +1,22 @@
---
title: "qemu"
weight: 3
description: >
QEMU driver
aliases:
- /docs/reference/drivers/qemu
---
## Overview
The `qemu` driver users QEMU (system) for VM creation.
<https://www.qemu.org/>
## Issues
* [Full list of open 'qemu' driver issues](https://github.com/kubernetes/minikube/labels/co%2Fqemu-driver)
## Troubleshooting
* Run `minikube start --alsologtostderr -v=4` to debug crashes