Skip to content

Commit 1b358af

Browse files
raiden00placassis
authored andcommitted
Documentation: add notes about TAP configuration for qemu
add notes how to configure QEMU network with TAP. Signed-off-by: raiden00pl <[email protected]>
1 parent 67e3266 commit 1b358af

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

Documentation/guides/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,5 @@ Guides
6060
remove_device_drivers_nsh.rst
6161
rust.rst
6262
optee.rst
63+
qemu_tips.rst
6364

Documentation/guides/qemu_tips.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
=========
2+
QEMU Tips
3+
=========
4+
5+
Netowrking with TAP device
6+
==========================
7+
8+
Step 1: Configure NuttX network with ``NETUTILS_NETINIT``::
9+
10+
CONFIG_NETUTILS_NETINIT=y
11+
CONFIG_NETINIT_IPADDR=0xc0a80868 # Target: 192.168.8.104
12+
CONFIG_NETINIT_DRIPADDR=0xc0a80801 # Router: 192.168.8.1
13+
CONFIG_NETINIT_NETMASK=0xffffff00 # Mask: 255.255.255.0
14+
15+
Step 2: Create and configure a TAP device on the host::
16+
17+
# Create the bridge
18+
sudo ip link add name br0 type bridge
19+
sudo ip link set br0 up
20+
21+
# Create the tap interface
22+
sudo ip tuntap add dev tap0 mode tap
23+
sudo ip link set tap0 master br0
24+
sudo ip link set tap0 up
25+
26+
# (optional) also attach your real NIC if you want LAN access
27+
# sudo ip link set enp3s0 master br0
28+
29+
# Assign IP to the *bridge*
30+
sudo ip addr add 192.168.8.1/24 dev br0
31+
32+
Step 3: Launch QEMU using the TAP interface::
33+
34+
qemu-system-x86_64 -m 2G -smp 4 -cpu host -enable-kvm \
35+
-kernel nuttx -nographic -serial mon:stdio \
36+
-device e1000,netdev=mynet0 \
37+
-netdev tap,id=mynet0,ifname=tap0,script=no,downscript=no
38+
39+
Step 4: Clean up::
40+
41+
sudo ip link set tap0 down
42+
sudo ip link set br0 down
43+
sudo ip tuntap del dev tap0 mode tap
44+
sudo ip link del br0

Documentation/platforms/x86_64/intel64/boards/qemu-intel64/index.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ qemu-intel64
55
This page file describes the contents of the build configurations available
66
for the NuttX QEMU x86_64 port.
77

8-
9-
108
QEMU/KVM
119
========
1210

@@ -187,6 +185,13 @@ Command to run the image with some xHCI devices attached::
187185
-kernel nuttx -serial mon:stdio -chardev pty,id=ch1 \
188186
-device qemu-xhci -device usb-mouse -device usb-kbd
189187

188+
Command to run the image with e1000 NIC device with TAP::
189+
190+
qemu-system-x86_64 -m 2G -smp 4 -cpu host -enable-kvm \
191+
-kernel nuttx -nographic -serial mon:stdio \
192+
-device e1000,netdev=mynet0 \
193+
-netdev tap,id=mynet0,ifname=tap0,script=no,downscript=no
194+
190195
knsh_romfs
191196
----------
192197

0 commit comments

Comments
 (0)