Commit 658dfed1 authored by Jose A. Lopes's avatar Jose A. Lopes

KVM daemon decides if it should run

This patch modifies the KVM daemon startup to test whether the node if
the enabled hypervisor is KVM, whether the node is VM capable, and if
user shutdown is enabled.  If at least one of these conditions is not
met, the KVM daemon will exit.
Signed-off-by: default avatarJose A. Lopes <jabolopes@google.com>
Reviewed-by: default avatarHrvoje Ribicic <riba@google.com>
parent 6050b2eb
......@@ -41,6 +41,7 @@ module Ganeti.Daemon
, parseArgs
, parseAddress
, cleanupSocket
, getFQDN
, describeError
, genericMain
) where
......
......@@ -66,9 +66,13 @@ import System.IO.Error (isEOFError)
import System.INotify
import qualified AutoConf
import qualified Ganeti.BasicTypes as BasicTypes
import qualified Ganeti.Constants as Constants
import qualified Ganeti.Daemon as Daemon (getFQDN)
import qualified Ganeti.Logging as Logging
import qualified Ganeti.UDSServer as UDSServer
import qualified Ganeti.Ssconf as Ssconf
import qualified Ganeti.Types as Types
type Lock = MVar ()
type Monitors = MVar (Set FilePath)
......@@ -305,4 +309,26 @@ startWith dir =
withINotify (rewatchDir lock dir)
start :: IO ()
start = startWith monitorDir
start =
do fqdn <- Daemon.getFQDN
hypervisors <- Ssconf.getHypervisorList Nothing
userShutdown <- Ssconf.getEnabledUserShutdown Nothing
vmCapable <- Ssconf.getNodesVmCapable Nothing
BasicTypes.genericResult
Logging.logInfo
(const $ startWith monitorDir) $ do
isKvm =<< hypervisors
isUserShutdown =<< userShutdown
isVmCapable fqdn =<< vmCapable
where
isKvm hs
| Types.Kvm `elem` hs = return ()
| otherwise = fail "KVM not enabled, exiting"
isUserShutdown True = return ()
isUserShutdown _ = fail "User shutdown not enabled, exiting"
isVmCapable node vmCapables =
case lookup node vmCapables of
Just True -> return ()
_ -> fail $ "Node " ++ show node ++ " is not VM capable, exiting"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment