Re: Command line for Qemu and libbsd for pc386

2020-06-25 Thread junkes

On 2020-06-24 19:22, Joel Sherrill wrote:

Hi 

Does someone have a qemu command line handy for running libbsd network applications on Qemu? 

I have lots of notes and old examples but can't seem to trip the right combination today. 

Thanks. 

--joel 
___

devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


To boot epics I was setting up DHCP, ntp and nfs on my development host,
run this script: 

[h1@earth utilities (master *+)]$ more setUpNetworkForQemu.py 
## @brief This Python file uses the following encoding: utf-8 
#  Documentation for this module. 
# 
#  More details. 

## Documentation for a function. 
# 
import netifaces 
import subprocess 
import dns.resolver 
import subprocess 
from string import Template 

brNet = '10.1.0.0' 
brNetMask = '255.255.255.0' 
brLeaseRange = '10.1.0.100 10.1.0.120' 
br0Ip = '10.1.0.1' 

ethNet = '10.0.0.0' 
ethNetMask = '255.255.255.0' 
ethLeaseRange = '10.0.0.100 10.0.0.120' 
eth0Ip = '10.0.0.1' 

def setupAndStartDhcpd(): 
dhcpdConfStr = ('\n' + 
 'default-lease-time 600;\n' + 
 'max-lease-time 7200;\n' + 
 'option ntp-servers $ntpIp;\n' + 
 'option rtems-cmdline code 129=string;\n' + 
 'option rtems-cmdline "Ich DIch doch auch";\n' + 
 'filename "RtemsForever";\n' + 
 'option domain-name "rtems";\n' + 
 '\n' + 
 'subnet ' + brNet + ' netmask ' + brNetMask + ' {\n' + 
 'range ' + brLeaseRange + ';\n' + 
 'option routers ' + br0Ip + ';\n' + 
 'option domain-name-servers $dnsIp;\n' + 
 '}\n' + 
 'subnet ' + ethNet + ' netmask ' + ethNetMask + ' {\n' + 
 'range ' + ethLeaseRange + ';\n' + 
 'option routers ' + eth0Ip + ';\n' + 
 'option domain-name-servers $dnsIp;\n' + 
 '}\n' ) 

# stop dhcp-server 
subprocess.run(['/bin/systemctl', 'stop', 'isc-dhcp-server.service']) 

dnsResolver = dns.resolver.Resolver() 
print("will setup dhcpd with dhcp-server at : ",
dnsResolver.nameservers[0]) 
s = Template(dhcpdConfStr) 
txtToFile = s.substitute(dnsIp = dnsResolver.nameservers[0], ntpIp =
'10.1.0.1') 
with open('/etc/dhcp/dhcpd.conf', 'w') as f: 
  print(txtToFile, file=f) 
  f.close() 

s = 'INTERFACESv4="br0"' 
with open('/etc/default/isc-dhcp-server', 'w') as f: 
  print(s, file=f) 
  f.close() 

# start dhcp-server 
subprocess.run(['/bin/systemctl', 'start', 'isc-dhcp-server.service']) 

def main(): 
print("\nWill setup qemu network\n") 

#setup a bridge 
subprocess.run(['/sbin/brctl', 'addbr', 'br0']) 
subprocess.run(['/sbin/ifconfig', 'br0', br0Ip, 'netmask', brNetMask,
'up']) 
subprocess.run(['/usr/bin/tunctl', '-t', 'tap0']) 
subprocess.run(['/usr/bin/tunctl', '-t', 'tap1']) 
subprocess.run(['/sbin/brctl', 'addif', 'br0', 'tap0', 'tap1']) 
subprocess.run(['/sbin/ifconfig', 'tap0']) 
subprocess.run(['/sbin/ifconfig', 'tap1']) 

# check for default gateway and interface used 
gws = netifaces.gateways() 
defaultGw = gws['default'][netifaces.AF_INET] 
gwAddress = defaultGw[0] 
gwInterface = defaultGw[1] 
print ("Default gateway : ", gwAddress, " on interface : ",
gwInterface) 
if 'wlan' in gwInterface : 
  print("Wlan interface used!? (", gwInterface, ")\n") 
  print("dummy eth mit ip_forwarding must be put in place") 
  #bridging wlan0 to eth0 
  s = '1' 
  with open('/proc/sys/net/ipv4/ip_forward', 'w') as f: 
print(s, file=f) 
f.close() 
  subprocess.run(['/sbin/iptables', '-t', 'nat', '-A', 'POSTROUTING', 
  '-o', 'wlan0', '-j', 'MASQUERADE']) 
  subprocess.run(['/sbin/brctl', 'addif', 'br0', 'eth0']) 
  subprocess.run(['ifconfig', 'eth0', eth0Ip, 'netmask', ethNetMask,
'up']) 

