Closed truelv closed 6 years ago
The image keeps state of the raised interfaces so if you have an unclean shutdown you need to manually run this in the guest:
Ifdown eth0 Ifup eth0
You should shutdown with:
poweroff
You might want to check that QEMU has attached the tap device to the bridge (on the host):
brctl show br0
Also i’m not sure if the ifdown/ifup scripts have the full path to ifconfig e.g. /sbin/ifconfig as some systems to not have /sbin in the path.
@michaeljclark Sorry to mention you I think you just answer my second question . For this question I follow your steps and works now I can see eth0 again even I force to kill busybear-linux.
My first quetion is : my host bridge(br0) is 192.168.80.73 but eh0 in busybear is always 192.168.100.2 , why does it happened ? Anything else I can do ?
Thx
192.168.100.2 is set inside guest: root@ucbvax:~# cat /etc/network/interfaces auto lo iface lo inet loopback
auto eth0 iface eth0 inet static address 192.168.100.2 netmask 255.255.255.0 broadcast 192.168.0.255 gateway 192.168.100.1
I could ssh to guest, but my guest always report: ntpd: bad address '1.pool.ntp.org' ntpd: bad address '0.pool.ntp.org' Still not resolved
I am having the same problems with the network as the previous two comments ie no network connectivity as shown by the "ntpd: bad address '1.pool.ntp.org'" errors. I believe I have set up the bridge correctly and can see that tap0 is being attached by the startup script. On the host (Ubuntu 20.04)
macd@macd-lp:~$ brctl show br0
bridge name bridge id STP enabled interfaces
br0 8000.9ecf16a76bb0 yes enp9s0
tap0
On the guest
root@busybear:~# cat /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.122.2
netmask 255.255.255.0
broadcast 192.168.122.255
gateway 192.168.122.1
Doing the ifdown eth0 ifup eth0 did not help. Also the scripts do have access to ifconfig. Perhaps this is only a problem with documentation, but after reading a half a dozen blog posts and the Ubuntu documentation on bridged networking, I still do not have a solution. Any pointers (or fixes?) would be appreciated.
OK, maybe this should be obvious, but a couple of changes to the /etc/network/interfaces file will make this work. On the host, use ifconfig to get the ip address. In my case this is 192.168.1.113. Use this for the gateway address in interfaces file. Then choose an ip address that won't clash, in my case I chose 192.168.1.123. Then use ifdown eth0
followed by ifup eth0
(on the guest busybear linux)
root@busybear:~# cat /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.123
netmask 255.255.255.0
broadcast 192.168.122.255
gateway 192.168.1.113
Finally, I changed ntp.conf to that below. But still getting timeouts although system clock has been updated. Probably ntp still needs better config info.
root@busybear:~# cat /etc/ntp.conf
server 0.north-america.pool.ntp.org
server 1.north-america.pool.ntp.org
Sorry I have not had a chance to look into this.
The bridged networking config is a little bit fiddly and QEMU can often change in behaviour between versions. If you have a change that works reliably, feel free to make a pull request.
I installed libvirt-bin
(via pkg manager), and this solved my issues: busybear could use eth0
even though there was no eth0
on the host, via the virbr0
network interface (from libvirt-bin
).
This is w.r.t. booting via busybear-linux/scripts/start-qemu.sh
.
Question 1: (Maybe a bug) My /etc/network/interfaces is
auto br0 iface br0 inet static
bridge_ports ens33 address 192.168.80.73 netmask 255.255.255.0 network 192.168.80.254 broadcast 192.168.80.255
My ifup script is
!/bin/sh
brctl addif br0 $1
ifconfig $1 up
My ifdown script is
!/bin/sh
ifconfig $1 down
brctl delif br0 $1
My ifconfig is
wangya@ubuntu:~/sdb/codes/riscv$ ifconfig br0 Link encap:Ethernet HWaddr 00:0c:29:e2:9f:e4
inet addr:192.168.80.73 Bcast:192.168.80.255 Mask:255.255.255.0 inet6 addr: fec0::b:40f5:157d:ecf8:1e15/64 Scope:Site inet6 addr: fec0::b:20c:29ff:fee2:9fe4/64 Scope:Site inet6 addr: 2002:bfc0:31a:b:20c:29ff:fee2:9fe4/64 Scope:Global inet6 addr: 2002:bfc0:31a:b:40f5:157d:ecf8:1e15/64 Scope:Global inet6 addr: fe80::20c:29ff:fee2:9fe4/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:61021 errors:0 dropped:316 overruns:0 frame:0 TX packets:177 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:9643726 (9.6 MB) TX bytes:28807 (28.8 KB)
docker0 Link encap:Ethernet HWaddr 02:42:ba:20:c3:7d
inet addr:172.17.0.1 Bcast:0.0.0.0 Mask:255.255.0.0 UP BROADCAST MULTICAST MTU:1500 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)
ens33 Link encap:Ethernet HWaddr 00:0c:29:e2:9f:e4
inet addr:192.168.80.72 Bcast:192.168.80.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:24480763 errors:0 dropped:5631 overruns:0 frame:0 TX packets:37782 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:7189054100 (7.1 GB) TX bytes:2874215 (2.8 MB)
ens38 Link encap:Ethernet HWaddr 00:0c:29:e2:9f:ee
inet addr:192.168.43.129 Bcast:192.168.43.255 Mask:255.255.255.0 inet6 addr: fe80::91de:1f1:2639:94f4/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:366356 errors:0 dropped:0 overruns:0 frame:0 TX packets:706088 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:22769377 (22.7 MB) TX bytes:67509900 (67.5 MB)
Then I start qemu like this: sudo qemu-system-riscv64 -nographic -machine virt -kernel ./riscv-pk/build/bbl -append "root=/dev/vda ro console=ttyS0" -drive file=./busybear-linux/busybear.bin,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 -netdev type=tap,script=./ifup,downscript=./ifdown,id=net0 -device virtio-net-device,netdev=net0
busybear-linux start correctly but comes out : ntpd: bad address '1.pool.ntp.org' so I type in : ifconfig . It works like below:
root@ucbvax:~# ifconfig eth0 Link encap:Ethernet HWaddr 52:54:00:12:34:56
inet addr:192.168.100.2 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: 2002:bfc0:31a:b:5054:ff:fe12:3456/64 Scope:Global inet6 addr: fe80::5054:ff:fe12:3456/64 Scope:Link inet6 addr: fec0::b:5054:ff:fe12:3456/64 Scope:Site UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1129 errors:0 dropped:12 overruns:0 frame:0 TX packets:34 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:82369 (80.4 KiB) TX bytes:1780 (1.7 KiB)
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:18 errors:0 dropped:0 overruns:0 frame:0 TX packets:18 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1582 (1.5 KiB) TX bytes:1582 (1.5 KiB) you can see eth0 is 192.168.100.2 , but my br0 is 192.168.80.73 , Does busybear-linux can't use my setting of network ?
Question2: Because of the problem above , I want to reboot and excute qemu another time . And I don't know how to exit busybear to my origin shell so I use another terminal and use sudo kill -9 to kill qemu. After this,I use sudo qemu-system-riscv64 -nographic -machine virt -kernel ./riscv-pk/build/bbl -append "root=/dev/vda ro console=ttyS0" -drive file=./busybear-linux/busybear.bin,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 -netdev type=tap,script=./ifup,downscript=./ifdown,id=net0 -device virtio-net-device,netdev=net0 to excute qemu twice and this time I just see :
ifup: interface lo already configured ifup: interface eth0 already configured Initializing mdev...
and I can see nothing when I type in : ifconfig . What should I do?
Thx