tox: use virio net driver
This commit is contained in:
parent
f7bdb15274
commit
814550084a
|
@ -1,4 +1,4 @@
|
||||||
# This file contains overrides necesarry to build some Make and Depot targets.
|
# This file contains overrides necessary to build some Make and Depot targets.
|
||||||
# Many targets can be built with the default attributes, and are not listed here.
|
# Many targets can be built with the default attributes, and are not listed here.
|
||||||
|
|
||||||
{ buildPackages, ports }:
|
{ buildPackages, ports }:
|
||||||
|
@ -91,6 +91,9 @@ in {
|
||||||
vfs_lwip.portInputs = [ lwip ];
|
vfs_lwip.portInputs = [ lwip ];
|
||||||
vfs_ttf.portInputs = [ libc stb ];
|
vfs_ttf.portInputs = [ libc stb ];
|
||||||
|
|
||||||
|
virtdev_rom = { };
|
||||||
|
virtio_nic_drv = { postInstall = "rm $out/*.xsd"; };
|
||||||
|
|
||||||
wifi_drv.portInputs = [ dde_linux libc openssl ];
|
wifi_drv.portInputs = [ dde_linux libc openssl ];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,10 @@ from contextlib import contextmanager, _GeneratorContextManager
|
||||||
from queue import Queue, Empty
|
from queue import Queue, Empty
|
||||||
from typing import Tuple, Any, Callable, Dict, Iterator, Optional, List
|
from typing import Tuple, Any, Callable, Dict, Iterator, Optional, List
|
||||||
from xml.sax.saxutils import XMLGenerator
|
from xml.sax.saxutils import XMLGenerator
|
||||||
|
import queue
|
||||||
|
import io
|
||||||
import _thread
|
import _thread
|
||||||
|
import argparse
|
||||||
import atexit
|
import atexit
|
||||||
import base64
|
import base64
|
||||||
import codecs
|
import codecs
|
||||||
|
@ -21,6 +24,7 @@ import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
|
import traceback
|
||||||
import unicodedata
|
import unicodedata
|
||||||
|
|
||||||
CHAR_TO_KEY = {
|
CHAR_TO_KEY = {
|
||||||
|
@ -99,6 +103,33 @@ def make_command(args: list) -> str:
|
||||||
return " ".join(map(shlex.quote, (map(str, args))))
|
return " ".join(map(shlex.quote, (map(str, args))))
|
||||||
|
|
||||||
|
|
||||||
|
def create_vlan(vlan_nr: str) -> Tuple[str, str, "subprocess.Popen[bytes]", Any]:
|
||||||
|
global log
|
||||||
|
log.log("starting VDE switch for network {}".format(vlan_nr))
|
||||||
|
vde_socket = tempfile.mkdtemp(
|
||||||
|
prefix="nixos-test-vde-", suffix="-vde{}.ctl".format(vlan_nr)
|
||||||
|
)
|
||||||
|
pty_master, pty_slave = pty.openpty()
|
||||||
|
vde_process = subprocess.Popen(
|
||||||
|
["vde_switch", "-s", vde_socket, "--dirmode", "0700"],
|
||||||
|
bufsize=1,
|
||||||
|
stdin=pty_slave,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE,
|
||||||
|
shell=False,
|
||||||
|
)
|
||||||
|
fd = os.fdopen(pty_master, "w")
|
||||||
|
fd.write("version\n")
|
||||||
|
# TODO: perl version checks if this can be read from
|
||||||
|
# an if not, dies. we could hang here forever. Fix it.
|
||||||
|
assert vde_process.stdout is not None
|
||||||
|
vde_process.stdout.readline()
|
||||||
|
if not os.path.exists(os.path.join(vde_socket, "ctl")):
|
||||||
|
raise Exception("cannot start vde_switch")
|
||||||
|
|
||||||
|
return (vlan_nr, vde_socket, vde_process, fd)
|
||||||
|
|
||||||
|
|
||||||
def retry(fn: Callable) -> None:
|
def retry(fn: Callable) -> None:
|
||||||
"""Call the given function repeatedly, with 1 second intervals,
|
"""Call the given function repeatedly, with 1 second intervals,
|
||||||
until it returns True or a timeout is reached.
|
until it returns True or a timeout is reached.
|
||||||
|
@ -216,7 +247,15 @@ class Machine:
|
||||||
net_backend = "-netdev user,id=net0"
|
net_backend = "-netdev user,id=net0"
|
||||||
net_frontend = "-device virtio-net-pci,netdev=net0"
|
net_frontend = "-device virtio-net-pci,netdev=net0"
|
||||||
|
|
||||||
start_command = "qemu-system-x86_64 -m 384 $QEMU_OPTS "
|
if "netBackendArgs" in args:
|
||||||
|
net_backend += "," + args["netBackendArgs"]
|
||||||
|
|
||||||
|
if "netFrontendArgs" in args:
|
||||||
|
net_frontend += "," + args["netFrontendArgs"]
|
||||||
|
|
||||||
|
start_command = (
|
||||||
|
"qemu-kvm -m 384 " + net_backend + " " + net_frontend + " $QEMU_OPTS "
|
||||||
|
)
|
||||||
|
|
||||||
if "hda" in args:
|
if "hda" in args:
|
||||||
hda_path = os.path.abspath(args["hda"])
|
hda_path = os.path.abspath(args["hda"])
|
||||||
|
@ -886,10 +925,26 @@ def subtest(name: str) -> Iterator[None]:
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
arg_parser = argparse.ArgumentParser()
|
||||||
|
arg_parser.add_argument(
|
||||||
|
"-K",
|
||||||
|
"--keep-vm-state",
|
||||||
|
help="re-use a VM state coming from a previous run",
|
||||||
|
action="store_true",
|
||||||
|
)
|
||||||
|
(cli_args, vm_scripts) = arg_parser.parse_known_args()
|
||||||
|
|
||||||
log = Logger()
|
log = Logger()
|
||||||
|
|
||||||
vm_scripts = sys.argv[1:]
|
vlan_nrs = list(dict.fromkeys(os.environ.get("VLANS", "").split()))
|
||||||
machines = [create_machine({"startCommand": s}) for s in vm_scripts]
|
vde_sockets = [create_vlan(v) for v in vlan_nrs]
|
||||||
|
for nr, vde_socket, _, _ in vde_sockets:
|
||||||
|
os.environ["QEMU_VDE_SOCKET_{}".format(nr)] = vde_socket
|
||||||
|
|
||||||
|
machines = [
|
||||||
|
create_machine({"startCommand": s, "keepVmState": cli_args.keep_vm_state})
|
||||||
|
for s in vm_scripts
|
||||||
|
]
|
||||||
machine_eval = [
|
machine_eval = [
|
||||||
"{0} = machines[{1}]".format(m.name, idx) for idx, m in enumerate(machines)
|
"{0} = machines[{1}]".format(m.name, idx) for idx, m in enumerate(machines)
|
||||||
]
|
]
|
||||||
|
|
|
@ -42,15 +42,21 @@ let tox-bootstrap =
|
||||||
, content =
|
, content =
|
||||||
[ XML.text
|
[ XML.text
|
||||||
''
|
''
|
||||||
<libc stdout="/dev/log" stderr="/dev/log" socket="/socket"/>
|
<libc stdout="/dev/log" stderr="/dev/log" socket="/socket" rng="/dev/zero"/>
|
||||||
<vfs>
|
<vfs>
|
||||||
<dir name="dev"> <log/> <null/> </dir>
|
<dir name="dev">
|
||||||
<dir name="socket"> <lwip/> </dir>
|
<log/>
|
||||||
<inline name="config">
|
<null/>
|
||||||
enable_motd = true
|
<zero/>
|
||||||
motd = "Genode Tox bootstrapd test"
|
</dir>
|
||||||
</inline>
|
<dir name="socket">
|
||||||
<ram/>
|
<lwip dhcp="yes"/>
|
||||||
|
</dir>
|
||||||
|
<inline name="config">
|
||||||
|
enable_motd = true
|
||||||
|
motd = "Genode Tox bootstrapd test"
|
||||||
|
</inline>
|
||||||
|
<ram/>
|
||||||
</vfs>
|
</vfs>
|
||||||
''
|
''
|
||||||
]
|
]
|
||||||
|
|
|
@ -3,16 +3,27 @@
|
||||||
{
|
{
|
||||||
name = "tox-bootstrapd";
|
name = "tox-bootstrapd";
|
||||||
constraints = builtins.any (spec: spec == "x86");
|
constraints = builtins.any (spec: spec == "x86");
|
||||||
machine = {
|
nodes = let
|
||||||
config = ./tox-bootstrapd.dhall;
|
node = {
|
||||||
inputs = (with pkgs; [
|
config = ./tox-bootstrapd.dhall;
|
||||||
acpi_drv
|
inputs = (with pkgs; [
|
||||||
ipxe_nic_drv
|
acpi_drv
|
||||||
libc-raise
|
libc-raise
|
||||||
platform_drv
|
platform_drv
|
||||||
posix
|
posix
|
||||||
report_rom
|
report_rom
|
||||||
vfs_lwip
|
vfs_lwip
|
||||||
]) ++ (with legacyPackages; [ libtoxcore ]);
|
virtdev_rom
|
||||||
|
virtio_nic_drv
|
||||||
|
]) ++ (with legacyPackages; [ libtoxcore ]);
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
alice = node;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
testScript = ''
|
||||||
|
start_all()
|
||||||
|
alice.wait_until_serial_output('child "init" exited with exit value 0')
|
||||||
|
'';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user