setupAndStartDhcpd() 
subprocess.run(['/sbin/ifconfig', 'tap0', 'up']) 
print("ready for qemu") 


main()

and then start a exe file with 

[h1@earth QtC-epics-base (7.0 *)]$ more startQemu  
#!/bin/bash 
echo Script name: $0 
if [ $# -ne 1 ]; 
then echo "Please name the exe file" 
exit 2 
fi 
#-net nic -net tap,ifname=tap1,script=no \ 
#-net nic,model=cadence_gem -net tap,ifname=tap1,script=no \ 
# -s -no-reboot 
sudo qemu-system-aarch64 -s -no-reboot \ 
-net nic,model=cadence_gem -net tap,ifname=tap0,script=no \ 
-serial null -serial mon:stdio -nographic -M xilinx-zynq-a9 -m 256M \ 
-kernel bin/RTEMS-xilinx_zynq_a9_qemu/$1


HTH, Heinz___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: Command line for Qemu and libbsd for pc386

2020-06-25 Thread Chris Johns

Hi Gabriel,

Thanks. Your post reminded me to have a look. This the set up I used a 
while ago ..


 qemu-system-arm \
  -M xilinx-zynq-a9 -m 256M -no-reboot -serial null \
  -serial mon:stdio -nographic -net nic,model=cadence_gem \
  -net vde,id=vde0,sock=/tmp/vde1 -kernel $*

This use the vdeswitch package. The RSB will build VDE support into qemu 
if it is installed and available.


On FreeBSD I have a bridge with a tap interface. The /etc/rc.conf has ...

 cloned_interfaces="bridge0 tap0"
 autobridge_interfaces="bridge0"
 ifconfig_bridge0="inet 10.1.1.2 netmask 255.255.255.0"
 autobridge_bridge0="re0 tap0"
 ifconfig_re0="up"
 ifconfig_tap0="up"
 defaultrouter="10.1.1.1"

Then run the VDE switch with ...

 #! /bin/sh
 #
 # vdeterm /tmp/mgmt1
 #

 sysctl net.link.tap.user_open=1
 sysctl net.link.tap.up_on_open=1

 chmod 660 /dev/tap0

 vde_switch -d -s /tmp/vde1 -M /tmp/mgmt1 -tap tap0 -m 660 \
--mgmtmode 660

VDE lets me run a number of qemu sessions together and have them see 
each other without needing to add a bunch of tap interfaces.


Chris

On 25/6/20 4:12 pm, gabriel.moy...@dlr.de wrote:

Hi Joel,

Before running qemu, some qtabs should be created. How to do that it is 
described on file libbsd.txt (line 333). Then I usually run qemu as follows:


qemu-system-i386 -append --console=/dev/com1 -no-reboot -serial stdio 
-monitor none -nographic -netdev 
tap,ifname=qtap1,script=no,downscript=no,id=n1 –device 
e1000,netdev=n1,mac=52:55:00:d1:55:01 -kernel path/to/exe/file


Please note that if you are running two instances, the second one should 
have different MAC address and  ifname, e.g. mac=52:55:00:d1:55:0*2*and 
ifname=qtab*2*


**

If hope this helps.

Cheers,

Gabriel

*From:*devel [mailto:devel-boun...@rtems.org] *On Behalf Of *Joel Sherrill
*Sent:* Mittwoch, 24. Juni 2020 19:23
*To:* rtems-de...@rtems.org
*Subject:* Command line for Qemu and libbsd for pc386

Hi

Does someone have a qemu command line handy for running libbsd network 
applications on Qemu?


I have lots of notes and old examples but can't seem to trip the right 
combination today.


Thanks.

--joel


___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

RE: Command line for Qemu and libbsd for pc386

2020-06-25 Thread Gabriel.Moyano
Hi Joel,

Before running qemu, some qtabs should be created. How to do that it is 
described on file libbsd.txt (line 333). Then I usually run qemu as follows:

qemu-system-i386 -append --console=/dev/com1 -no-reboot -serial stdio -monitor 
none -nographic -netdev tap,ifname=qtap1,script=no,downscript=no,id=n1 –device 
e1000,netdev=n1,mac=52:55:00:d1:55:01 -kernel path/to/exe/file

Please note that if you are running two instances, the second one should have 
different MAC address and  ifname, e.g. mac=52:55:00:d1:55:02 and ifname=qtab2

If hope this helps.

Cheers,
Gabriel

From: devel [mailto:devel-boun...@rtems.org] On Behalf Of Joel Sherrill
Sent: Mittwoch, 24. Juni 2020 19:23
To: rtems-de...@rtems.org
Subject: Command line for Qemu and libbsd for pc386

Hi

Does someone have a qemu command line handy for running libbsd network 
applications on Qemu?

I have lots of notes and old examples but can't seem to trip the right 
combination today.

Thanks.

--joel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel