Skip to content

Commit a4c90d9

Browse files
Merge pull request #451 from matthawkins90/add_vsock_to_firecracker
feat(firecracker): add vsock support
2 parents bb9e99b + 652ab76 commit a4c90d9

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

lib/runners/firecracker.nix

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ let
1111
vcpu mem balloon initialBalloonMem hotplugMem hotpluggedMem
1212
interfaces volumes shares devices
1313
kernel initrdPath
14-
storeDisk credentialFiles;
14+
storeDisk credentialFiles vsock;
1515
inherit (microvmConfig.firecracker) cpu;
1616

1717
kernelPath = {
@@ -61,8 +61,16 @@ let
6161
}
6262
else throw "Network interface type ${type} not implemented for Firecracker"
6363
) interfaces;
64-
vsock = null;
65-
} // lib.optionalAttrs (cpu != null) {
64+
vsock =
65+
if vsock.cid != null then
66+
{
67+
guest_cid = vsock.cid;
68+
uds_path = "notify.vsock";
69+
}
70+
else
71+
null;
72+
}
73+
// lib.optionalAttrs (cpu != null) {
6674
cpu-config = pkgs.writeText "cpu-config.json" (builtins.toJSON cpu);
6775
};
6876
config = lib.recursiveUpdate baseConfig microvmConfig.firecracker.extraConfig;
@@ -105,6 +113,9 @@ in {
105113
if [ -e '${socket}' ]; then
106114
mv '${socket}' '${socket}.old'
107115
fi
116+
''
117+
+ lib.optionalString (vsock.cid != null) ''
118+
rm -f notify.vsock notify.vsock_*
108119
'';
109120

110121
canShutdown = socket != null;

0 commit comments

Comments
 (0)