mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
hyperv: use g_autoptr for WMI classes in hypervDomainGetVcpusFlags
Signed-off-by: Matt Coleman <matt@datto.com> Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
parent
f0f0a77ee2
commit
917ed7592a
@ -2023,12 +2023,11 @@ hypervDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
|
|||||||
static int
|
static int
|
||||||
hypervDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
|
hypervDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
|
||||||
{
|
{
|
||||||
int result = -1;
|
|
||||||
char uuid_string[VIR_UUID_STRING_BUFLEN];
|
char uuid_string[VIR_UUID_STRING_BUFLEN];
|
||||||
hypervPrivate *priv = domain->conn->privateData;
|
hypervPrivate *priv = domain->conn->privateData;
|
||||||
Msvm_ComputerSystem *computerSystem = NULL;
|
g_autoptr(Msvm_ComputerSystem) computerSystem = NULL;
|
||||||
Msvm_ProcessorSettingData *proc_sd = NULL;
|
g_autoptr(Msvm_ProcessorSettingData) proc_sd = NULL;
|
||||||
Msvm_VirtualSystemSettingData *vssd = NULL;
|
g_autoptr(Msvm_VirtualSystemSettingData) vssd = NULL;
|
||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_VCPU_LIVE |
|
virCheckFlags(VIR_DOMAIN_VCPU_LIVE |
|
||||||
VIR_DOMAIN_VCPU_CONFIG |
|
VIR_DOMAIN_VCPU_CONFIG |
|
||||||
@ -2038,36 +2037,27 @@ hypervDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
|
|||||||
|
|
||||||
/* Start by getting the Msvm_ComputerSystem */
|
/* Start by getting the Msvm_ComputerSystem */
|
||||||
if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
|
if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
/* Check @flags to see if we are to query a running domain, and fail
|
/* Check @flags to see if we are to query a running domain, and fail
|
||||||
* if that domain is not running */
|
* if that domain is not running */
|
||||||
if (flags & VIR_DOMAIN_VCPU_LIVE &&
|
if (flags & VIR_DOMAIN_VCPU_LIVE &&
|
||||||
computerSystem->data->EnabledState != MSVM_COMPUTERSYSTEM_ENABLEDSTATE_ENABLED) {
|
computerSystem->data->EnabledState != MSVM_COMPUTERSYSTEM_ENABLEDSTATE_ENABLED) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not active"));
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not active"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check @flags to see if we are to return the maximum vCPU limit */
|
/* Check @flags to see if we are to return the maximum vCPU limit */
|
||||||
if (flags & VIR_DOMAIN_VCPU_MAXIMUM) {
|
if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
|
||||||
result = hypervConnectGetMaxVcpus(domain->conn, NULL);
|
return hypervConnectGetMaxVcpus(domain->conn, NULL);
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hypervGetMsvmVirtualSystemSettingDataFromUUID(priv, uuid_string, &vssd) < 0)
|
if (hypervGetMsvmVirtualSystemSettingDataFromUUID(priv, uuid_string, &vssd) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (hypervGetProcessorSD(priv, vssd->data->InstanceID, &proc_sd) < 0)
|
if (hypervGetProcessorSD(priv, vssd->data->InstanceID, &proc_sd) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
result = proc_sd->data->VirtualQuantity;
|
return proc_sd->data->VirtualQuantity;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
hypervFreeObject((hypervObject *)computerSystem);
|
|
||||||
hypervFreeObject((hypervObject *)vssd);
|
|
||||||
hypervFreeObject((hypervObject *)proc_sd);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user