Skip to content

Commit 3d83727

Browse files
committed
feat: launch opensuse in separate container with kvm
1 parent 942adf6 commit 3d83727

6 files changed

Lines changed: 58 additions & 8 deletions

File tree

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ DOCKER_PREFIX := ${LIB_NAME}
66
DOCKER_TAG := ${DOCKER_PREFIX}-yocto-builder
77
DOCKER_SUSE_TAG := ${DOCKER_PREFIX}-open-suse-env
88
DOCKER_PYTHON_TAG := ${DOCKER_PREFIX}-analyzer
9+
DOCKER_SUSE_VM_TAG := ${DOCKER_PREFIX}-suse-vm
910
DOCKER_BUILD_VOLUME := ${DOCKER_PREFIX}-yocto-build
1011
DOCKER_DOWNLOADS_VOLUME := ${DOCKER_PREFIX}-yocto-downloads
1112
DOCKER_SSTATE_VOLUME := ${DOCKER_PREFIX}-yocto-sstate

docker/compose.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,28 @@ services:
5151
environment:
5252
S_USER: ${S_USER}
5353
PASSWORD: ${PASSWORD}
54-
VM_RAM: ${QEMU_VM_RAM}
55-
CPUS: ${CPUS}
54+
networks:
55+
- yocto-network
56+
57+
imgtests-suse-vm:
58+
build:
59+
dockerfile: docker/vm-suse.dockerfile
60+
args:
61+
USER: ${USER}
62+
image: ${DOCKER_SUSE_VM_TAG}
63+
privileged: true
64+
devices:
65+
- /dev/kvm
66+
volumes:
67+
- ${DOCKER_OPENSUSE_VOLUME}:${SUSE_DIR}
68+
environment:
5669
SSH_QEMU_PORT: ${SSH_TO_QEMU_PORT}
5770
SSH_SUSE_PORT: ${SSH_SUSE_PORT_156}
5871
SUSE_NE_PORT: ${SUSE_156_NE_PORT}
5972
DEFAULT_NE_PORT: ${DEFAULT_NE_PORT}
6073
IPERF3_PORT: ${IPERF3_PORT}
74+
VM_RAM: ${QEMU_VM_RAM}
75+
CPUS: ${CPUS}
6176
ports:
6277
- ${SSH_SUSE_PORT_156}:${SSH_SUSE_PORT_156}
6378
networks:

docker/open-suse.dockerfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ ENV DEBIAN_FRONTEND=noninteractive \
77

88
RUN apt-get update && \
99
apt-get install -y --no-install-recommends \
10-
qemu-system \
11-
qemu-utils \
12-
qemu-user-static \
1310
cloud-init \
1411
cloud-image-utils \
1512
wget \

docker/vm-suse.dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM ubuntu:24.04
2+
3+
ARG USER
4+
5+
ENV DEBIAN_FRONTEND=noninteractive \
6+
SUSE_DIR=/home/${USER}/suse
7+
8+
RUN apt-get update && \
9+
apt-get install -y --no-install-recommends \
10+
qemu-system \
11+
qemu-utils \
12+
qemu-user-static
13+
14+
WORKDIR ${SUSE_DIR}
15+
16+
COPY scripts/opensuse/start-vm.sh /start-vm.sh
17+
RUN chmod +x /start-vm.sh
18+
19+
ENTRYPOINT ["/start-vm.sh"]

scripts/opensuse/start-vm.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
cd "${SUSE_DIR}"
6+
7+
echo "Waiting for OpenSUSE image to be ready..."
8+
while true; do
9+
for img in open-suse-*.ready.qcow2; do
10+
[ -f "$img" ] && IMAGE="$img" && break 2
11+
done
12+
sleep 10
13+
done
14+
15+
exec qemu-system-x86_64 -enable-kvm -m "${VM_RAM}" -smp "${CPUS}" -nographic \
16+
-monitor tcp:0.0.0.0:4444,server,nowait \
17+
-drive file="$IMAGE",index=0,media=disk \
18+
-cdrom cloud-init.iso \
19+
-net user,hostfwd=tcp::"${SSH_SUSE_PORT}"-:"${SSH_QEMU_PORT}",hostfwd=tcp::"${SUSE_NE_PORT}"-:"${DEFAULT_NE_PORT}",hostfwd=tcp:0.0.0.0:"${IPERF3_PORT}"-:"${IPERF3_PORT}",hostfwd=udp:0.0.0.0:"${IPERF3_PORT}"-:"${IPERF3_PORT}" \
20+
-net nic

scripts/opensuse/suse-compose.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@ set -e
44

55
./scripts/download_images.py "$1"
66
./scripts/cloud-setup.sh "${S_USER}" "${PASSWORD}"
7-
CPUS=4
8-
qemu-system-x86_64 -m "${VM_RAM}" -smp "${CPUS}" -nographic -monitor tcp:0.0.0.0:4444,server,nowait -drive file=open-suse-"$1".ready.qcow2,index=0,media=disk \
9-
-cdrom cloud-init.iso -net user,hostfwd=tcp::"${SSH_SUSE_PORT}"-:"${SSH_QEMU_PORT}",hostfwd=tcp::"${SUSE_NE_PORT}"-:"${DEFAULT_NE_PORT}",hostfwd=tcp:0.0.0.0:"${IPERF3_PORT}"-:"${IPERF3_PORT}",hostfwd=udp:0.0.0.0:"${IPERF3_PORT}"-:"${IPERF3_PORT}" -net nic
7+
echo "Image is ready. VM will be started by imgtests-suse-vm container."

0 commit comments

Comments
 (0)