} else {
PrintDebug(vm, VCORE_NONE,"VM time slaved to host TSC.\n");
}
- }
+ }
// Should we make a separate TSC device that handles this sort of thing?
tsc = v3_cfg_val(cfg, "tsc");
PrintError(vm, VCORE_NONE, "WARNING: Guest TSC set to passthrough host TSC, but guest time not slaved to host time.");
}
vm->time_state.flags |= V3_TIME_TSC_PASSTHROUGH;
- } else if (strcasecmp(source, "guest") != 0) {
+ } else if (!source || (strcasecmp(source, "guest") != 0)) {
PrintError(vm, VCORE_NONE, "ERROR: Unknown TSC configuration in time configuration.\n");
}
}
int v3_init_time_vm(struct v3_vm_info * vm) {
v3_cfg_tree_t * cfg_tree = vm->cfg_data->cfg;
- int ret;
+ int ret=0;
PrintDebug(vm, VCORE_NONE, "Installing TSC MSR hook.\n");
ret = v3_hook_msr(vm, TSC_MSR,
PrintDebug(vm, VCORE_NONE, "Registering TIME_CPUFREQ hypercall.\n");
ret = v3_register_hypercall(vm, TIME_CPUFREQ_HCALL,
handle_cpufreq_hcall, NULL);
+
+ if (ret!=0) {
+ return ret;
+ }
+
PrintDebug(vm, VCORE_NONE, "Registering TIME_RDHTSC hypercall.\n");
ret = v3_register_hypercall(vm, TIME_RDHTSC_HCALL,
handle_rdhtsc_hcall, NULL);
+ if (ret!=0) {
+ return ret;
+ }
+
handle_time_configuration(vm, v3_cfg_subtree(cfg_tree, "time"));
return ret;
(time_state->clock_ratio_num != 1) ||
(info->vm_info->time_state.td_num != 1) ||
(info->vm_info->time_state.td_denom != 1)) {
- if (time_state->flags | VM_TIME_TSC_PASSTHROUGH) {
+ if (time_state->flags & VM_TIME_TSC_PASSTHROUGH) {
PrintError(info->vm_info, info, "WARNING: Cannot use reqested passthrough TSC with clock or time modification also requested.\n");
time_state->flags &= ~VM_TIME_TSC_PASSTHROUGH;
}
struct v3_timer * tmr = NULL;
struct v3_timer * tmp = NULL;
- list_for_each_entry_safe(tmr, tmp, &(time_state->timers), timer_link) {
- v3_remove_timer(core, tmr);
+ if (*(void**)&time_state->timers) {
+ list_for_each_entry_safe(tmr, tmp, &(time_state->timers), timer_link) {
+ v3_remove_timer(core, tmr);
+ }
}
}