# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1214248235 25200
# Node ID d2ad8dd8ccbdf66c416deb765d8b738e15dabc2e
# Parent 54d2e0f7e87e78a8a9e85765f0795300ec7190ce
Make ComputerSystem::RequestStateChange() set scheduling parameters at start
Currently, only do this for Xen domains.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 54d2e0f7e87e -r d2ad8dd8ccbd src/Virt_ComputerSystem.c
--- a/src/Virt_ComputerSystem.c Mon Jun 23 12:10:35 2008 -0700
+++ b/src/Virt_ComputerSystem.c Mon Jun 23 12:10:35 2008 -0700
@@ -35,6 +35,7 @@
#include "cs_util.h"
#include <libcmpiutil/libcmpiutil.h>
#include "misc_util.h"
+#include "infostore.h"
#include "device_parsing.h"
#include <libcmpiutil/std_invokemethod.h>
#include <libcmpiutil/std_instance.h>
@@ -620,6 +621,40 @@
DEFAULT_EQ();
DEFAULT_INST_CLEANUP();
+static void set_scheduler_params(virDomainPtr dom)
+{
+ struct infostore_ctx *ctx;
+ virConnectPtr conn = NULL;
+ virSchedParameter params[] =
+ {{ "weight", VIR_DOMAIN_SCHED_FIELD_UINT },
+ { "cap", VIR_DOMAIN_SCHED_FIELD_UINT },
+ };
+
+ conn = virDomainGetConnect(dom);
+ if (conn == NULL) {
+ CU_DEBUG("Unable to get connection from domain");
+ return;
+ }
+
+ if (!STREQC(virConnectGetType(conn), "xen")) {
+ CU_DEBUG("Not setting sched params for this domain type");
+ return;
+ }
+
+ ctx = infostore_open(dom);
+ if (ctx == NULL) {
+ CU_DEBUG("Unable to open infostore for domain");
+ return;
+ }
+
+ params[0].value.ui = infostore_get_u64(ctx, "weight");
+ params[1].value.ui = infostore_get_u64(ctx, "limit");
+
+ virDomainSetSchedulerParameters(dom, params, 2);
+
+ infostore_close(ctx);
+}
+
/* This composite operation may be supported as a flag to reboot */
static int domain_reset(virDomainPtr dom)
{
@@ -643,6 +678,7 @@
case VIR_DOMAIN_SHUTOFF:
CU_DEBUG("Start domain");
ret = virDomainCreate(dom);
+ set_scheduler_params(dom);
break;
case VIR_DOMAIN_PAUSED:
CU_DEBUG("Unpause domain");