Skip to content

Commit

Permalink
remove mktuntap for crosvm
Browse files Browse the repository at this point in the history
The current crosvm runner uses mktuntap to pass fds of the
network devices to a vm. It seems to silently ignore declared
mac addresses as well as non tap-devices.

Current versions of crosvm in nixpkgs also support a
--net flag where tap id & mac can be passed directly, so I
believe mktuntap is not needed (anymore)? Please let me
know if it still provides value.
  • Loading branch information
phaer authored and astro committed Sep 27, 2023
1 parent 09ed8c5 commit 67bf176
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 28 deletions.
1 change: 0 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
in {
build-microvm = pkgs.callPackage ./pkgs/build-microvm.nix { inherit self; };
doc = pkgs.callPackage ./pkgs/doc.nix { inherit nixpkgs; };
mktuntap = pkgs.callPackage ./pkgs/mktuntap.nix {};
microvm = import ./pkgs/microvm-command.nix {
inherit pkgs;
};
Expand Down
18 changes: 5 additions & 13 deletions lib/runners/crosvm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ let
kernel initrdPath storeDisk storeOnDisk;
inherit (microvmConfig.crosvm) pivotRoot extraArgs;

mktuntap = pkgs.callPackage ../../pkgs/mktuntap.nix {};

inherit (macvtapFds) nextFreeFd;
inherit ((
builtins.foldl' ({ interfaceFds, nextFreeFd }: { type, id, ... }:
Expand Down Expand Up @@ -56,14 +54,6 @@ in {
if user != null
then throw "crosvm will not change user"
else lib.escapeShellArgs (
lib.concatLists (lib.imap0 (i: ({ id, type, ... }:
lib.optionals (type == "tap") [
"${mktuntap}/bin/mktuntap"
"-i" id
"-p" "-v" "-B"
(toString interfaceFds.${id})
])) microvmConfig.interfaces)
++
[
"${pkgs.crosvm}/bin/crosvm" "run"
"-m" (toString (mem + balloonMem))
Expand Down Expand Up @@ -109,9 +99,11 @@ in {
]
) shares
++
builtins.concatMap ({ id, ... }: [
"--tap-fd" (toString interfaceFds.${id})
]) interfaces
(builtins.concatMap ({ id, type, mac, ... }:
if type == "tap"
then ["--net" "tap-name=${id},mac=${mac}"]
else throw "Unsupported interface type ${type} for crosvm"
) microvmConfig.interfaces)
++
builtins.concatMap ({ bus, path }: {
pci = [ "--vfio" "/sys/bus/pci/devices/${path},iommu=viommu" ];
Expand Down
14 changes: 0 additions & 14 deletions pkgs/mktuntap.nix

This file was deleted.

0 comments on commit 67bf176

Please sign in to comment.