tool: Consolidate qemu nic setup.

Right now the same code dealing with nic setup on qemu is duplicated
in many different run scripts. It makes it unnecesarily complex to
change the existing config or add support for new nic types. Lets move
all this common code to qemu.inc.

Ref #3825
This commit is contained in:
Piotr Tworek 2020-04-02 21:20:50 +02:00 committed by Christian Helmuth
parent aa2511e209
commit fe0ad0addb
26 changed files with 65 additions and 168 deletions

View File

@ -135,16 +135,7 @@ append boot_modules { depot_download_manager depot_query }
build_boot_image $boot_modules build_boot_image $boot_modules
append qemu_args " -nographic " append qemu_args " -nographic "
append_qemu_nic_args
proc qemu_nic_model {} {
if [have_spec x86] { return e1000 }
if [have_spec lan9118] { return lan9118 }
if [have_spec zynq] { return cadence_gem }
return nic_model_missing
}
append qemu_args " -netdev user,id=net0 "
append qemu_args " -net nic,model=[qemu_nic_model],netdev=net0 "
# watch the state reports generated by the depot-download manager # watch the state reports generated by the depot-download manager

View File

@ -3,7 +3,8 @@ set use_nvme 0
source ${genode_dir}/repos/gems/run/sculpt.run source ${genode_dir}/repos/gems/run/sculpt.run
# enable Qemu networking, usable via the nic_drv # enable Qemu networking, usable via the nic_drv
append qemu_args " -m 768 -net nic,model=e1000 -net user " append_qemu_nic_args
append qemu_args " -m 768 "
# attach small SATA disk to Qemu to experiment with file-system access # attach small SATA disk to Qemu to experiment with file-system access
set disk_image "bin/sculpt-ahci.raw" set disk_image "bin/sculpt-ahci.raw"

View File

@ -225,16 +225,8 @@ build_boot_image $boot_modules
# Execute test # Execute test
# #
append qemu_args " -m 512 -nographic " append qemu_args " -m 512 -nographic "
append_qemu_nic_args "hostfwd=tcp::5555-:22"
proc qemu_nic_model {} {
if [have_spec x86] { return e1000 }
if [have_spec lan9118] { return lan9118 }
return nic_model_missing
}
append qemu_args " -netdev user,id=net0,hostfwd=tcp::5555-:22 "
append qemu_args " -net nic,model=[qemu_nic_model],netdev=net0 "
set lxip_match_string "ipaddr=(\[0-9\]+\.\[0-9\]+\.\[0-9\]+\.\[0-9\]+).*\n" set lxip_match_string "ipaddr=(\[0-9\]+\.\[0-9\]+\.\[0-9\]+\.\[0-9\]+).*\n"

View File

@ -190,16 +190,8 @@ build_boot_image $boot_modules
# Execute test # Execute test
# #
append qemu_args " -m 512 -nographic " append qemu_args " -m 512 -nographic "
append_qemu_nic_args "hostfwd=tcp::5555-:22"
proc qemu_nic_model {} {
if [have_spec x86] { return e1000 }
if [have_spec lan9118] { return lan9118 }
return nic_model_missing
}
append qemu_args " -netdev user,id=net0,hostfwd=tcp::5555-:22 "
append qemu_args " -net nic,model=[qemu_nic_model],netdev=net0 "
set lxip_match_string "ipaddr=(\[0-9\]+\.\[0-9\]+\.\[0-9\]+\.\[0-9\]+).*\n" set lxip_match_string "ipaddr=(\[0-9\]+\.\[0-9\]+\.\[0-9\]+\.\[0-9\]+).*\n"

View File

@ -77,16 +77,8 @@ build_boot_image { tcp_terminal test-terminal_echo }
# qemu config # qemu config
proc qemu_nic_model {} {
if [have_spec x86] { return e1000 }
if [have_spec lan9118] { return lan9118 }
if [have_spec zynq] { return cadence_gem }
return nic_model_missing
}
append qemu_args " -nographic " append qemu_args " -nographic "
append qemu_args " -netdev user,id=net0,hostfwd=tcp::5555-:8888 " append_qemu_nic_args "hostfwd=tcp::5555-:8888"
append qemu_args " -net nic,model=[qemu_nic_model],netdev=net0 "
run_genode_until forever run_genode_until forever

View File

