Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples #11

Merged
merged 9 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# SPDX-License-Identifier: GPL-3.0-or-later
SHELLCHECK := $(shell command -v shellcheck 2>/dev/null)

check:
Expand Down
1 change: 1 addition & 0 deletions contrib/generate-cloud-config-seed-freebsd.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-3.0-or-later

set -euo pipefail

Expand Down
1 change: 1 addition & 0 deletions contrib/generate-cloud-config-seed.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-3.0-or-later

set -euo pipefail

Expand Down
36 changes: 26 additions & 10 deletions examples/vm/aarch64-virt-base.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# Configuration variables
#
# GUEST_DISPLAY Set to '1' to enable graphical output
# GUEST_DISPLAY Display option (QEMU -display parameter).
# GUEST_VIOMMU Set to '1' to add a virtual IOMMU to the machine
# GUEST_CPU CPU model (QEMU -cpu paramater, default: 'host')
# GUEST_SMP SMP configuration (QEMU -smp parameter, default: '4')
Expand All @@ -16,35 +16,51 @@
# Extra parameters to add to the kernel "command
# line".

QEMU_SYSTEM_BINARY="$HOME/work/src/qemu/build/aarch64-softmmu/qemu-system-aarch64"
GUEST_BOOT_BASE="img/debian-11-genericcloud-arm64.qcow2"
if [[ -f "common.conf" ]]; then
source "common.conf"
fi

: "${GUEST_DISPLAY:="1"}"
: "${GUEST_CPU:="cortex-a57"}"
QEMU_SYSTEM_BINARY=${QEMU_SYSTEM_AARCH64}
: "${GUEST_BOOT_BASE:="img/debian-11-genericcloud-arm64.qcow2"}"

: "${GUEST_DISPLAY:=""}"
: "${GUEST_CPU:="host"}"
: "${GUEST_MEMORY:="2G"}"
: "${GUEST_ACCEL:="kvm"}"
: "${GUEST_GDB_PORT:=""}"
: "${GUEST_NET_USER_HOSTFWDS:="tcp::${GUEST_SSH_PORT}-:22"}"
: "${GUEST_BOOT:="$GUEST_BOOT_BASE"}"
: "${GUEST_KERNEL_IMAGE:="arch/arm64/boot/Image"}"
: "${GUEST_KERNEL_APPEND_EXTRA:="audit=0 earlyprintk=serial"}"
: "${GUEST_KERNEL_CONSOLE:="ttyAMA0"}"

