mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
hyperv: implement domainGetVcpusFlags
Co-authored-by: Sri Ramanujam <sramanujam@datto.com> Signed-off-by: Matt Coleman <matt@datto.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
01a93d55a0
commit
b516400976
@ -1078,6 +1078,57 @@ hypervDomainGetState(virDomainPtr domain, int *state, int *reason,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
hypervDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
|
||||
{
|
||||
int result = -1;
|
||||
char uuid_string[VIR_UUID_STRING_BUFLEN];
|
||||
hypervPrivate *priv = domain->conn->privateData;
|
||||
Msvm_ComputerSystem *computerSystem = NULL;
|
||||
Msvm_ProcessorSettingData *proc_sd = NULL;
|
||||
Msvm_VirtualSystemSettingData *vssd = NULL;
|
||||
|
||||
virCheckFlags(VIR_DOMAIN_VCPU_LIVE |
|
||||
VIR_DOMAIN_VCPU_CONFIG |
|
||||
VIR_DOMAIN_VCPU_MAXIMUM, -1);
|
||||
|
||||
virUUIDFormat(domain->uuid, uuid_string);
|
||||
|
||||
/* Start by getting the Msvm_ComputerSystem */
|
||||
if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
|
||||
goto cleanup;
|
||||
|
||||
/* Check @flags to see if we are to query a running domain, and fail
|
||||
* if that domain is not running */
|
||||
if (flags & VIR_DOMAIN_VCPU_LIVE &&
|
||||
computerSystem->data->EnabledState != MSVM_COMPUTERSYSTEM_ENABLEDSTATE_ENABLED) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not active"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Check @flags to see if we are to return the maximum vCPU limit */
|
||||
if (flags & VIR_DOMAIN_VCPU_MAXIMUM) {
|
||||
result = hypervConnectGetMaxVcpus(domain->conn, NULL);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (hypervGetMsvmVirtualSystemSettingDataFromUUID(priv, uuid_string, &vssd) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (hypervGetProcessorSD(priv, vssd->data->InstanceID, &proc_sd) < 0)
|
||||
goto cleanup;
|
||||
|
||||
result = proc_sd->data->VirtualQuantity;
|
||||
|
||||
cleanup:
|
||||
hypervFreeObject(priv, (hypervObject *)computerSystem);
|
||||
hypervFreeObject(priv, (hypervObject *)vssd);
|
||||
hypervFreeObject(priv, (hypervObject *)proc_sd);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
hypervDomainGetVcpus(virDomainPtr domain,
|
||||
virVcpuInfoPtr info,
|
||||
@ -1930,6 +1981,7 @@ static virHypervisorDriver hypervHypervisorDriver = {
|
||||
.domainSetMemoryFlags = hypervDomainSetMemoryFlags, /* 3.6.0 */
|
||||
.domainGetInfo = hypervDomainGetInfo, /* 0.9.5 */
|
||||
.domainGetState = hypervDomainGetState, /* 0.9.5 */
|
||||
.domainGetVcpusFlags = hypervDomainGetVcpusFlags, /* 6.10.0 */
|
||||
.domainGetVcpus = hypervDomainGetVcpus, /* 6.10.0 */
|
||||
.domainGetXMLDesc = hypervDomainGetXMLDesc, /* 0.9.5 */
|
||||
.connectListDefinedDomains = hypervConnectListDefinedDomains, /* 0.9.5 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user