-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Haskell bindings to Xen hypervisor interface -- -- Haskell bindings to Xen hypervisor interface @package hen @version 0.0.2 -- | This module provides every special exception that can be raised in Mid -- and High-level interfaces. module System.Xen.Errors -- | This error can be raised if handle can not be opened, insufficient -- rights for example. data XcHandleOpenError XcHandleOpenError :: Errno -> XcHandleOpenError -- | This error can be raised if peecked value of -- DomainShutdownReason is not expected. data InvalidDomainShutdownReason -- | Peeked value InvalidDomainShutdownReason :: CInt -> InvalidDomainShutdownReason -- | This error can be raised if any error occured during receiving the -- list, for example: try to to fetch a list in domU. data DomainGetInfoError DomainGetInfoError :: Errno -> DomainGetInfoError -- | Generalized version of getErrno getErrno :: MonadBase IO m => m Errno instance Typeable XcHandleOpenError instance Typeable InvalidDomainShutdownReason instance Typeable DomainGetInfoError instance Typeable Errno instance Show Errno instance Ord Errno instance Eq XcHandleOpenError instance Ord XcHandleOpenError instance Show XcHandleOpenError instance Eq InvalidDomainShutdownReason instance Ord InvalidDomainShutdownReason instance Show InvalidDomainShutdownReason instance Eq DomainGetInfoError instance Ord DomainGetInfoError instance Show DomainGetInfoError instance Exception DomainGetInfoError instance Exception InvalidDomainShutdownReason instance Exception XcHandleOpenError -- | Types for working with XenCtrl data and accoring -- Storable instances. module System.Xen.Types -- | Entry point of the hypervisor interface connection, it's a file -- descriptor in xen 3 and pointer to corresponging structure in xen 4. newtype XcHandle XcHandle :: CIntPtr -> XcHandle -- | Domain id, wrapper around Word32. newtype DomId DomId :: Word32 -> DomId unDomId :: DomId -> Word32 -- | Domain flags. It's translated from xc_dominfo structure, so it's -- possible to be mutual exclusion flags in one domain, e.g. -- DomainFlagShutdown and DomainFlagRunning. data DomainFlag DomainFlagDying :: DomainFlag DomainFlagCrashed :: DomainFlag DomainFlagShutdown :: DomainFlag DomainFlagPaused :: DomainFlag DomainFlagBlocked :: DomainFlag DomainFlagRunning :: DomainFlag DomainFlagHVM :: DomainFlag DomainFlagDebugged :: DomainFlag -- | Domain shutdown reason it's only meaningful if domain has -- DomainFlagShutdown flag. data DomainShutdownReason DomainShutdownReasonPoweroff :: DomainShutdownReason DomainShutdownReasonReboot :: DomainShutdownReason DomainShutdownReasonSuspend :: DomainShutdownReason DomainShutdownReasonCrash :: DomainShutdownReason DomainShutdownReasonWatchdog :: DomainShutdownReason -- | Information about a single domain. data DomainInfo DomainInfo :: {-# UNPACK #-} !DomId -> {-# UNPACK #-} !Word32 -> BitSet DomainFlag -> Maybe DomainShutdownReason -> {-# UNPACK #-} !Word32 -> {-# UNPACK #-} !Word32 -> {-# UNPACK #-} !Word32 -> {-# UNPACK #-} !Word64 -> {-# UNPACK #-} !Word32 -> {-# UNPACK #-} !Word32 -> {-# UNPACK #-} !Word32 -> {-# UNPACK #-} !UUID -> {-# UNPACK #-} !Word32 -> DomainInfo domainInfoId :: DomainInfo -> {-# UNPACK #-} !DomId domainInfoSsidRef :: DomainInfo -> {-# UNPACK #-} !Word32 domainInfoFlags :: DomainInfo -> BitSet DomainFlag domainInfoShutdownReason :: DomainInfo -> Maybe DomainShutdownReason domainInfoNumberOfPages :: DomainInfo -> {-# UNPACK #-} !Word32 domainInfoNumberOfSharedPages :: DomainInfo -> {-# UNPACK #-} !Word32 domainInfoSharedInfoFrame :: DomainInfo -> {-# UNPACK #-} !Word32 domainInfoCpuTime :: DomainInfo -> {-# UNPACK #-} !Word64 domainInfoMaxMemKb :: DomainInfo -> {-# UNPACK #-} !Word32 domainInfoNubmerOfOnlineVcpus :: DomainInfo -> {-# UNPACK #-} !Word32 domainInfoMaxVcpuId :: DomainInfo -> {-# UNPACK #-} !Word32 domainInfoDomHandle :: DomainInfo -> {-# UNPACK #-} !UUID domainInfoCpuPool :: DomainInfo -> {-# UNPACK #-} !Word32 instance Eq XcHandle instance Ord XcHandle instance Show XcHandle instance Storable XcHandle instance Eq DomId instance Ord DomId instance Show DomId instance Read DomId instance Storable DomId instance Enum DomainFlag instance Eq DomainFlag instance Ord DomainFlag instance Show DomainFlag instance Read DomainFlag instance Eq DomainShutdownReason instance Ord DomainShutdownReason instance Show DomainShutdownReason instance Read DomainShutdownReason instance Eq DomainInfo instance Ord DomainInfo instance Show DomainInfo instance Read DomainInfo instance Storable DomainInfo instance Storable DomainShutdownReason -- | Low-level interface to XenCtrl. Each function defined in this -- module is a ffi call to corresponding c function. module System.Xen.Low -- | This function opens the handle to the hypervisor interface. Each -- successful call to this function should have a corresponding call to -- xc_interface_close. xc_interface_open :: CInt -> CInt -> CInt -> IO XcHandle -- | This function closes an open hypervisor interface. This function can -- fail if the handle does not represent an open interface or if there -- were problems closing the interface. In the latter case the interface -- is still closed. xc_interface_close :: XcHandle -> IO CInt -- | This function will return information about one or more domains. It is -- designed to iterate over the list of domains. If a single domain is -- requested, this function will return the next domain in the list - if -- one exists. It is, therefore, important in this case to make sure the -- domain requested was the one returned. xc_domain_getinfo :: XcHandle -> DomId -> CUInt -> Ptr DomainInfo -> IO CInt -- | Mid-level interface to XenCtrl. Functions that provided by -- this module are version-independent from Xen and raise real -- exceptions instead of confusing error codes and errno. module System.Xen.Mid -- | Open the connection to the hypervisor interface, can fail with -- XcHandleOpenError. interfaceOpen :: MonadBase IO m => m XcHandle -- | Close an open hypervisor interface, ignores all possible errors but -- all the same can fail with segfault or sutin. interfaceClose :: MonadBase IO m => XcHandle -> m () -- | Returns a list of currently runing domains, 1024 maximum, can fail -- with InvalidDomainShutdownReason and DomainGetInfoError. domainGetInfo :: MonadBase IO m => XcHandle -> m [DomainInfo] -- | High-level interface to XenCtrl. Contains Xen monad -- and provides a safe way to run any Xen computation. module System.Xen.High -- | This is a special monad for operations with XenCtrl, it's a -- wrapper around ReaderT transformer and it controls the -- connection to the hypervisor. Because Xen has instances of and -- MonadBase and MonadBaseControl over IO, you can -- use any functions of lifted-base library, or any IO -- with liftBase. data Xen a -- | Returns a lift of domains, this function can fail with -- InvalidDomainShutdownReason and DomainGetInfoError. domainGetInfo :: Xen [DomainInfo] -- | Helper function for creating high-level interface functions from -- mid-level. Generally high-level function is just highLevel = -- withXenHandle midLevel. withXenHandle :: (XcHandle -> Xen a) -> Xen a -- | Open new connection to the hypervisor, run any Xen action and -- close connection if nessesary. This function can fail with Either -- SomeException with XcHandleOpenError and any error of -- providing Xen action. runXen :: MonadBaseControl IO m => Xen a -> m (Either SomeException a) instance Functor Xen instance Applicative Xen instance Monad Xen instance MonadBase IO Xen instance MonadBaseControl IO Xen -- | Haskell bidings to Xen hypervisor interface. There are three interface -- levels in this library: -- --
-- module Main (main) where -- -- import System.Xen (runXen, domainGetInfo) -- -- main :: IO () -- main = print =<< runXen domainGetInfo --module System.Xen -- | This error can be raised if handle can not be opened, insufficient -- rights for example. data XcHandleOpenError XcHandleOpenError :: Errno -> XcHandleOpenError -- | This error can be raised if peecked value of -- DomainShutdownReason is not expected. data InvalidDomainShutdownReason -- | Peeked value InvalidDomainShutdownReason :: CInt -> InvalidDomainShutdownReason -- | This error can be raised if any error occured during receiving the -- list, for example: try to to fetch a list in domU. data DomainGetInfoError DomainGetInfoError :: Errno -> DomainGetInfoError -- | Domain id, wrapper around Word32. newtype DomId DomId :: Word32 -> DomId unDomId :: DomId -> Word32 -- | Domain flags. It's translated from xc_dominfo structure, so it's -- possible to be mutual exclusion flags in one domain, e.g. -- DomainFlagShutdown and DomainFlagRunning. data DomainFlag DomainFlagDying :: DomainFlag DomainFlagCrashed :: DomainFlag DomainFlagShutdown :: DomainFlag DomainFlagPaused :: DomainFlag DomainFlagBlocked :: DomainFlag DomainFlagRunning :: DomainFlag DomainFlagHVM :: DomainFlag DomainFlagDebugged :: DomainFlag -- | Domain shutdown reason it's only meaningful if domain has -- DomainFlagShutdown flag. data DomainShutdownReason DomainShutdownReasonPoweroff :: DomainShutdownReason DomainShutdownReasonReboot :: DomainShutdownReason DomainShutdownReasonSuspend :: DomainShutdownReason DomainShutdownReasonCrash :: DomainShutdownReason DomainShutdownReasonWatchdog :: DomainShutdownReason -- | Information about a single domain. data DomainInfo DomainInfo :: {-# UNPACK #-} !DomId -> {-# UNPACK #-} !Word32 -> BitSet DomainFlag -> Maybe DomainShutdownReason -> {-# UNPACK #-} !Word32 -> {-# UNPACK #-} !Word32 -> {-# UNPACK #-} !Word32 -> {-# UNPACK #-} !Word64 -> {-# UNPACK #-} !Word32 -> {-# UNPACK #-} !Word32 -> {-# UNPACK #-} !Word32 -> {-# UNPACK #-} !UUID -> {-# UNPACK #-} !Word32 -> DomainInfo domainInfoId :: DomainInfo -> {-# UNPACK #-} !DomId domainInfoSsidRef :: DomainInfo -> {-# UNPACK #-} !Word32 domainInfoFlags :: DomainInfo -> BitSet DomainFlag domainInfoShutdownReason :: DomainInfo -> Maybe DomainShutdownReason domainInfoNumberOfPages :: DomainInfo -> {-# UNPACK #-} !Word32 domainInfoNumberOfSharedPages :: DomainInfo -> {-# UNPACK #-} !Word32 domainInfoSharedInfoFrame :: DomainInfo -> {-# UNPACK #-} !Word32 domainInfoCpuTime :: DomainInfo -> {-# UNPACK #-} !Word64 domainInfoMaxMemKb :: DomainInfo -> {-# UNPACK #-} !Word32 domainInfoNubmerOfOnlineVcpus :: DomainInfo -> {-# UNPACK #-} !Word32 domainInfoMaxVcpuId :: DomainInfo -> {-# UNPACK #-} !Word32 domainInfoDomHandle :: DomainInfo -> {-# UNPACK #-} !UUID domainInfoCpuPool :: DomainInfo -> {-# UNPACK #-} !Word32 -- | This is a special monad for operations with XenCtrl, it's a -- wrapper around ReaderT transformer and it controls the -- connection to the hypervisor. Because Xen has instances of and -- MonadBase and MonadBaseControl over IO, you can -- use any functions of lifted-base library, or any IO -- with liftBase. data Xen a -- | Returns a lift of domains, this function can fail with -- InvalidDomainShutdownReason and DomainGetInfoError. domainGetInfo :: Xen [DomainInfo] -- | Open new connection to the hypervisor, run any Xen action and -- close connection if nessesary. This function can fail with Either -- SomeException with XcHandleOpenError and any error of -- providing Xen action. runXen :: MonadBaseControl IO m => Xen a -> m (Either SomeException a)