Skip to content

Commit

Permalink
virt/qemu: add support for UTM
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Willemsen <[email protected]>
Signed-off-by: Christian Stewart <[email protected]>
  • Loading branch information
peterwilli authored and paralin committed Apr 14, 2024
1 parent cd921dd commit e8463b7
Show file tree
Hide file tree
Showing 11 changed files with 362 additions and 22 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ main SkiffOS repository:
| VirtualBox | [virt/virtualbox] | N/A | ✔ 6.8.4 |
| [Docker Img] | [virt/docker] | N/A | N/A |
| [Qemu] | [virt/qemu] | N/A | ✔ 6.8.4 |
| [UTM] on MacOS | [apple/arm] + [virt/qemu] | N/A | ✔ 6.8.4 |
| [V86] on WebAssembly | [browser/v86] | [V86] | ✔ 6.8.4 |
| [WSL] on Windows | [virt/wsl] | N/A | N/A |
|-----------------------|---------------------------|------------------|-----------------|
Expand Down Expand Up @@ -169,6 +170,7 @@ main SkiffOS repository:
[VisionFive2]: https://ameridroid.com/products/visionfive-2
[Steam Deck]: https://store.steampowered.com/steamdeck
[USBArmory Mk2]: https://github.com/f-secure-foundry/usbarmory
[UTM]: https://getutm.app/
[V86]: https://copy.sh/v86/?profile=copy/skiffos
[Wandboard]: https://elinux.org/Wandboard
[WSL]: https://docs.microsoft.com/en-us/windows/wsl/
Expand Down Expand Up @@ -345,6 +347,32 @@ $ ./scripts/push_image.bash root@my-ip-address

The SkiffOS upgrade (or downgrade) will take effect on next reboot.

### Compile on MacOS

Building directly on MacOS is not yet possible, particularly due to the
case-insensitivity of the MacOS file system. You can use Lima to build the OS:

