qemu: add option to enable SLiRP user networking
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Igor Opaniuk <igor.opaniuk@linaro.org>
[Rebase on top of master]
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
diff --git a/common.mk b/common.mk
index 48cd45b..6478d8b 100644
--- a/common.mk
+++ b/common.mk
@@ -29,6 +29,8 @@
QEMU_VIRTFS_ENABLE ?= n
QEMU_VIRTFS_HOST_DIR ?= $(ROOT)
+# Enable SLiRP user networking
+QEMU_USERNET_ENABLE ?= n
################################################################################
# Check coherency of compilation mode
################################################################################
@@ -196,6 +198,11 @@
-fsdev local,id=fsdev0,path=$(QEMU_VIRTFS_HOST_DIR),security_model=none \
-device virtio-9p-device,fsdev=fsdev0,mount_tag=host
endif
+
+ifeq ($(QEMU_USERNET_ENABLE),y)
+QEMU_EXTRA_ARGS +=\
+ -netdev user,id=vmnic -device virtio-net-device,netdev=vmnic
+endif
################################################################################
# OP-TEE
################################################################################
@@ -301,6 +308,10 @@
"$(HELLOWORLD_PATH)/ta/8aaaf200-2450-11e4-abe2-0002a5d5c51b.ta" \
"444 0 0" >> $(fl); \
fi
+ @if [ "$(QEMU_USERNET_ENABLE)" = "y" ]; then \
+ echo "slink /etc/rc.d/S02_udhcp_networking /etc/init.d/udhcpc 755 0 0" \
+ >> $(fl); \
+ fi
@echo "# Secure storage dir" >> $(fl)
@echo "dir /data 755 0 0" >> $(fl)
@echo "dir /data/tee 755 0 0" >> $(fl)
diff --git a/docs/qemu.md b/docs/qemu.md
index dce9261..7970924 100644
--- a/docs/qemu.md
+++ b/docs/qemu.md
@@ -4,7 +4,8 @@
1. [Introduction](#1-introduction)
2. [Regular build](#2-regular-build)
3. [Install files on the device](#3-qemu-console)
-4. [Host-Guest folder sharing in QEMU/QEMUv8 configurations](#4-host-guest-folder-sharing-in-qemuqemuv8-configurations)
+4. [Host-Guest folder sharing](#4-host-guest-folder-sharing)
+5. [SLiRP user networking](#5-slirp-user-networking)
# 1. Introduction
The instructions here will tell how to run OP-TEE using QEMU. We have two
@@ -31,12 +32,12 @@
## 3.2 ARMv8-A
It won't stop, it will just boot up QEMU and OP-TEE.
-#4. Host-Guest folder sharing in QEMU/QEMUv8 configurations
+# 4. Host-Guest folder sharing
To avoid changing rootfs CPIO archive each time you need to add additional files
to it, you can also use VirtFS QEMU feature to share a folder between the guest
and host operating systems. To use this feature enable VirtFS QEMU build in
-build/common.mk (set QEMU_VIRTFS_ENABLE ?= y), adjust QEMU_VIRTFS_HOST_DIR and
+build/common.mk (set `QEMU_VIRTFS_ENABLE ?= y`), adjust `QEMU_VIRTFS_HOST_DIR` and
rebuild QEMU.
To mount host folder in QEMU, simply run:
@@ -44,6 +45,12 @@
```bash
$ mount_shared <mount_point>
```
+# 5. SLiRP user networking
+To enable SLiRP user networking just set `QEMU_USERNET_ENABLE ?= y` in `common.mk`.
+After booting QEMU VM, eth0 will automatically receive IP address via DHCP
+
+*Important* Take into account that ICMP doesn't work in SLiRP mode,
+so `ping` utility won't work.
[bios]: https://github.com/linaro-swg/bios_qemu_tz_arm
[README.md]: ../README.md