_setup_aarch64_virt_base() {
QEMU_PARAMS+=("-nographic")
QEMU_PARAMS+=("-nodefaults")

if [[ $GUEST_DISPLAY -eq 0 ]]; then
#QEMU_PARAMS+=("-display" "none")
if [[ -z $GUEST_DISPLAY ]]; then
QEMU_PARAMS+=("-nographic")
else
QEMU_PARAMS+=("-device" "virtio-gpu-pci")
QEMU_PARAMS+=("-display" "$GUEST_DISPLAY")
QEMU_PARAMS+=("-device" "virtio-keyboard-pci")
QEMU_PARAMS+=("-device" "virtio-mouse-pci")
QEMU_PARAMS+=("-device" "qemu-xhci")
QEMU_PARAMS+=("-device" "usb-tablet")
fi

QEMU_PARAMS+=("-machine" "virt")
QEMU_PARAMS+=("-machine" "virt,accel=$GUEST_ACCEL,kernel-irqchip=split")
QEMU_PARAMS+=("-cpu" "$GUEST_CPU")
QEMU_PARAMS+=("-smp" "1")
QEMU_PARAMS+=("-m" "$GUEST_MEMORY")

QEMU_PARAMS+=("-bios" "/usr/share/edk2-armvirt/aarch64/QEMU_EFI.fd")
QEMU_PARAMS+=("-bios" "$QEMU_EDK2_AARCH64")
#QEMU_PARAMS+=("-pflash" "/tmp/flash0.img")
#QEMU_PARAMS+=("-pflash" "/tmp/flash1.img")

if [[ -n $GUEST_GDB_PORT ]]; then
QEMU_PARAMS+=("-gdb" "tcp::$GUEST_GDB_PORT")
fi

# simple user-level networking
QEMU_PARAMS+=("-netdev" "user,id=net0,hostfwd=${GUEST_NET_USER_HOSTFWDS}")
QEMU_PARAMS+=("-device" "virtio-net-pci,netdev=net0")
Expand Down
4 changes: 2 additions & 2 deletions examples/vm/common.conf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

# vmctl run parameters
QEMU_SYSTEM_BINARY="/usr/local/bin/qemu-system-x86_64"
QEMU_IMG="/usr/local/bin/qemu-img"
QEMU_IMG=$(/usr/bin/which qemu-img)
QEMU_EDK2_AARCH64="/usr/share/edk2-armvirt/aarch64/QEMU_EFI.fd"
GUEST_KERNEL_APPEND_EXTRA="audit=0"
GUEST_KERNEL_BOOTDEV="/dev/vda1"

Expand Down
28 changes: 28 additions & 0 deletions examples/vm/nvme-aarch64.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

QEMU_SYSTEM_AARCH64=$(/usr/bin/which qemu-system-aarch64)
GUEST_BOOT_BASE="img/debian-13-genericcloud-arm64.qcow2"

source "aarch64-virt-base.conf"

_setup_nvme_aarch64() {
# setup basevm
_setup_aarch64_virt_base

# pcie root port
qemu_pcie_add_root_port "pcie_root_port0" \
--chassis 1 --slot 0

# nvme controller
qemu_nvme_add_ctrl "nvme0" \
--serial "deadbeef" \
--port "pcie_root_port0" \
--extra "mdts=7"

# nvme namespace
qemu_nvme_add_ns "nvm" \
--nsid "1" \
--ctrl "nvme0" \
--size "1G" \
--extra "$default_nvme_ns_extra"
}
28 changes: 28 additions & 0 deletions examples/vm/nvme-cortex-a57.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

GUEST_BOOT_BASE="img/debian-13-genericcloud-arm64.qcow2"
GUEST_CPU="cortex-a57"

source "aarch64-virt-base.conf"

_setup_nvme_aarch64() {
# setup basevm
_setup_aarch64_virt_base

# pcie root port
qemu_pcie_add_root_port "pcie_root_port0" \
--chassis 1 --slot 0

# nvme controller
qemu_nvme_add_ctrl "nvme0" \
--serial "deadbeef" \
--port "pcie_root_port0" \
--extra "mdts=7"

# nvme namespace
qemu_nvme_add_ns "nvm" \
--nsid "1" \
--ctrl "nvme0" \
--size "1G" \
--extra "$default_nvme_ns_extra"
}
2 changes: 2 additions & 0 deletions examples/vm/nvme.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

QEMU_SYSTEM_X86_64=$(/usr/bin/which qemu-system-x86_64)

source "x86_64-q35-base.conf"

_setup_nvme() {
Expand Down
7 changes: 7 additions & 0 deletions examples/vm/x86_64-q35-base.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ if [[ -f "common.conf" ]]; then
source "common.conf"
fi

QEMU_SYSTEM_BINARY=${QEMU_SYSTEM_X86_64}

: "${GUEST_DISPLAY:="0"}"
: "${GUEST_VIOMMU:="1"}"
: "${GUEST_CPU:="host"}"
: "${GUEST_SMP:="4"}"
: "${GUEST_MEMORY:="8G"}"
: "${GUEST_GDB_PORT:=""}"
: "${GUEST_NET_USER_HOSTFWDS:="tcp::${GUEST_SSH_PORT}-:22"}"
: "${GUEST_BOOT_BASE:="img/base.qcow2"}"
: "${GUEST_BOOT:="$GUEST_BOOT_BASE"}"
Expand All @@ -44,6 +47,10 @@ _setup_x86_64_q35_base() {
QEMU_PARAMS+=("-smp" "$GUEST_SMP")
QEMU_PARAMS+=("-m" "$GUEST_MEMORY")

if [[ -n $GUEST_GDB_PORT ]]; then
QEMU_PARAMS+=("-gdb" "tcp::$GUEST_GDB_PORT")
fi

# guest iommu
if [[ $GUEST_VIOMMU -ne 0 ]]; then
QEMU_PARAMS+=("-device" "intel-iommu,intremap=on")
Expand Down
Loading