[Install Lima](https://github.com/lima-vm/lima?tab=readme-ov-file#getting-started), then:

```bash
limactl start --name=skiffos-build https://raw.githubusercontent.com/skiffos/SkiffOS/master/build/lima/lima.yaml
limactl shell skiffos-build
```

Then in the lima shell:

```bash
cd
git clone https://github.com/skiffos/skiffos
cd skiffos
```

Proceed with usual build sequence.

See the [apple/arm] docs for building a VM to run on MacOS.

[apple/arm]: ./configs/apple/arm

### Podman

Use the `apps/podman` configuration package to enable Podman support.
Expand Down
53 changes: 53 additions & 0 deletions build/lima/lima.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
images:
- location: >-
https://cloud.debian.org/images/cloud/sid/daily/latest/debian-sid-genericcloud-arm64-daily.qcow2
arch: aarch64
provision:
# Automatically installing the dependencies for a successful ARM build (taken from https://github.com/skiffos/SkiffOS/?tab=readme-ov-file#getting-started)
- mode: boot
script: |
#!/bin/bash
apt-get update
set -eux -o pipefail
export DEBIAN_FRONTEND=noninteractive
apt-get install -y \
bash \
bc \
binutils \
build-essential \
bzip2 \
cpio \
diffutils \
file \
findutils \
git \
golang \
gzip \
libarchive-tools \
libncurses-dev \
make \
patch \
perl \
rsync \
sed \
tar \
unzip \
wget \
zsh
mounts:
- location: "/tmp/lima"
writable: true
- location: ~/skiffos-build
mountPoint: /opt/skiffos-build
writable: true

mountType: virtiofs
disk: 75GB
cpus: 8

# NOTE: This uses a "raw" disk format (unlike qemu).
# This is faster but uses disk space equal to the disk: option above!
# Not using this option will use less disk space.
# vmType: vz
34 changes: 19 additions & 15 deletions configs/apple/arm/README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
# Apple Macbook (ARM)
# Apple Silicon (ARM64)

This package supports the ARM64 Macbook Pros.
This package supports the ARM64 Macs.

Direct hardware support through [Asahi Linux] will be supported, but has not
been implemented yet. In the meantime, we support running with [UTM] on MacOS.
Support for booting SkiffOS natively with [Asahi Linux] has not been implemented yet.

[Asahi Linux]: https://asahilinux.org/

In the meantime, we support running with [UTM] on MacOS.

[UTM]: https://github.com/utmapp/UTM

## Setup
## Compiling

Install UTM on your Mac.
For compiling on MacOS, see [Compile on MacOS].

Compile SkiffOS on a Linux host:
[Compile on MacOS]: https://github.com/skiffos/SkiffOS?tab=readme-ov-file#compile-on-macos

```
export SKIFF_CONFIG=apple/arm,skiff/core
```bash
export SKIFF_CONFIG=apple/arm,skiff/core,virt/qemu
make configure compile
make cmd/virt/qemu/buildutm
```

Instructions on how to run using UTM will be added here soon (TODO).
Copy `workspaces/default/images/skiffos.utm` to your Mac, on Lima:

## Compiling on MacOS
```bash
cp workspaces/default/images/skiffos.utm /opt/skiffos-build
```

Compiling SkiffOS on MacOS is not yet supported.
## Running in UTM

You can compile it in any Linux environment or VM.
[Install UTM](https://getutm.app) on your MacOS machine.

Instructions on how to build using [lima] will be added here soon.
Run `open ~/skiffos-build` and double-click the skiffos.utm file to start the VM!

[lima]: https://github.com/lima-vm/lima
1 change: 1 addition & 0 deletions configs/apple/arm/buildroot/arch
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ BR2_aarch64=y

# The M1, M2, and M3 support armv8.5-a.
# Closest option we have: saphira => armv8.4a
# With qemu this requires -cpu max
BR2_saphira=y

This file was deleted.

22 changes: 22 additions & 0 deletions configs/virt/qemu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,25 @@ Log in as "root" for the default Skiff setup.

The `intel/x64` portion of `SKIFF_CONFIG` can be replaced with any of the
SkiffOS targets, including the arm and riscv64 systems.

## Using UTM on MacOS

For compiling on MacOS, see [Compile on MacOS].

[Compile on MacOS]: https://github.com/skiffos/SkiffOS?tab=readme-ov-file#compile-on-macos

```bash
export SKIFF_CONFIG=apple/arm,skiff/core,virt/qemu
make configure compile
make cmd/virt/utm/buildutm
```

Copy `workspaces/default/images/skiffos.utm` to your Mac, on Lima:

```
cp workspaces/default/images/skiffos.utm /opt/skiffos-build
```

[Install UTM](https://getutm.app) on your MacOS machine.

Run `open ~/skiffos-build` and double-click the skiffos.utm file to start the VM!
2 changes: 0 additions & 2 deletions configs/virt/qemu/buildroot/tools
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
BR2_PACKAGE_HOST_QEMU=y
BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y
BR2_PACKAGE_HOST_QEMU_VIRTFS=y
BR2_PACKAGE_HOST_E2FSPROGS=y
BR2_PACKAGE_HOST_GENEXT2FS=y
3 changes: 3 additions & 0 deletions configs/virt/qemu/extensions/Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
run:
@$(SKIFF_CURRENT_CONF_DIR)/scripts/execute_qemu.sh

buildutm:
@$(SKIFF_CURRENT_CONF_DIR)/scripts/buildutm.sh
191 changes: 191 additions & 0 deletions configs/virt/qemu/resources/utm-config.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Backend</key>
<string>QEMU</string>
<key>ConfigurationVersion</key>
<integer>4</integer>
<key>Display</key>
<array>
<dict>
<key>DownscalingFilter</key>
<string>Linear</string>
<key>DynamicResolution</key>
<true/>
<key>Hardware</key>
<string>virtio-gpu-pci</string>
<key>NativeResolution</key>
<false/>
<key>UpscalingFilter</key>
<string>Nearest</string>
</dict>
</array>
<key>Drive</key>
<array>
<dict>
<key>Identifier</key>
<string>1a69bb72-4f95-4525-95b6-a228ceb8ee74</string>
<key>ImageName</key>
<string>Image</string>
<key>ImageType</key>
<string>LinuxKernel</string>
<key>Interface</key>
<string>None</string>
<key>InterfaceVersion</key>
<integer>1</integer>
<key>ReadOnly</key>
<false/>
</dict>
<dict>
<key>Identifier</key>
<string>de859e3e-ea2d-4c5b-beb1-0693160e884e</string>
<key>ImageName</key>
<string>rootfs.cpio.lz4</string>
<key>ImageType</key>
<string>LinuxInitrd</string>
<key>Interface</key>
<string>None</string>
<key>InterfaceVersion</key>
<integer>1</integer>
<key>ReadOnly</key>
<false/>
</dict>
<dict>
<key>Identifier</key>
<string>81204ce1-bebe-458a-be45-f19b6eebe4c5</string>
<key>ImageName</key>
<string>persist.qcow2</string>
<key>ImageType</key>
<string>Disk</string>
<key>Interface</key>
<string>VirtIO</string>
<key>InterfaceVersion</key>
<integer>1</integer>
<key>ReadOnly</key>
<false/>
</dict>
</array>
<key>Information</key>
<dict>
<key>Icon</key>
<string>skiff-icon.png</string>
<key>IconCustom</key>
<true/>
<key>Name</key>
<string>SkiffOS</string>
<key>UUID</key>
<string>20c05852-ae8c-49e8-bc99-7f7db953aed0</string>
</dict>
<key>Input</key>
<dict>
<key>MaximumUsbShare</key>
<integer>3</integer>
<key>UsbBusSupport</key>
<string>3.0</string>
<key>UsbSharing</key>
<false/>
</dict>
<key>Network</key>
<array>
<dict>
<key>Hardware</key>
<string>virtio-net-pci</string>
<key>IsolateFromHost</key>
<false/>
<key>MacAddress</key>
<string>REPLACEME_MAC_ADDRESS</string>
<key>Mode</key>
<string>Shared</string>
<key>PortForward</key>
<array/>
</dict>
</array>
<key>QEMU</key>
<dict>
<key>AdditionalArguments</key>
<array>
<string>-append</string>
<string>"root=/dev/ram0 ro net.ifnames=0"</string>
</array>
<key>BalloonDevice</key>
<false/>
<key>DebugLog</key>
<false/>
<key>Hypervisor</key>
<true/>
<key>PS2Controller</key>
<false/>
<key>RNGDevice</key>
<true/>
<key>RTCLocalTime</key>
<false/>
<key>TPMDevice</key>
<false/>
<key>TSO</key>
<false/>
<key>UEFIBoot</key>
<true/>
</dict>
<key>Serial</key>
<array>
<dict>
<key>Mode</key>
<string>Terminal</string>
<key>Target</key>
<string>Auto</string>
<key>Terminal</key>
<dict>
<key>BackgroundColor</key>
<string>#000000</string>
<key>CursorBlink</key>
<true/>
<key>Font</key>
<string>Menlo</string>
<key>FontSize</key>
<integer>12</integer>
<key>ForegroundColor</key>
<string>#ffffff</string>
</dict>
</dict>
</array>
<key>Sharing</key>
<dict>
<key>ClipboardSharing</key>
<true/>
<key>DirectoryShareMode</key>
<string>VirtFS</string>
<key>DirectoryShareReadOnly</key>
<false/>
</dict>
<key>Sound</key>
<array>
<dict>
<key>Hardware</key>
<string>intel-hda</string>
</dict>
</array>
<key>System</key>
<dict>
<key>Architecture</key>
<string>aarch64</string>
<key>CPU</key>
<string>default</string>
<key>CPUCount</key>
<integer>0</integer>
<key>CPUFlagsAdd</key>
<array/>
<key>CPUFlagsRemove</key>
<array/>
<key>ForceMulticore</key>
<false/>
<key>JITCacheSize</key>
<integer>0</integer>
<key>MemorySize</key>
<integer>4096</integer>
<key>Target</key>
<string>virt</string>
</dict>
</dict>
</plist>

Loading

0 comments on commit e8463b7

Please sign in to comment.