@ -118,16 +118,8 @@ install_config {
#build { } #build { }
build_boot_image { } build_boot_image { }
proc qemu_nic_model {} {
if [have_spec x86] { return e1000 }
if [have_spec lan9118] { return lan9118 }
if [have_spec zynq] { return cadence_gem }
return nic_model_missing
}
append qemu_args " -nographic " append qemu_args " -nographic "
append qemu_args " -netdev user,id=net0 " append_qemu_nic_args
append qemu_args " -net nic,model=[qemu_nic_model],netdev=net0 "
## Uncomment to dump network traffic to file ## Uncomment to dump network traffic to file
# append qemu_args " -object filter-dump,id=net0,netdev=net0,file=[run_dir].pcap" # append qemu_args " -object filter-dump,id=net0,netdev=net0,file=[run_dir].pcap"

View File

@ -68,13 +68,7 @@ install_config {
build_boot_image { test-libc_getaddrinfo } build_boot_image { test-libc_getaddrinfo }
proc qemu_nic_model {} { append qemu_args " -nographic "
if [have_spec x86] { return e1000 } append_qemu_nic_args
if [have_spec lan9118] { return lan9118 }
if [have_spec zynq] { return cadence_gem }
return nic_model_missing
}
append qemu_args " -nographic -net nic,model=[qemu_nic_model] -net user"
run_genode_until "child .* exited with exit value 0.*\n" 20 run_genode_until "child .* exited with exit value 0.*\n" 20

View File

@ -90,15 +90,8 @@ build_boot_image { test-lwip_httpsrv }
# #
# Qemu config # Qemu config
# #
proc qemu_nic_model {} {
if [have_spec x86] { return e1000 }
if [have_spec lan9118] { return lan9118 }
if [have_spec zynq] { return cadence_gem }
return nic_model_missing
}
append qemu_args " -nographic " append qemu_args " -nographic "
append qemu_args " -netdev user,id=net0,hostfwd=tcp::5555-:80 " append_qemu_nic_args "hostfwd=tcp::5555-:80"
append qemu_args " -net nic,model=[qemu_nic_model],netdev=net0 "
run_genode_until {.*lwIP Nic interface up.*\n} 30 run_genode_until {.*lwIP Nic interface up.*\n} 30

View File

@ -101,14 +101,17 @@ append config {
</start> </start>
} }
proc qemu_nic_model {} {
if [have_spec x86] { return e1000 }
if [have_spec lan9118] { return lan9118 }
if [have_spec zynq] { return cadence_gem }
return nic_model_missing
}
append qemu_args " -nographic " append qemu_args " -nographic "
append qemu_args " -net nic,model=[qemu_nic_model] " append_qemu_nic_args
append qemu_args " -net tap,ifname=tap0,downscript=no,script=no "
# When using with a tap device manually replace append_qemu_nic_args with:
#proc qemu_nic_model {} {
# if [have_spec x86] { return e1000 }
# if [have_spec lan9118] { return lan9118 }
# if [have_spec zynq] { return cadence_gem }
# return nic_model_missing
#}
#append qemu_args " -net nic,model=[qemu_nic_model] "
#append qemu_args " -net tap,ifname=tap0,downscript=no,script=no "
# vi: set ft=tcl : # vi: set ft=tcl :

View File

@ -61,14 +61,16 @@ append config {
</start> </start>
} }
proc qemu_nic_model {} {
if [have_spec x86] { return e1000 }
if [have_spec lan9118] { return lan9118 }
if [have_spec zynq] { return cadence_gem }
return nic_model_missing
}
append qemu_args " -nographic " append qemu_args " -nographic "
append qemu_args " -net nic,model=[qemu_nic_model] " append_qemu_nic_args
append qemu_args " -net tap,ifname=tap0,downscript=no,script=no "
#proc qemu_nic_model {} {
# if [have_spec x86] { return e1000 }
# if [have_spec lan9118] { return lan9118 }
# if [have_spec zynq] { return cadence_gem }
# return nic_model_missing
#}
#append qemu_args " -net nic,model=[qemu_nic_model] "
#append qemu_args " -net tap,ifname=tap0,downscript=no,script=no "
# vi: set ft=tcl : # vi: set ft=tcl :

View File

