Enable kvm
This commit is contained in:
parent
f457489375
commit
fa0cd762ca
@ -48,8 +48,11 @@ ENV LC_ALL=en_US.UTF-8
|
|||||||
# Create build user matching host UID/GID
|
# Create build user matching host UID/GID
|
||||||
ARG USER_ID=1000
|
ARG USER_ID=1000
|
||||||
ARG GROUP_ID=1000
|
ARG GROUP_ID=1000
|
||||||
|
ARG KVM_GID=992
|
||||||
RUN groupadd -g ${GROUP_ID} builder && \
|
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
|
# Enable compiler cache for performance
|
||||||
ENV USE_CCACHE=1
|
ENV USE_CCACHE=1
|
||||||
|
|||||||
@ -30,6 +30,7 @@ services:
|
|||||||
args:
|
args:
|
||||||
USER_ID: ${USER_ID:-1000}
|
USER_ID: ${USER_ID:-1000}
|
||||||
GROUP_ID: ${GROUP_ID:-1000}
|
GROUP_ID: ${GROUP_ID:-1000}
|
||||||
|
KVM_GID: ${KVM_GID:-992}
|
||||||
container_name: qemu-server
|
container_name: qemu-server
|
||||||
hostname: qemu-server
|
hostname: qemu-server
|
||||||
working_dir: /workspace
|
working_dir: /workspace
|
||||||
@ -37,15 +38,15 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- ./:/workspace
|
- ./:/workspace
|
||||||
- ../:/repo
|
- ../:/repo
|
||||||
|
devices:
|
||||||
|
- /dev/kvm:/dev/kvm
|
||||||
tty: true
|
tty: true
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
depends_on:
|
|
||||||
- disk-image
|
|
||||||
command: >
|
command: >
|
||||||
bash -c "
|
bash -c "
|
||||||
echo 'Starting QEMU with host networking...' &&
|
echo 'Starting QEMU with host networking...' &&
|
||||||
echo 'VNC will be available on localhost:5901' &&
|
echo 'VNC will be available on localhost:5901' &&
|
||||||
echo 'SSH will be available on localhost:2222' &&
|
echo 'SSH will be available on localhost:2222' &&
|
||||||
echo 'QEMU monitor on localhost:4444' &&
|
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'
|
||||||
"
|
"
|
||||||
@ -15,7 +15,6 @@ ExecStartPre=/bin/sleep 3
|
|||||||
ExecStart=/usr/bin/gui
|
ExecStart=/usr/bin/gui
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=5
|
RestartSec=5
|
||||||
WatchdogSec=30
|
|
||||||
# Resource limits
|
# Resource limits
|
||||||
MemoryMax=256M
|
MemoryMax=256M
|
||||||
CPUQuota=80%
|
CPUQuota=80%
|
||||||
|
|||||||
@ -9,6 +9,9 @@ set -e
|
|||||||
export USER_ID=$(id -u)
|
export USER_ID=$(id -u)
|
||||||
export GROUP_ID=$(id -g)
|
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
|
# Check if service name is provided
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
echo "Usage: $0 <service> [additional args...]"
|
echo "Usage: $0 <service> [additional args...]"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user