Co-authored-by: Sri Ramanujam <sramanujam@xxxxxxxxx> Signed-off-by: Matt Coleman <matt@xxxxxxxxx> --- src/hyperv/hyperv_driver.c | 83 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index e05c10d194..9fda0d6047 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -1354,6 +1354,86 @@ hypervDomainSetAutostart(virDomainPtr domain, int autostart) } +static char * +hypervDomainGetSchedulerType(virDomainPtr domain G_GNUC_UNUSED, int *nparams) +{ + if (nparams) + *nparams = 3; /* reservation, limit, weight */ + + return g_strdup("allocation"); +} + + +static int +hypervDomainGetSchedulerParametersFlags(virDomainPtr domain, + virTypedParameterPtr params, + int *nparams, unsigned int flags) +{ + hypervPrivate *priv = domain->conn->privateData; + Msvm_ComputerSystem *computerSystem = NULL; + Msvm_VirtualSystemSettingData *vssd = NULL; + Msvm_ProcessorSettingData *proc_sd = NULL; + char uuid_string[VIR_UUID_STRING_BUFLEN]; + int saved_nparams = 0; + int result = -1; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1); + + if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) + goto cleanup; + + /* get info from host */ + virUUIDFormat(domain->uuid, uuid_string); + + if (hypervGetMsvmVirtualSystemSettingDataFromUUID(priv, uuid_string, &vssd) < 0) + goto cleanup; + + if (hypervGetProcessorSD(priv, vssd->data->InstanceID, &proc_sd) < 0) + goto cleanup; + + /* parse it all out */ + if (virTypedParameterAssign(¶ms[0], VIR_DOMAIN_SCHEDULER_LIMIT, + VIR_TYPED_PARAM_LLONG, proc_sd->data->Limit) < 0) + goto cleanup; + saved_nparams++; + + if (*nparams > saved_nparams) { + if (virTypedParameterAssign(¶ms[1], VIR_DOMAIN_SCHEDULER_RESERVATION, + VIR_TYPED_PARAM_LLONG, proc_sd->data->Reservation) < 0) + goto cleanup; + saved_nparams++; + } + + if (*nparams > saved_nparams) { + if (virTypedParameterAssign(¶ms[2], VIR_DOMAIN_SCHEDULER_WEIGHT, + VIR_TYPED_PARAM_UINT, proc_sd->data->Weight) < 0) + goto cleanup; + saved_nparams++; + } + + *nparams = saved_nparams; + + result = 0; + + cleanup: + hypervFreeObject(priv, (hypervObject *)computerSystem); + hypervFreeObject(priv, (hypervObject *)vssd); + hypervFreeObject(priv, (hypervObject *)proc_sd); + + return result; +} + + +static int +hypervDomainGetSchedulerParameters(virDomainPtr domain, + virTypedParameterPtr params, + int *nparams) +{ + return hypervDomainGetSchedulerParametersFlags(domain, params, nparams, + VIR_DOMAIN_AFFECT_CURRENT); +} + + static unsigned long long hypervNodeGetFreeMemory(virConnectPtr conn) { @@ -1802,6 +1882,9 @@ static virHypervisorDriver hypervHypervisorDriver = { .domainCreateWithFlags = hypervDomainCreateWithFlags, /* 0.9.5 */ .domainGetAutostart = hypervDomainGetAutostart, /* 6.9.0 */ .domainSetAutostart = hypervDomainSetAutostart, /* 6.9.0 */ + .domainGetSchedulerType = hypervDomainGetSchedulerType, /* 6.10.0 */ + .domainGetSchedulerParameters = hypervDomainGetSchedulerParameters, /* 6.10.0 */ + .domainGetSchedulerParametersFlags = hypervDomainGetSchedulerParametersFlags, /* 6.10.0 */ .nodeGetFreeMemory = hypervNodeGetFreeMemory, /* 6.9.0 */ .connectIsEncrypted = hypervConnectIsEncrypted, /* 0.9.5 */ .connectIsSecure = hypervConnectIsSecure, /* 0.9.5 */ -- 2.27.0