Commit afa0fca4 authored by Jose A. Lopes's avatar Jose A. Lopes
Browse files

User shutdown hypervisor parameter



Add user shutdown parameter for KVM.  Based on this parameter, decide
what information to report for a KVM instance, for example,
distinguish between 'ADMIN_down' and 'USER_down'.
Signed-off-by: default avatarJose A. Lopes <jabolopes@google.com>
Reviewed-by: default avatarMichele Tartara <mtartara@google.com>
parent 306b855a
......@@ -225,7 +225,9 @@ class LUInstanceQueryData(NoHooksLU):
remote_info.Raise("Error checking node %s" % pnode.name)
remote_info = remote_info.payload
if remote_info and "state" in remote_info:
if hv_base.HvInstanceState.IsShutdown(remote_info["state"]):
if hv_base.HvInstanceState.IsShutdown(remote_info["state"]) \
and (instance.hypervisor != constants.HT_KVM
or instance.hvparams[constants.HV_KVM_USER_SHUTDOWN]):
remote_state = "user down"
else:
remote_state = "up"
......
......@@ -705,6 +705,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
hv_base.ParamInSet(False, constants.HT_KVM_FLAG_VALUES),
constants.HV_VHOST_NET: hv_base.NO_CHECK,
constants.HV_KVM_USE_CHROOT: hv_base.NO_CHECK,
constants.HV_KVM_USER_SHUTDOWN: hv_base.NO_CHECK,
constants.HV_MEM_PATH: hv_base.OPT_DIR_CHECK,
constants.HV_REBOOT_BEHAVIOR:
hv_base.ParamInSet(True, constants.REBOOT_BEHAVIORS),
......
......@@ -1565,6 +1565,9 @@ hvKvmSpiceZlibGlzImgCompr = "spice_zlib_glz_wan_compression"
hvKvmUseChroot :: String
hvKvmUseChroot = "use_chroot"
hvKvmUserShutdown :: String
hvKvmUserShutdown = "user_shutdown"
hvMemPath :: String
hvMemPath = "mem_path"
......@@ -1721,6 +1724,7 @@ hvsParameterTypes = Map.fromList
, (hvKvmSpiceUseVdagent, VTypeBool)
, (hvKvmSpiceZlibGlzImgCompr, VTypeString)
, (hvKvmUseChroot, VTypeBool)
, (hvKvmUserShutdown, VTypeBool)
, (hvMemPath, VTypeString)
, (hvMigrationBandwidth, VTypeInt)
, (hvMigrationDowntime, VTypeInt)
......@@ -3717,6 +3721,7 @@ hvcDefaults =
, (hvKvmFlag, PyValueEx "")
, (hvVhostNet, PyValueEx False)
, (hvKvmUseChroot, PyValueEx False)
, (hvKvmUserShutdown, PyValueEx False)
, (hvMemPath, PyValueEx "")
, (hvRebootBehavior, PyValueEx instanceRebootAllowed)
, (hvCpuMask, PyValueEx cpuPinningAll)
......
......@@ -628,11 +628,18 @@ liveInstanceStatus (instInfo, foundOnPrimary) inst
case instanceState of
InstanceStateRunning | adminState == AdminUp -> Running
| otherwise -> ErrorUp
InstanceStateShutdown | adminState == AdminUp -> UserDown
InstanceStateShutdown | adminState == AdminUp && allowDown -> UserDown
| otherwise -> StatusDown
where adminState = instAdminState inst
instanceState = instInfoState instInfo
hvparams = fromContainer $ instHvparams inst
allowDown =
instHypervisor inst /= Kvm ||
(Map.member C.hvKvmUserShutdown hvparams &&
hvparams Map.! C.hvKvmUserShutdown == J.JSBool True)
-- | Determines the status of a dead instance.
deadInstanceStatus :: Instance -> InstanceStatus
deadInstanceStatus inst =
......
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