From: Michal Privoznik Date: Wed, 21 Oct 2020 12:36:16 +0000 (+0200) Subject: hyperv: Use hypervRequestStateChange() in hypervDomainSuspend() X-Git-Tag: v6.9.0-rc1~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=864d79e45260f2c0a9ec1d1bce4fc3f9d464edb7;p=thirdparty%2Flibvirt.git hyperv: Use hypervRequestStateChange() in hypervDomainSuspend() A few commits ago, hypervRequestStateChange() helper was introduced which has exactly the same code as a part of hypervDomainSuspend(). Deduplicate by calling the helper. Signed-off-by: Michal Privoznik Reviewed-by: Matt Coleman --- diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 4b198f5b95..d08b6cff2e 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -893,9 +893,7 @@ hypervDomainLookupByName(virConnectPtr conn, const char *name) static int hypervDomainSuspend(virDomainPtr domain) { - int result = -1; hypervPrivate *priv = domain->conn->privateData; - Msvm_ComputerSystem *computerSystem = NULL; int requestedState = -1; switch (priv->wmiVersion) { @@ -907,20 +905,7 @@ hypervDomainSuspend(virDomainPtr domain) 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")); - goto cleanup; - } - - result = hypervInvokeMsvmComputerSystemRequestStateChange(domain, requestedState); - - cleanup: - hypervFreeObject(priv, (hypervObject *)computerSystem); - - return result; + return hypervRequestStateChange(domain, requestedState); }