Skip to content

Commit 9b6d13f

Browse files
committed
xenmgr: Remove restartVm and reboot code
There is no meaningful difference between restartVm and startVm, so remove restartVm and the unused is_reboot boolean. Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
1 parent 9105092 commit 9b6d13f

3 files changed

Lines changed: 11 additions & 17 deletions

File tree

xenmgr/Vm/Actions.hs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ module Vm.Actions
2323
, trashUnusedServiceVms
2424
, createVm, CreateVmPms(..), defaultCreateVmPms
2525
, removeVm
26-
, restartVm
2726
, startVm
2827
, startVmInternal
2928
, rebootVm
@@ -505,16 +504,11 @@ getVhdReferences vhd = concat <$> (mapM (diskVhdReferences vhd) =<< getVms) wher
505504
references vhd disk = diskPath disk == vhd
506505

507506
startVm :: Uuid -> XM ()
508-
startVm uuid = _startVm False uuid
509-
510-
restartVm :: Uuid -> XM ()
511-
restartVm uuid = _startVm True uuid
512-
513-
_startVm :: Bool -> Uuid -> XM ()
514-
_startVm is_reboot uuid = do
507+
startVm uuid = do
508+
info $ "Starting " ++ show uuid
515509
withPreCreationState uuid $ do
516510
ran <- liftRpc $ runEventScript HardFail uuid getVmRunInsteadofStart [uuidStr uuid]
517-
when (not ran) $ startVmInternal uuid is_reboot
511+
when (not ran) $ startVmInternal uuid
518512

519513
--Add a passthrough rule to vm config
520514
add_pt_rule_bdf uuid dev = modifyVmPciPtRules uuid $ pciAddRule (form_rule_bdf (show (devAddr dev)))
@@ -523,14 +517,14 @@ form_rule_bdf = rule . fromMaybe (error "error parsing rule") . pciAndSlotFromSt
523517
rule (addr,sl) = PciPtRuleBDF addr sl
524518

525519
-- Start a VM! (maybe, because stuff can happen not)
526-
startVmInternal :: Uuid -> Bool -> XM ()
527-
startVmInternal uuid is_reboot = do
520+
startVmInternal :: Uuid -> XM ()
521+
startVmInternal uuid = do
528522
unlessM (dbExists $ "/vm/" ++ show uuid) $ error ("vm does not have a database entry: " ++ show uuid)
529523
info $ "starting VM " ++ show uuid
530524
liftRpc $ maybePtGpuFuncs uuid
531525
config <- prepareAndCheckConfig uuid
532526
case config of
533-
Just c -> info ("done checks for VM " ++ show uuid) >> bootVm c is_reboot
527+
Just c -> info ("done checks for VM " ++ show uuid) >> bootVm c
534528
Nothing-> return ()
535529
where
536530

@@ -833,8 +827,8 @@ checkAndPerformSnapshotIfReq uuid disks = do
833827
_ -> return disk --other Snapshot types unimplemented for now since UI can't set them
834828

835829

836-
bootVm :: VmConfig -> Bool -> XM ()
837-
bootVm config reboot
830+
bootVm :: VmConfig -> XM ()
831+
bootVm config
838832
= do
839833
monitor <- vm_monitor <$> xmRunVm uuid vmContext
840834

@@ -1026,7 +1020,7 @@ rebootVm uuid = do
10261020
debug $ "reboot done issuing shutdown to " ++ show uuid
10271021
done <- liftIO $ Xl.waitForState uuid Shutdown (Just 60)
10281022
debug $ "reboot waitForState returned " ++ show done
1029-
when done $ restartVm uuid
1023+
when done $ startVm uuid
10301024

10311025
shutdownVm :: Uuid -> Rpc ()
10321026
shutdownVm uuid = do

xenmgr/Vm/React.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ whenShutdown xm reason = do
315315
maybeCleanupSnapshots
316316
if reason == Reboot
317317
then do
318-
uuidRpc (backgroundRpc . runXM xm . restartVm)
318+
uuidRpc (backgroundRpc . runXM xm . startVm)
319319
else do
320320
runXM xm (maybeKeepVmAlive uuid)
321321
return ()

xenmgr/XenMgr/Expose/VmObject.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ implementationFor xm uuid = self where
103103
, comCitrixXenclientXenmgrVmDelete = unlessM policyQueryVmDeletion failActionSuppressedByPolicy >> removeVm uuid
104104
, comCitrixXenclientXenmgrVmSwitch = switchVm uuid >> return ()
105105
, comCitrixXenclientXenmgrVmStart = runXM xm (startVm uuid) >> return ()
106-
, comCitrixXenclientXenmgrVmStartInternal = runXM xm (startVmInternal uuid False) >> return ()
106+
, comCitrixXenclientXenmgrVmStartInternal = runXM xm (startVmInternal uuid) >> return ()
107107
, comCitrixXenclientXenmgrVmReboot = runXM xm (rebootVm uuid) >> return ()
108108
, comCitrixXenclientXenmgrVmShutdown = runvm invokeShutdownVm
109109
, comCitrixXenclientXenmgrVmDestroy = runvm invokeForceShutdownVm

0 commit comments

Comments
 (0)