* create a physical workstation resource, but specifying the size of
* s_workstation_VM2013_t and the vm workstation model object. */
workstation_CLM03_t ws = (workstation_CLM03_t) surf_resource_new(sizeof(s_workstation_VM2013_t),
- surf_vm_workstation_model, name, NULL);
+ surf_vm_workstation_model, name, NULL, NULL);
/* Currently, we assume a VM has no storage. */
ws->storage = NULL;
/* We can assume one core and cas01 cpu for the first step.
* Do xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu) if you get the resource. */
cpu_cas01_create_resource(name, // name
- sub_cpu->power_peak, // host->power_peak,
+ sub_cpu->power_peak_list, // host->power_peak,
+ sub_cpu->pstate,
1, // host->power_scale,
NULL, // host->power_trace,
1, // host->core_amount,
* free other objects than lmm_constraint. */
surf_model_t cpu_model = cpu->generic_resource.model;
lmm_constraint_free(cpu_model->model_private->maxmin_system, cpu->constraint);
+ {
+ unsigned long i;
+ for (i = 0; i < cpu->core; i++) {
+ void *cnst_id = cpu->constraint_core[i]->id;
+ lmm_constraint_free(cpu_model->model_private->maxmin_system, cpu->constraint_core[i]);
+ xbt_free(cnst_id);
+ }
+
+ xbt_free(cpu->constraint_core);
+ }
+
surf_resource_free(cpu);
/* Free the network resource of the VM. */
vm_ws->current_state = SURF_VM_STATE_RUNNING;
}
-
static double get_solved_value(surf_action_t cpu_action)
{
- int found = 0;
- /* NOTE: Do not use surf_workstation_model's maxmin_system. It is not used. */
- lmm_system_t pm_system = surf_cpu_model_pm->model_private->maxmin_system;
- lmm_variable_t var = NULL;
-
- xbt_swag_foreach(var, &pm_system->variable_set) {
- XBT_DEBUG("var id %p id_int %d double %f", var->id, var->id_int, var->value);
- if (var->id == cpu_action) {
- found = 1;
- break;
- }
- }
+ lmm_variable_t var = ((surf_action_lmm_t) cpu_action)->variable;
- if (found)
- return var->value;
-
- XBT_CRITICAL("bug: cannot found the solved variable of the action %p", cpu_action);
- DIE_IMPOSSIBLE;
- return -1; /* NOT REACHED */
+ return var->value;
}
-
-
/* In the real world, processes on the guest operating system will be somewhat
* degraded due to virtualization overhead. The total CPU share that these
* processes get is smaller than that of the VM process gets on a host
/* FIXME: 3. do we have to re-initialize our cpu_action object? */
-#if 1
+#if 0
/* iterate for all hosts including virtual machines */
xbt_lib_foreach(host_lib, cursor, key, ind_host) {
workstation_CLM03_t ws_clm03 = ind_host[SURF_WKS_LEVEL];
/* Now we can set bound for each task by using MSG_task_set_bound. But, it does
* not work for the dummy CPU action of a VM. Here, we add the set_bound
* function for the dummy CPU action. */
-static void vm_ws_set_vm_bound(void *workstation, double bound)
+static void vm_ws_set_vm_bound(void *vm, double bound)
{
- surf_resource_t ws = ((surf_resource_t) surf_workstation_resource_priv(workstation));
+ surf_resource_t ws = ((surf_resource_t) surf_workstation_resource_priv(vm));
xbt_assert(ws->model->type == SURF_MODEL_TYPE_VM_WORKSTATION);
workstation_VM2013_t vm_ws = (workstation_VM2013_t) ws;
}
+/* set the affinity of a VM to the CPU cores of a PM */
+static void vm_ws_set_vm_affinity(void *vm, void *pm, unsigned long mask)
+{
+ surf_resource_t ws = ((surf_resource_t) surf_workstation_resource_priv(vm));
+ xbt_assert(ws->model->type == SURF_MODEL_TYPE_VM_WORKSTATION);
+ workstation_VM2013_t vm_ws = (workstation_VM2013_t) ws;
+
+ surf_cpu_model_pm->set_affinity(vm_ws->cpu_action, pm, mask);
+}
+
+
static void surf_vm_workstation_model_init_internal(void)
{
surf_model_t model = surf_model_init();
// model->set_max_duration = ws_action_set_max_duration;
model->set_priority = ws_action_set_priority;
model->set_bound = ws_action_set_bound;
+ model->set_affinity = ws_action_set_affinity;
// #ifdef HAVE_TRACING
// model->set_category = ws_action_set_category;
// #endif
model->extension.vm_workstation.restore = vm_ws_restore;
model->extension.vm_workstation.get_pm = vm_ws_get_pm;
model->extension.vm_workstation.set_vm_bound = vm_ws_set_vm_bound;
+ model->extension.vm_workstation.set_vm_affinity = vm_ws_set_vm_affinity;
model->extension.workstation.set_params = ws_set_params;
model->extension.workstation.get_params = ws_get_params;