Signed-off-by: Matt Coleman <matt@xxxxxxxxx> --- src/hyperv/hyperv_driver.c | 15 +++++++++++---- src/hyperv/hyperv_wmi_classes.h | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 0b28c1e94b..89840f7ac4 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -867,6 +867,10 @@ hypervDomainSuspend(virDomainPtr domain) int result = -1; hypervPrivate *priv = domain->conn->privateData; Msvm_ComputerSystem *computerSystem = NULL; + int requestedState = MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_PAUSED; + + if (priv->wmiVersion == HYPERV_WMI_VERSION_V2) + requestedState = MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_QUIESCE; if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; @@ -878,8 +882,8 @@ hypervDomainSuspend(virDomainPtr domain) goto cleanup; } - result = hypervInvokeMsvmComputerSystemRequestStateChange - (domain, MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_PAUSED); + result = hypervInvokeMsvmComputerSystemRequestStateChange(domain, + requestedState); cleanup: hypervFreeObject(priv, (hypervObject *)computerSystem); @@ -895,12 +899,15 @@ hypervDomainResume(virDomainPtr domain) int result = -1; hypervPrivate *priv = domain->conn->privateData; Msvm_ComputerSystem *computerSystem = NULL; + int expectedState = MSVM_COMPUTERSYSTEM_ENABLEDSTATE_PAUSED; + + if (priv->wmiVersion == HYPERV_WMI_VERSION_V2) + expectedState = MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_QUIESCE; if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - if (computerSystem->data.common->EnabledState != - MSVM_COMPUTERSYSTEM_ENABLEDSTATE_PAUSED) { + if (computerSystem->data.common->EnabledState != expectedState) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not paused")); goto cleanup; diff --git a/src/hyperv/hyperv_wmi_classes.h b/src/hyperv/hyperv_wmi_classes.h index 7f4159dd8e..0074d8889e 100644 --- a/src/hyperv/hyperv_wmi_classes.h +++ b/src/hyperv/hyperv_wmi_classes.h @@ -73,6 +73,7 @@ enum _Msvm_ComputerSystem_EnabledState { enum _Msvm_ComputerSystem_RequestedState { MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_ENABLED = 2, MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_DISABLED = 3, + MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_QUIESCE = 9, MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_REBOOT = 10, MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_RESET = 11, MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_PAUSED = 32768, -- 2.27.0