mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 21:34:54 +03:00
hyperv: fix domainSuspend and domainResume on Hyper-V V2
Signed-off-by: Matt Coleman <matt@datto.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
d4f09baa6b
commit
a9f1a798fd
@ -896,19 +896,26 @@ hypervDomainSuspend(virDomainPtr domain)
|
||||
int result = -1;
|
||||
hypervPrivate *priv = domain->conn->privateData;
|
||||
Msvm_ComputerSystem *computerSystem = NULL;
|
||||
int requestedState = -1;
|
||||
|
||||
switch (priv->wmiVersion) {
|
||||
case HYPERV_WMI_VERSION_V1:
|
||||
requestedState = MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_PAUSED;
|
||||
break;
|
||||
case HYPERV_WMI_VERSION_V2:
|
||||
requestedState = MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_QUIESCE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (computerSystem->data.common->EnabledState !=
|
||||
MSVM_COMPUTERSYSTEM_ENABLEDSTATE_ENABLED) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("Domain is not active"));
|
||||
if (computerSystem->data.common->EnabledState != MSVM_COMPUTERSYSTEM_ENABLEDSTATE_ENABLED) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not active"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
result = hypervInvokeMsvmComputerSystemRequestStateChange
|
||||
(domain, MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_PAUSED);
|
||||
result = hypervInvokeMsvmComputerSystemRequestStateChange(domain, requestedState);
|
||||
|
||||
cleanup:
|
||||
hypervFreeObject(priv, (hypervObject *)computerSystem);
|
||||
@ -924,12 +931,21 @@ hypervDomainResume(virDomainPtr domain)
|
||||
int result = -1;
|
||||
hypervPrivate *priv = domain->conn->privateData;
|
||||
Msvm_ComputerSystem *computerSystem = NULL;
|
||||
int expectedState = -1;
|
||||
|
||||
switch (priv->wmiVersion) {
|
||||
case HYPERV_WMI_VERSION_V1:
|
||||
expectedState = MSVM_COMPUTERSYSTEM_ENABLEDSTATE_PAUSED;
|
||||
break;
|
||||
case HYPERV_WMI_VERSION_V2:
|
||||
expectedState = MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_QUIESCE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
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;
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user