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.
|
||||
|
||||
{ buildPackages, ports }:
|
||||
|
@ -91,6 +91,9 @@ in {
|
|||
vfs_lwip.portInputs = [ lwip ];
|
||||
vfs_ttf.portInputs = [ libc stb ];
|
||||
|
||||
virtdev_rom = { };
|
||||
virtio_nic_drv = { postInstall = "rm $out/*.xsd"; };
|
||||
|
||||
wifi_drv.portInputs = [ dde_linux libc openssl ];
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,10 @@ from contextlib import contextmanager, _GeneratorContextManager
|
|||
from queue import Queue, Empty
|
||||
from typing import Tuple, Any, Callable, Dict, Iterator, Optional, List
|
||||
from xml.sax.saxutils import XMLGenerator
|
||||
import queue
|
||||
import io
|
||||
import _thread
|
||||
import argparse
|
||||
import atexit
|
||||
import base64
|
||||
import codecs
|
||||
|
@ -21,6 +24,7 @@ import subprocess
|
|||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
import traceback
|
||||
import unicodedata
|
||||
|
||||
CHAR_TO_KEY = {
|
||||
|
@ -99,6 +103,33 @@ def make_command(args: list) -> str:
|
|||
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:
|
||||
"""Call the given function repeatedly, with 1 second intervals,
|
||||
until it returns True or a timeout is reached.
|
||||
|
@ -216,7 +247,15 @@ class Machine:
|
|||
net_backend = "-netdev user,id=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:
|
||||
hda_path = os.path.abspath(args["hda"])
|
||||
|
@ -886,10 +925,26 @@ def subtest(name: str) -> Iterator[None]:
|
|||
|
||||
|
||||
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()
|
||||
|
||||
vm_scripts = sys.argv[1:]
|
||||
machines = [create_machine({"startCommand": s}) for s in vm_scripts]
|
||||
vlan_nrs = list(dict.fromkeys(os.environ.get("VLANS", "").split()))
|
||||
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 = [
|
||||
"{0} = machines[{1}]".format(m.name, idx) for idx, m in enumerate(machines)
|
||||
]
|
||||
|
|
|
@ -42,15 +42,21 @@ let tox-bootstrap =
|
|||
, content =
|
||||
[ XML.text
|
||||
''
|
||||
<libc stdout="/dev/log" stderr="/dev/log" socket="/socket"/>
|
||||
<libc stdout="/dev/log" stderr="/dev/log" socket="/socket" rng="/dev/zero"/>
|
||||
<vfs>
|
||||
<dir name="dev"> <log/> <null/> </dir>
|
||||
<dir name="socket"> <lwip/> </dir>
|
||||
<inline name="config">
|
||||
enable_motd = true
|
||||
motd = "Genode Tox bootstrapd test"
|
||||
</inline>
|
||||
<ram/>
|
||||
<dir name="dev">
|
||||
<log/>
|
||||
<null/>
|
||||
<zero/>
|
||||
</dir>
|
||||
<dir name="socket">
|
||||
<lwip dhcp="yes"/>
|
||||
</dir>
|
||||
<inline name="config">
|
||||
enable_motd = true
|
||||
motd = "Genode Tox bootstrapd test"
|
||||
</inline>
|
||||
<ram/>
|
||||
</vfs>
|
||||
''
|
||||
]
|
||||
|
|
|
@ -3,16 +3,27 @@
|
|||
{
|
||||
name = "tox-bootstrapd";
|
||||
constraints = builtins.any (spec: spec == "x86");
|
||||
machine = {
|
||||
config = ./tox-bootstrapd.dhall;
|
||||
inputs = (with pkgs; [
|
||||
acpi_drv
|
||||
ipxe_nic_drv
|
||||
libc-raise
|
||||
platform_drv
|
||||
posix
|
||||
report_rom
|
||||
vfs_lwip
|
||||
]) ++ (with legacyPackages; [ libtoxcore ]);
|
||||
nodes = let
|
||||
node = {
|
||||
config = ./tox-bootstrapd.dhall;
|
||||
inputs = (with pkgs; [
|
||||
acpi_drv
|
||||
libc-raise
|
||||
platform_drv
|
||||
posix
|
||||
report_rom
|
||||
vfs_lwip
|
||||
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