QEMU Aarch64 and networking connections
6,718
I was getting same warnings while I used the obsolete -net
option. Then I changed it to this:
-netdev tap,ifname=tap0,script=no,downscript=no,id=my_net_id \
-device driver=virtio-net,netdev=my_net_id
It fixed the problem.
Related videos on Youtube
Author by
Admin
Updated on September 18, 2022Comments
-
Admin over 1 year
I just set up an ARM64 image using QEMU and I'm trying to access the internet from within the binary. The host OS(Ubuntu) receives internet from the
eth0
interface. I have thetap0
interface set up. I've addedtap0
andeth0
tovirbr0
.$ brctl show virbr0 bridge name bridge id STP enabled interfaces virbr0 8000.080027c9997e yes eth0 tap0
Now, I try to start the VM as follows :-
sudo qemu-system-aarch64 -machine virt -cpu cortex-a57 -nographic -smp 1 -m 512 \ -global virtio-blk-device.scsi=off -device virtio-scsi-device,id=scsi \ -drive file=ubuntu-core-14.04.1-core-arm64.img,id=coreimg,cache=unsafe,if=none -device scsi-hd,drive=coreimg \ -kernel vmlinuz-3.13.0-55-generic \ -initrd initrd.img-3.13.0-55-generic \ -netdev user,id=unet -device virtio-net-device,netdev=unet \ -net nic -net tap,ifname=tap0,script=no,downscript=no \ --append "console=ttyAMA0 root=/dev/sda"
The output of ifconfig on host is as follows :-
$ ifconfig eth0 Link encap:Ethernet HWaddr 08:00:27:c9:99:7e inet6 addr: fe80::a00:27ff:fec9:997e/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2942 errors:0 dropped:0 overruns:0 frame:0 TX packets:7889 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:239227 (239.2 KB) TX bytes:557156 (557.1 KB) tap0 Link encap:Ethernet HWaddr 8e:3d:c3:0e:58:36 inet6 addr: fe80::8c3d:c3ff:fe0e:5836/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:412 errors:0 dropped:427 overruns:0 carrier:0 collisions:0 txqueuelen:500 RX bytes:0 (0.0 B) TX bytes:21432 (21.4 KB) virbr0 Link encap:Ethernet HWaddr 08:00:27:c9:99:7e inet addr:10.0.2.15 Bcast:0.0.0.0 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2928 errors:0 dropped:0 overruns:0 frame:0 TX packets:2940 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:195163 (195.1 KB) TX bytes:236587 (236.5 KB)
Once I start the VM, the output of ifconfig is as follows.
root@localhost:~# ifconfig eth0 Link encap:Ethernet HWaddr 52:54:00:12:34:57 inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0 inet6 addr: fe80::5054:ff:fe12:3457/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:5 errors:0 dropped:0 overruns:0 frame:0 TX packets:38 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:846 (846.0 B) TX bytes:3320 (3.3 KB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
However, I don't seem to be able to ping any remote addresses(eg: 8.8.8.8). Why does this happen? How can I fix this?
[EDIT] When starting the VM I get the following warnings.
W: /etc/qemu-ifup: no bridge for guest interface found Warning: hub port hub0port0 has no peer Warning: vlan 0 with no nics Warning: netdev hub0port0 has no peer Warning: requested NIC (anonymous, model unspecified) was not created (not supported by this machine?)
-
ikrabbe almost 9 yearsYour
virbr0
uses10.0.2.25
as an address, that is private. So what's your route to8.8.8.8
? -
Admin almost 9 years@ikrabbe Sorry, I'm not sure I understand. I have not added in any routes using iptables.
-
ikrabbe almost 9 yearsWhen you have an interface on your host with an address
10.0.2.25
and nothing else, how is this private IP routed to access the internet? Show us yourip route
on the host, would be a first approach. It also seems that your virtual host through tap0 has the same address as thevirbr0
. How do you ping from the host to the client and vice versa? -
mikeserv almost 9 yearsYou need
-net nic -net tap,ifname=tap0
not-net user
. You'd use theuser
stuff if you were not configuring your own bridge. -
Admin almost 9 years@mikeserv I'm not using "-net user". I've tried using both "-netdev user" and "-netdev tap". Is that what you meant?
-
mikeserv almost 9 yearsOh I see - why are you doing two? Just do one.
-