vfio-unbind.hs
1 {-# LANGUAGE OverloadedStrings #-} 2 3 {- | 4 Unbind a PCI device from vfio-pci and rescan the PCI bus. 5 6 Usage: vfio-unbind PCI_ADDR 7 8 Example: vfio-unbind 0000:01:00.0 9 10 All devices in the same IOMMU group will be unbound. 11 Requires root privileges. 12 -} 13 module Main where 14 15 import Aleph.Script hiding (FilePath) 16 import qualified Aleph.Script.Vfio as Vfio 17 import System.Environment (getArgs) 18 19 main :: IO () 20 main = do 21 args <- getArgs 22 case args of 23 [addr] -> script $ do 24 Vfio.unbindFromVfio (pack addr) 25 echoErr ":: Done" 26 _ -> script $ do 27 echoErr "Usage: vfio-unbind PCI_ADDR" 28 echoErr "" 29 echoErr "Example: vfio-unbind 0000:01:00.0" 30 echoErr "" 31 echoErr "Unbinds the device from vfio-pci and rescans the PCI bus." 32 echoErr "Requires root privileges." 33 exit 1