diff options
Diffstat (limited to 'pkgs/os-specific/linux/spectrum/testhost/default.nix')
-rw-r--r-- | pkgs/os-specific/linux/spectrum/testhost/default.nix | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/pkgs/os-specific/linux/spectrum/testhost/default.nix b/pkgs/os-specific/linux/spectrum/testhost/default.nix index 7e1a973e8c6..21c585f1490 100644 --- a/pkgs/os-specific/linux/spectrum/testhost/default.nix +++ b/pkgs/os-specific/linux/spectrum/testhost/default.nix @@ -142,7 +142,9 @@ let printf "%s" $PCI_LOCATION } - # (Re)bind the device to the VFIO PCI driver. + # Tell the VFIO driver it should support our device. This + # is allowed to fail because it might already know that, in + # which case it'll return EEXIST. if { modprobe vfio-pci } backtick -in device_id { if { dd bs=2 skip=1 count=2 status=none if=''${PCI_PATH}/vendor } @@ -155,6 +157,20 @@ let printf "%s" $device_id } + # Bind the device to the VFIO driver. This is allowed to + # fail because the new_id operation we just tried will have + # bound it automatically for us if it succeeded. In such a + # case, the kernel will return ENODEV (conistency!). + foreground { + redirfd -w 1 /sys/bus/pci/drivers/vfio-pci/bind + printf "%s" $PCI_LOCATION + } + + # Because we allow both new_id and bind to fail, we need to + # manually make sure now that at least one of them succeeded + # and the device is actually attached to the vfio-driver. + if { test -e /sys/bus/pci/drivers/vfio-pci/''${PCI_LOCATION} } + foreground { mkdir env } ${cloud-hypervisor}/bin/cloud-hypervisor |