Skip to content

Commit

Permalink
Add custom qemu target
Browse files Browse the repository at this point in the history
  • Loading branch information
vlasakm committed Dec 9, 2022
1 parent 0290919 commit 720bd64
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tools/labs/qemu/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.PHONY: qemu clean

QEMU_DISPLAY ?= none
ARCH ?= x86
ifeq ($(ARCH),x86)
Expand Down Expand Up @@ -32,6 +34,46 @@ QEMU_OPTS += -enable-kvm -cpu host
ENABLE_KVM_SUDO = sudo
endif

# Run with:
# make -j$(nproc)

# Compile in skel directories with something like:
# alias kmake='make -C "$HOME/src/linux/" M="$(pwd)"'
# kmake

# .ssh/config
# Host osy
# HostName localhost
# Port 2222
# User root
# HostkeyAlgorithms +ssh-rsa
# PubkeyAcceptedAlgorithms +ssh-rsa

# Mount SMB (if automount fails)
# mount -a
# or if customization is needed:
# mount -t cifs -o guest,user=guest //10.0.2.4/qemu skels

# For GUI change:
# -append "root=/dev/vda console=ttyS0 loglevel=15 TERM=xterm" \
# -nographic \
# to:
# -append "root=/dev/vda loglevel=15" \
# -display sdl \
qemu: $(ZIMAGE) $(YOCTO_IMAGE)
qemu-system-i386 \
-enable-kvm -cpu host \
-smp 2 -m 2048 \
-no-reboot \
-nographic \
-drive file=$(YOCTO_IMAGE),if=virtio,format=raw \
-nic user,hostfwd=tcp::2222-:22,smb=$(shell readlink -f skels) \
-kernel $(ZIMAGE) \
-append "root=/dev/vda console=ttyS0 loglevel=15 TERM=xterm" \
-nographic \
-gdb tcp::1234

boot: .modinst tap0 tap1 pipe1.in pipe1.out pipe2.in pipe2.out disk1.img disk2.img nttcp-run
$(ENABLE_KVM_SUDO) ARCH=$(ARCH) qemu/qemu.sh $(QEMU_OPTS)

Expand Down
8 changes: 8 additions & 0 deletions tools/labs/qemu/prepare-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ cat >> $TMP/etc/inittab <<EOF
5:12345:respawn:/sbin/getty 38400 tty5
EOF

cat >> $TMP/etc/fstab <<EOF
//10.0.2.4/qemu /home/root/skels cifs guest,user=guest 0 0
EOF

mkdir -p $TMP/root/skels

sed -i '/^root/ s@/bin/sh@/bin/bash@' $TMP/etc/passwd

# enable networking
echo -e "auto eth0\niface eth0 inet dhcp" >> $TMP/etc/network/interfaces

Expand Down

0 comments on commit 720bd64

Please sign in to comment.