@ -158,16 +158,8 @@ build_boot_image {
test-lwip_httpsrv test-lwip_httpsrv
} }
proc qemu_nic_model {} {
if [have_spec x86] { return e1000 }
if [have_spec lan9118] { return lan9118 }
if [have_spec zynq] { return cadence_gem }
return nic_model_missing
}
append qemu_args " -nographic " append qemu_args " -nographic "
append qemu_args " -netdev user,id=net0 " append_qemu_nic_args
append qemu_args " -net nic,model=[qemu_nic_model],netdev=net0 "
append done_string {.*?\[init -> client_3] .\[31mError: Nic-session creation failed} append done_string {.*?\[init -> client_3] .\[31mError: Nic-session creation failed}
append done_string {.*?\[client_1 -> lwip] rcv .\[32mETH.\[0m 02:02:02:02:42:0.} append done_string {.*?\[client_1 -> lwip] rcv .\[32mETH.\[0m 02:02:02:02:42:0.}

View File

@ -68,15 +68,8 @@ append config {
install_config $config install_config $config
build_boot_image { core ld.lib.so init timer sntp_client report_rom } build_boot_image { core ld.lib.so init timer sntp_client report_rom }
proc qemu_nic_model {} {
if [have_spec x86] { return e1000 }
if [have_spec lan9118] { return lan9118 }
if [have_spec zynq] { return cadence_gem }
return nic_model_missing
}
append qemu_args " -nographic " append qemu_args " -nographic "
append qemu_args " -netdev user,id=net0 " append_qemu_nic_args
append qemu_args " -net nic,model=[qemu_nic_model],netdev=net0 "
set done_string "report_rom] <set_rtc year.*?report_rom] <set_rtc year.*?\n" set done_string "report_rom] <set_rtc year.*?report_rom] <set_rtc year.*?\n"

View File

@ -237,16 +237,8 @@ append config {
install_config $config install_config $config
build_boot_image { ping nic_dump } build_boot_image { ping nic_dump }
proc qemu_nic_model {} {
if [have_spec x86] { return e1000 }
if [have_spec lan9118] { return lan9118 }
if [have_spec zynq] { return cadence_gem }
return nic_model_missing
}
append qemu_args " -nographic " append qemu_args " -nographic "
append qemu_args " -netdev user,id=net0 " append_qemu_nic_args
append qemu_args " -net nic,model=[qemu_nic_model],netdev=net0 "
set done_string "" set done_string ""
for {set i 0} {$i < 3} {incr i 1} { for {set i 0} {$i < 3} {incr i 1} {

View File

@ -200,15 +200,7 @@ install_config {
build_boot_image { test-net_flood ping nic_router dynamic_rom } build_boot_image { test-net_flood ping nic_router dynamic_rom }
proc qemu_nic_model {} {
if [have_spec x86] { return e1000 }
if [have_spec lan9118] { return lan9118 }
if [have_spec zynq] { return cadence_gem }
return nic_model_missing
}
append qemu_args " -nographic " append qemu_args " -nographic "
append qemu_args " -netdev user,id=net0 " append_qemu_nic_args
append qemu_args " -net nic,model=[qemu_nic_model],netdev=net0 "
run_genode_until {.*ping\] 64 bytes from 10\.0\.2\.2: icmp_seq=30 .*\n} [test_timeout] run_genode_until {.*ping\] 64 bytes from 10\.0\.2\.2: icmp_seq=30 .*\n} [test_timeout]

View File

@ -104,16 +104,8 @@ append config {
install_config $config install_config $config
build_boot_image { ping } build_boot_image { ping }
proc qemu_nic_model {} {
if [have_spec x86] { return e1000 }
if [have_spec lan9118] { return lan9118 }
if [have_spec zynq] { return cadence_gem }
return nic_model_missing
}
append qemu_args " -nographic " append qemu_args " -nographic "
append qemu_args " -netdev user,id=net0 " append_qemu_nic_args
append qemu_args " -net nic,model=[qemu_nic_model],netdev=net0 "
set done_string ".*\"ping_1\" exited with exit value 0.*\n" set done_string ".*\"ping_1\" exited with exit value 0.*\n"

View File

@ -220,16 +220,8 @@ append config {
install_config $config install_config $config
build_boot_image { ping } build_boot_image { ping }
proc qemu_nic_model {} {
if [have_spec x86] { return e1000 }
if [have_spec lan9118] { return lan9118 }
if [have_spec zynq] { return cadence_gem }
return nic_model_missing
}
append qemu_args " -nographic " append qemu_args " -nographic "
append qemu_args " -netdev user,id=net0 " append_qemu_nic_args
append qemu_args " -net nic,model=[qemu_nic_model],netdev=net0 "
set done_string "" set done_string ""
for {set i 0} {$i < 3} {incr i 1} { for {set i 0} {$i < 3} {incr i 1} {

View File

@ -120,15 +120,7 @@ exec tar cfv bin/genode_org.tar -h -C bin/genode_org .
build_boot_image { genode_org.tar } build_boot_image { genode_org.tar }
proc qemu_nic_model {} {
if [have_spec x86] { return e1000 }
if [have_spec lan9118] { return lan9118 }
if [have_spec zynq] { return cadence_gem }
return nic_model_missing
}
append qemu_args " -netdev user,id=net0,hostfwd=tcp::5555-:80 "
append qemu_args " -net nic,model=[qemu_nic_model],netdev=net0 "
append qemu_args " -nographic " append qemu_args " -nographic "
append_qemu_nic_args "hostfwd=tcp::5555-:80"
run_genode_until forever run_genode_until forever

View File

@ -179,16 +179,8 @@ EpA5DBBklj8UE2CdONvN
#build { } #build { }
build_boot_image { } build_boot_image { }
proc qemu_nic_model {} {
if [have_spec x86] { return e1000 }
if [have_spec lan9118] { return lan9118 }
if [have_spec zynq] { return cadence_gem }
return nic_model_missing
}
append qemu_args " -netdev user,id=net0,hostfwd=tcp::5555-:80,hostfwd=tcp::5556-:443 "
append qemu_args " -net nic,model=[qemu_nic_model],netdev=net0 "
append qemu_args " -nographic " append qemu_args " -nographic "
append_qemu_nic_args "hostfwd=tcp::5555-:80,hostfwd=tcp::5556-:443"
append xen_args { sdl=0\; vif=\["model=e1000,mac=02:00:00:00:01:01,bridge=xenbr0"\] } append xen_args { sdl=0\; vif=\["model=e1000,mac=02:00:00:00:01:01,bridge=xenbr0"\] }
run_genode_until forever run_genode_until forever

View File

@ -316,16 +316,8 @@ build_boot_image { netserver }
# #
# qemu config # qemu config
append qemu_args " -nographic " append qemu_args " -nographic "
append_qemu_nic_args "hostfwd=tcp::12865-:12865,hostfwd=tcp::49153-:49153"
proc qemu_nic_model {} {
if [have_spec x86] { return e1000 }
if [have_spec lan9118] { return lan9118 }
return nic_model_missing
}
append qemu_args " -netdev user,id=net0,hostfwd=tcp::12865-:12865,hostfwd=tcp::49153-:49153 "
append qemu_args " -net nic,model=[qemu_nic_model],netdev=net0 "
set ip_match_string "" set ip_match_string ""
set force_ports "" set force_ports ""

View File

@ -75,8 +75,8 @@ foreach binary $guest_os_binaries {
source ${genode_dir}/repos/ports/run/seoul.inc source ${genode_dir}/repos/ports/run/seoul.inc
append qemu_args " -cpu phenom -smp 2 " append qemu_args " -cpu phenom -smp 2 "
append qemu_args " -net nic,model=e1000 "
append qemu_args " -nographic " append qemu_args " -nographic "
append_qemu_nic_args
if { [get_cmd_switch --autopilot] } { if { [get_cmd_switch --autopilot] } {
run_genode_until {\[init -\> seoul\] VMM: # Hello Genode world!} 300 run_genode_until {\[init -\> seoul\] VMM: # Hello Genode world!} 300

View File

@ -62,6 +62,6 @@ source ${genode_dir}/repos/ports/run/seoul.inc
append qemu_args " -m 1024 " append qemu_args " -m 1024 "
append qemu_args " -cpu phenom " append qemu_args " -cpu phenom "
append qemu_args " -net nic,model=e1000 " append_qemu_nic_args
run_genode_until forever run_genode_until forever

View File

@ -57,6 +57,6 @@ foreach binary $guest_os_binaries {
source ${genode_dir}/repos/ports/run/seoul.inc source ${genode_dir}/repos/ports/run/seoul.inc
append qemu_args " -cpu phenom " append qemu_args " -cpu phenom "
append qemu_args " -net nic,model=e1000 " append_qemu_nic_args
run_genode_until forever run_genode_until forever

View File

@ -3,7 +3,6 @@
# #
source [genode_dir]/tool/run/log.inc source [genode_dir]/tool/run/log.inc
source [genode_dir]/tool/run/qemu.inc
proc run_log { wait_for_re timeout_value } { proc run_log { wait_for_re timeout_value } {

View File

@ -4,8 +4,6 @@
# Reset the target machine or rather run the scenario with Qemu # Reset the target machine or rather run the scenario with Qemu
# #
source [genode_dir]/tool/run/qemu.inc
proc check_version {qemu_version qemu_min qemu_max} { proc check_version {qemu_version qemu_min qemu_max} {
set version_min_list [split $qemu_min ".-"] set version_min_list [split $qemu_min ".-"]
set version_min_list_len [llength $version_min_list] set version_min_list_len [llength $version_min_list]

View File

@ -14,6 +14,24 @@ proc qemu_args { } {
return $qemu_args return $qemu_args
} }
proc qemu_nic_model {} {
if [have_spec lan9118] { return lan9118 }
if [have_spec zynq] { return cadence_gem }
if [have_spec x86] { return e1000 }
return nic_model_missing
}
proc append_qemu_nic_args { { extra_netdev_args "" } } {
global qemu_args
append qemu_args " -netdev user,id=net0"
if { $extra_netdev_args ne "" } {
append qemu_args ",$extra_netdev_args"
}
append qemu_args " -net nic,model=[qemu_nic_model],netdev=net0 "
}
## ##
# Check whether Qemu support is available # Check whether Qemu support is available

View File

@ -1026,6 +1026,7 @@ proc build_initrd { modules } {
} }
source [genode_dir]/tool/run/depot.inc source [genode_dir]/tool/run/depot.inc
source [genode_dir]/tool/run/qemu.inc
## ##