You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+34-28Lines changed: 34 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,14 @@
1
1
# libkrun
2
2
3
-
```libkrun``` is a dynamic library that allows programs to easily acquire the ability to run processes in a partially isolated environment using [KVM](https://www.kernel.org/doc/Documentation/virtual/kvm/api.txt) Virtualization.
3
+
```libkrun``` is a dynamic library that allows programs to easily acquire the ability to run processes in a partially isolated environment using [KVM](https://www.kernel.org/doc/Documentation/virtual/kvm/api.txt) Virtualization on Linux and [HVF](https://developer.apple.com/documentation/hypervisor) on macOS/ARM64.
4
4
5
5
It integrates a VMM (Virtual Machine Monitor, the userspace side of an Hypervisor) with the minimum amount of emulated devices required to its purpose, abstracting most of the complexity that comes from Virtual Machine management, offering users a simple C API.
6
6
7
-
## Possible use cases
7
+
## Use cases
8
8
9
-
* Adding VM-isolation capabilities to an OCI runtime.
10
-
*Implementing a lightweight jailer for serverless workloads.
11
-
*Bringing additional self-isolation capabilities to conventional services (think of something as simple as ```chroot```, but more powerful).
9
+
*[crun](https://github.com/containers/crun/blob/main/krun.1.md): Adding Virtualization-based isolation to container and confidential workloads.
10
+
*[kunkit](https://github.com/containers/krunkit): Running GPU-enabled (via [venus](https://docs.mesa3d.org/drivers/venus.html)) lightweight VMs on macOS.
11
+
*[muvm](https://github.com/AsahiLinux/muvm): Launching a microVM with GPU acceleration (via [native context](https://www.youtube.com/watch?v=9sFP_yddLLQ)) for running games that require 4k pages.
12
12
13
13
## Goals and non-goals
14
14
@@ -30,7 +30,8 @@ It integrates a VMM (Virtual Machine Monitor, the userspace side of an Hyperviso
30
30
This project provides two different variants of the library:
31
31
32
32
-**libkrun**: Generic variant compatible with all Virtualization-capable systems.
33
-
-**libkrun-sev**: Variant including support for AMD SEV (bare SEV and SEV-ES) memory encryption and remote attestation. Requires an SEV-capable CPU.
33
+
-**libkrun-sev**: Variant including support for AMD SEV (SEV, SEV-ES and SEV-SNP) memory encryption and remote attestation. Requires an SEV-capable CPU.
34
+
-**libkrun-efi**: Variant that bundles OVMF/EDK2 for booting a distribution-provided kernel (only available on macOS).
34
35
35
36
Each variant generates a dynamic library with a different name (and ```soname```), so both can be installed at the same time in the same system.
36
37
@@ -39,24 +40,22 @@ Each variant generates a dynamic library with a different name (and ```soname```
39
40
### All variants
40
41
41
42
* virtio-console
42
-
* virtio-vsock (specialized for TSI, Transparent Socket Impersonation)
43
43
* virtio-block
44
-
45
-
### libkrun
46
-
47
44
* virtio-fs
45
+
* virtio-gpu (venus and native-context)
46
+
* virtio-net
47
+
* virtio-vsock (for TSI and socket redirection)
48
48
* virtio-balloon (only free-page reporting)
49
49
* virtio-rng
50
+
* virtio-snd
50
51
51
52
## Networking
52
53
53
-
In ```libkrun```, networking is implemented using a novel technique called **Transparent Socket Impersonation**, or **TSI**. This allows the VM to have network connectivity without a virtual interface (hence, ```virtio-net``` is not among the list of supported devices).
54
+
In ```libkrun```, networking is provided by two different, mutually exclusive techniques:
54
55
55
-
This technique supports both outgoing and incoming connections. It's possible for userspace applications running in the VM are able to transparently connect to endpoints outside the VM, and also receive connections from the outside to ports listening inside the VM.
56
+
-**virtio-vsock + TSI**: A novel technique called **Transparent Socket Impersonation** which allows the VM to have network connectivity without a virtual interface. This technique supports both outgoing and incoming connections. It's possible for userspace applications running in the VM to transparently connect to endpoints outside the VM and receive connections from the outside to ports listening inside the VM. Requires a custom kernel (like the one bundled in **libkrunfw**) and it's limited to AF_INET SOCK_DGRAM and SOCK_STREAM sockets.
56
57
57
-
### Limitations
58
-
59
-
**TSI** only supports impersonating AF_INET SOCK_DGRAM and SOCK_STREAM sockets. This implies it's not possible to communicate outside the VM with raw sockets.
58
+
-**virtio-net + passt/gvproxy**: A conventional virtual interface that allows the guest to communicate with the outside through the VMM using a supporting application like [passt](https://passt.top/passt/about/) or [gvproxy](https://github.com/containers/gvisor-tap-vsock).
60
59
61
60
## Building and installing
62
61
@@ -69,10 +68,18 @@ This technique supports both outgoing and incoming connections. It's possible fo
69
68
* C Library static libraries, as the [init](init/init.c) binary is statically linked (package ```glibc-static``` in Fedora)
***VIRGL_RESOURCE_MAP2=1**: Uses virgl_resource_map2 function. Requires a virglrenderer-devel patched with [1374](https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/1374)
75
+
***BLK=1**: Enables virtio-block.
76
+
***NET=1**: Enables virtio-net.
77
+
***SND=1**: Enables virtio-snd.
78
+
72
79
#### Compiling
73
80
74
81
```
75
-
make
82
+
make [FEATURE_OPTIONS]
76
83
```
77
84
78
85
#### Installing
@@ -103,19 +110,23 @@ make SEV=1
103
110
sudo make SEV=1 install
104
111
```
105
112
106
-
### macOS
113
+
### macOS (EFI variant)
107
114
108
115
#### Requirements
109
116
110
-
As part of ```libkrun``` building process, it's necessary to produce a Linux ELF binary from [init/init.c](init/init.c). The easiest way to do this is by using a binary version of [krunvm](https://github.com/slp/krunvm) and its dependencies ([libkrunfw](https://github.com/containers/libkrunfw), and ```libkrun``` itself), such as the one available in the [krunvm Homebrew repo](https://github.com/slp/homebrew-krun), and then executing the [build_on_krunvm.sh](build_on_krunvm.sh) script found in this repository.
117
+
* A working [Rust](https://www.rust-lang.org/) toolchain
118
+
119
+
#### Compiling
111
120
112
-
This will create a lightweight Linux VM using ```krunvm``` with the current working directory mapped inside it, and produce the Linux ELF binary from [init/init.c](init/init.c).
```libkrun``` has achieved maturity and starting version ```1.0.0``` the public API is guaranteed to be stable, following [SemVer](https://semver.org/).
169
180
170
-
### Known users
171
-
172
-
-[crun](https://github.com/containers/crun): An OCI runtime that can make use of libkrun to run containers with Virtualization-based isolation.
173
-
-[krunvm](https://github.com/slp/krunvm): A CLI tool for creating and running microVMs based on OCI images.
174
-
175
181
## Getting in contact
176
182
177
-
The main communication channel is the [VirTEE Matrix channel](https://matrix.to/#/#virtee:matrix.org).
183
+
The main communication channel is the [libkrun Matrix channel](https://matrix.to/#/#libkrun:matrix.org).
0 commit comments