Replace 9p mounts with virtiofs for vfkit and krunkit. Testing shows
that virtiofs mount is 23 times faster with krunkit, and 8 times faster
with vfkit.
vfkit and krunkit support multiple virtiofs mounts but minikube
--mount-* flags are not ready for multiple mounts. We have the same
issue with KIC drivers, supporting multiple mounts but using only one.
We hope to improve this in the next release.
Example usage:
minikube start --mount-string ~/models:/mnt/models
The arguments are parsed and validated when configuring the driver, so
invalid arguments fail quickly without starting the driver. The
validated mounts are stored in the machine config:
$ jq '.Driver.VirtiofsMounts' < ~/.minikube/machines/minikube/config.json
[
{
"HostPath": "/Users/joe/models",
"GuestPath": "/mnt/models",
"Tag": "f845b54d-00e3-493d-9541-3b37490b96db"
}
]
Minikube generates a new random UUID for every virtiofs mount to
identify the file system inside the guest. In krunkit and vfkit, every
mount is add as:
--device virtio-fs,sharedDir=/host-path,mountTag=f845b54d-00e3-493d-9541-3b37490b96db
When the guest is started the shared directory is mounted via SSH using:
sudo mkdir -p /mnt/models
sudo mount -t virtiofs f845b54d-00e3-493d-9541-3b37490b96db /mnt/models
Example mount:
$ minikube ssh findmnt /mnt/models
TARGET SOURCE FSTYPE OPTIONS
/mnt/models f845b54d-00e3-493d-9541-3b37490b96db virtiofs rw,relatime
More work is needed to add VirtioFS to qemu. I'm starting with vfkit and
krunkit since they have identical interface (krunkit was designed as
drop-in replacement for vfkit).
Move all files and packages which are not a driver to the drivers/common
package. This helps to understand the structure of the code.
While moving, move the iso_test.iso into testdata/test.iso to separate
code and test data.
While fixing the test iso path fix few bugs in the tests using wrong iso
path. The test failed because the iso path was wrong instead of issue
with source or destination path.
New directory structure:
% tree -L1 pkg/drivers
pkg/drivers
├── common
├── hyperkit
├── kic
├── krunkit
├── kvm
├── none
├── qemu
├── ssh
└── vfkit
I don't know why the linter did not complain in the CI, but running
locally revealed few issues:
% golangci-lint run ./pkg/drivers/krunkit
pkg/drivers/krunkit/krunkit.go:537:34: importShadow: shadow of
imported from 'github.com/docker/machine/libmachine/state' package
'state' (gocritic)
func (d *Driver) setKrunkitState(state string) error {
^
pkg/drivers/krunkit/krunkit.go:341:9: unnecessary-format:
unnecessary use of formatting function "fmt.Errorf", you can replace
it with "errors.New" (revive)
return fmt.Errorf("hosts without a driver cannot start docker")
^
pkg/drivers/krunkit/krunkit.go:345:9: unnecessary-format:
unnecessary use of formatting function "fmt.Errorf", you can replace
it with "errors.New" (revive)
return fmt.Errorf("hosts without a driver cannot stop docker")
^
pkg/drivers/krunkit/krunkit.go:444:18: func (*Driver).logfilePath is
unused (unused)
func (d *Driver) logfilePath() string {
^
* krunkit: Add krunkit driver
krunkit is a tool to launch configurable virtual machines using the
libkrun platform, optimized for GPU accelerated virtual machines and AI
workloads on Apple silicon.
It is mostly compatible with vfkit; the driver is a simplified copy of
the vfkit driver. Unlike vfkit, krunkit is available only on Apple
silicon.
Changes compared to vfkit driver:
- krunkit requires unix socket for networking, so we must use
vment-helper.
- krunkit does not support HardStop, so we kill it using SIGKILL.
- We must enable vmnet offloading, required for krunkit.
- The code was simplified since vmnet-helper is always used
- Code was cleaned up to use .ResolveStorePath()
- Unused Upgrade() function was removed
- Types and functions that should not be public made private
We require krunkit 0.2.2, supporting --restul-uri=unix://.
* reason: Make vment-helper error driver agnostic
Previously it was used only for vfkit, so we suggested to fallback to
the `nat` network. This advice is not relevant to krunkit or to qemu
(which can also use vmnet-helper).
Change the error to recommend installing vment-helper. We need to think
how we can recommend other networks for vfkit and qemu. Another solution
is to create error for every driver+network combination but this seems
hard to manage.
* hack: Add krunkit integration test
This is the same way that we test vfkit. This test is not running in the
CI.
Issues:
- Need to install and configure vment-helper (requires root).
* site: Add krunkit driver documentation