forked from DGNum/liminix
support USB ethernet in bordervm
This commit is contained in:
parent
55387b0ee3
commit
b70c8ee258
3 changed files with 39 additions and 17 deletions
|
@ -1,7 +1,7 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
let
|
||||
cfg = config.bordervm;
|
||||
inherit (lib) mkOption mdDoc types;
|
||||
inherit (lib) mkOption mkEnableOption mdDoc types optional optionals;
|
||||
in {
|
||||
options.bordervm = {
|
||||
l2tp = {
|
||||
|
@ -22,7 +22,9 @@ in {
|
|||
};
|
||||
};
|
||||
ethernet = {
|
||||
pciId = mkOption {
|
||||
pci = {
|
||||
enable = mkEnableOption "passthru PCI ethernet";
|
||||
id = mkOption {
|
||||
description = ''
|
||||
Host PCI ID (as shown by `lspci`) of the ethernet adaptor
|
||||
to be used by the VM. This uses VFIO and requires setup
|
||||
|
@ -32,6 +34,18 @@ in {
|
|||
example = "04:00.0";
|
||||
};
|
||||
};
|
||||
usb = {
|
||||
enable = mkEnableOption "passthru USB ethernet";
|
||||
vendor = mkOption {
|
||||
type = types.str;
|
||||
example = "0x0bda";
|
||||
};
|
||||
product = mkOption {
|
||||
type = types.str;
|
||||
example = "0x8153";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
imports = [
|
||||
<nixpkgs/nixos/modules/virtualisation/qemu-vm.nix>
|
||||
|
@ -66,8 +80,13 @@ in {
|
|||
virtualisation = {
|
||||
qemu = {
|
||||
networkingOptions = [];
|
||||
options = [
|
||||
"-device vfio-pci,host=${cfg.ethernet.pciId}"
|
||||
options = [] ++
|
||||
optional cfg.ethernet.pci.enable
|
||||
"-device vfio-pci,host=${cfg.ethernet.pci.id}" ++
|
||||
optionals cfg.ethernet.usb.enable [
|
||||
"-device usb-ehci,id=ehci"
|
||||
"-device usb-host,bus=ehci.0,vendorid=${cfg.ethernet.usb.vendor},productid=${cfg.ethernet.usb.product}"
|
||||
] ++ [
|
||||
"-nographic"
|
||||
"-serial mon:stdio"
|
||||
];
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
{...}:
|
||||
{
|
||||
bordervm = {
|
||||
ethernet.pciId = "01:00.0";
|
||||
# ethernet.pci = { id = "01:00.0"; enable = true; };
|
||||
ethernet.usb = { vendor = "0x0bda"; product = "0x8153"; enable = true; };
|
||||
l2tp = {
|
||||
host = "l2tp.aa.net.uk";
|
||||
};
|
||||
|
|
|
@ -139,11 +139,13 @@ router from the internet so you can borrow the cable/fibre/DSL.
|
|||
|
||||
``bordervm`` is included for this purpose. You will need
|
||||
|
||||
* a Linux machine with a spare PCI ethernet card which you can dedicate to Liminix
|
||||
* a Linux machine with a spare (PCI or USB) ethernet device which you can dedicate to Liminix
|
||||
|
||||
* an L2TP service such as https://www.aa.net.uk/broadband/l2tp-service/
|
||||
|
||||
You need to configure the Ethernet card for VFIO passthru, then
|
||||
You need to "hide" the Ethernet device from the host - for PCI this
|
||||
means configuring it for VFIO passthru; for USB you need to
|
||||
unload the module(s) it uses. Then
|
||||
you can execute :command:`run-border-vm` in a ``buildEnv`` shell,
|
||||
which starts up QEMU using the NixOS configuration in
|
||||
:file:`bordervm-configuration.nix`.
|
||||
|
|
Loading…
Reference in a new issue