[PATCH 07/21] Added implementation for virDomainGetSchedulerType and virDomainGetSchedulerParameters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: yvinter <yves.vinter@xxxxxxxx>

---
 src/hyperv/hyperv_driver.c | 129 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 129 insertions(+)

diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index aadadb1..4074fb0 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -41,6 +41,7 @@
 #include "hyperv_wmi.h"
 #include "openwsman.h"
 #include "virstring.h"
+#include "virtypedparam.h"
 
 #define VIR_FROM_THIS VIR_FROM_HYPERV
 
@@ -1782,6 +1783,131 @@ hypervDomainShutdown(virDomainPtr dom)
 
 
 
+static int
+hypervDomainGetSchedulerParametersFlags(virDomainPtr dom, virTypedParameterPtr params,
+                                        int *nparams, unsigned int flags)
+{
+    hypervPrivate *priv = dom->conn->privateData;
+    Msvm_ComputerSystem *computerSystem = NULL;
+    Msvm_ProcessorSettingData *processorSettingData = NULL;
+    Msvm_VirtualSystemSettingData *virtualSystemSettingData = NULL;
+    char uuid_string[VIR_UUID_STRING_BUFLEN];
+    virBuffer query = VIR_BUFFER_INITIALIZER;
+    int saved_nparams = 0;
+    int result = -1;
+    
+    virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |VIR_DOMAIN_AFFECT_CONFIG |VIR_TYPED_PARAM_STRING_OKAY, -1);
+    
+    /* We don't return strings, and thus trivially support this flag */
+    flags &= ~VIR_TYPED_PARAM_STRING_OKAY;
+    
+    virUUIDFormat(dom->uuid, uuid_string);
+    
+    /* Get Msvm_ComputerSystem */
+    if (hypervMsvmComputerSystemFromDomain(dom, &computerSystem) < 0) {
+        goto cleanup;
+    }
+    
+    /* Get Msvm_VirtualSystemSettingData */
+    virBufferAsprintf(&query,
+                      "associators of "
+                      "{Msvm_ComputerSystem.CreationClassName=\"Msvm_ComputerSystem\","
+                      "Name=\"%s\"} "
+                      "where AssocClass = Msvm_SettingsDefineState "
+                      "ResultClass = Msvm_VirtualSystemSettingData",
+                      uuid_string);
+    
+    if (hypervGetMsvmVirtualSystemSettingDataList(priv, &query, &virtualSystemSettingData) < 0) {
+        goto cleanup;
+    }
+    
+    if (virtualSystemSettingData == NULL) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Could not lookup %s for domain %s"),
+                       "Msvm_VirtualSystemSettingData",
+                       computerSystem->data->ElementName);
+        goto cleanup;
+    }
+    
+    /* Get Msvm_ProcessorSettingData */
+    virBufferAsprintf(&query,
+                      "associators of "
+                      "{Msvm_VirtualSystemSettingData.InstanceID=\"%s\"} "
+                      "where AssocClass = Msvm_VirtualSystemSettingDataComponent "
+                      "ResultClass = Msvm_ProcessorSettingData",
+                      virtualSystemSettingData->data->InstanceID);
+    
+    if (hypervGetMsvmProcessorSettingDataList(priv, &query, &processorSettingData) < 0) {
+        goto cleanup;
+    }
+    
+    if (processorSettingData == NULL) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not lookup %s for domain %s"),
+                       "Msvm_ProcessorSettingData",computerSystem->data->ElementName);
+        goto cleanup;
+    }
+    
+    if (virTypedParameterAssign(&params[0], VIR_DOMAIN_SCHEDULER_LIMIT,
+                                VIR_TYPED_PARAM_LLONG, processorSettingData->data->Limit) < 0)
+        goto cleanup;
+    saved_nparams++;
+    
+    if (*nparams > saved_nparams) {
+        if (virTypedParameterAssign(&params[1],VIR_DOMAIN_SCHEDULER_RESERVATION,
+                                    VIR_TYPED_PARAM_LLONG, processorSettingData->data->Reservation) < 0)
+            goto cleanup;
+        saved_nparams++;
+    }
+    
+    if (*nparams > saved_nparams) {
+        if (virTypedParameterAssign(&params[2],VIR_DOMAIN_SCHEDULER_WEIGHT,
+                                    VIR_TYPED_PARAM_UINT, processorSettingData->data->Weight) < 0)
+            goto cleanup;
+        saved_nparams++;
+    }
+    
+    *nparams = saved_nparams;
+    
+    result = 0;
+    
+ cleanup:
+    hypervFreeObject(priv, (hypervObject *)computerSystem);
+    hypervFreeObject(priv, (hypervObject *)virtualSystemSettingData);
+    hypervFreeObject(priv, (hypervObject *)processorSettingData);
+    virBufferFreeAndReset(&query);
+
+    return result;
+}
+
+
+
+static int
+hypervDomainGetSchedulerParameters(virDomainPtr dom, virTypedParameterPtr params, int *nparams)
+{
+    return hypervDomainGetSchedulerParametersFlags(dom, params, nparams, VIR_DOMAIN_AFFECT_CURRENT);
+}
+
+
+
+static char*
+hypervDomainGetSchedulerType(virDomainPtr domain ATTRIBUTE_UNUSED, int *nparams)
+{
+    char *type;
+    
+    if (VIR_STRDUP(type, "allocation") < 0) {
+        virReportOOMError();
+        return NULL;
+    }
+    
+    if (nparams != NULL) {
+        *nparams = 3; /* reservation, limit, weight */
+    }
+    
+    return type;
+}
+
+
+
 static virDriver hypervDriver = {
     .no = VIR_DRV_HYPERV,
     .name = "Hyper-V",
@@ -1826,6 +1952,9 @@ static virDriver hypervDriver = {
     .nodeGetFreeMemory = hypervNodeGetFreeMemory, /* 1.2.10 */
     .domainShutdownFlags = hypervDomainShutdownFlags, /* 1.2.10 */
     .domainShutdown = hypervDomainShutdown, /* 1.2.10 */
+    .domainGetSchedulerParametersFlags = hypervDomainGetSchedulerParametersFlags, /* 1.2.10 */
+    .domainGetSchedulerParameters = hypervDomainGetSchedulerParameters, /* 1.2.10 */
+    .domainGetSchedulerType = hypervDomainGetSchedulerType, /* 1.2.10 */
 };
 
 
-- 
1.9.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]