Enable kvm

This commit is contained in:
geens 2025-07-07 18:21:48 +02:00
parent f457489375
commit fa0cd762ca
4 changed files with 11 additions and 5 deletions

View File

@ -48,8 +48,11 @@ ENV LC_ALL=en_US.UTF-8
# Create build user matching host UID/GID
ARG USER_ID=1000
ARG GROUP_ID=1000
ARG KVM_GID=992
RUN groupadd -g ${GROUP_ID} builder && \
useradd -u ${USER_ID} -g ${GROUP_ID} -ms /bin/bash builder
useradd -u ${USER_ID} -g ${GROUP_ID} -ms /bin/bash builder && \
groupadd -g ${KVM_GID} kvm && \
usermod -a -G kvm builder
# Enable compiler cache for performance
ENV USE_CCACHE=1

View File

@ -30,6 +30,7 @@ services:
args:
USER_ID: ${USER_ID:-1000}
GROUP_ID: ${GROUP_ID:-1000}
KVM_GID: ${KVM_GID:-992}
container_name: qemu-server
hostname: qemu-server
working_dir: /workspace
@ -37,15 +38,15 @@ services:
volumes:
- ./:/workspace
- ../:/repo
devices:
- /dev/kvm:/dev/kvm
tty: true
stdin_open: true
depends_on:
- disk-image
command: >
bash -c "
echo 'Starting QEMU with host networking...' &&
echo 'VNC will be available on localhost:5901' &&
echo 'SSH will be available on localhost:2222' &&
echo 'QEMU monitor on localhost:4444' &&
qemu-system-x86_64 -cpu core2duo -m 2048 -smp 2 -kernel /workspace/build/tmp/deploy/images/genericx86-64/bzImage -drive file=/workspace/build/tmp/deploy/images/genericx86-64/fcb-looper-image-genericx86-64.rootfs.ext4,if=virtio,format=raw -netdev user,id=net0,hostfwd=tcp:127.0.0.1:2222-:22,hostfwd=tcp:127.0.0.1:8080-:8080 -device virtio-net-pci,netdev=net0 -device virtio-vga -vnc 127.0.0.1:1 -monitor telnet:127.0.0.1:4444,server,nowait -serial stdio -append 'root=/dev/vda rw console=ttyS0 console=tty0'
qemu-system-x86_64 -accel kvm -cpu host -m 4096 -smp 4 -kernel /workspace/build/tmp/deploy/images/genericx86-64/bzImage -drive file=/workspace/build/tmp/deploy/images/genericx86-64/fcb-looper-image-genericx86-64.rootfs.ext4,if=virtio,format=raw,cache=writeback -netdev user,id=net0,hostfwd=tcp:127.0.0.1:2222-:22,hostfwd=tcp:127.0.0.1:8080-:8080 -device virtio-net-pci,netdev=net0 -device virtio-vga -vnc 127.0.0.1:1 -monitor telnet:127.0.0.1:4444,server,nowait -serial stdio -append 'root=/dev/vda rw console=ttyS0 console=tty0'
"

View File

@ -15,7 +15,6 @@ ExecStartPre=/bin/sleep 3
ExecStart=/usr/bin/gui
Restart=always
RestartSec=5
WatchdogSec=30
# Resource limits
MemoryMax=256M
CPUQuota=80%

View File

@ -9,6 +9,9 @@ set -e
export USER_ID=$(id -u)
export GROUP_ID=$(id -g)
# Get KVM group ID for hardware acceleration
export KVM_GID=$(getent group kvm | cut -d: -f3)
# Check if service name is provided
if [ $# -eq 0 ]; then
echo "Usage: $0 <service> [additional args...]"