--- /dev/null
+/*
+ * This file is part of the Palacios Virtual Machine Monitor developed
+ * by the V3VEE Project with funding from the United States National
+ * Science Foundation and the Department of Energy.
+ *
+ * The V3VEE Project is a joint project between Northwestern University
+ * and the University of New Mexico. You can find out more at
+ * http://www.v3vee.org
+ *
+ * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
+ * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org>
+ * All rights reserved.
+ *
+ * Author: Jack Lange <jarusl@cs.northwestern.edu>
+ *
+ * This is free software. You are permitted to use,
+ * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
+ */
+
+#ifndef __VMM_MUXER_H__
+#define __VMM_MUXER_H__
+
+#ifdef __V3VEE__
+
+
+struct v3_vm_info;
+
+
+
+struct v3_vm_info * v3_get_foreground_vm();
+void v3_set_foreground_vm(struct v3_vm_info * vm);
+
+
+int v3_add_mux_notification(int (*focus_change)(struct v3_vm_info * old_vm, struct v3_vm_info * new_vm));
+
+
+#endif
+
+#endif
vmm_xed.o \
vmm_binaries.o \
vmm_cpuid.o \
- vmm_xml.o
+ vmm_xml.o \
+ vmm_muxer.o
obj-$(CONFIG_SVM) += svm.o \
svm_io.o \
#endif
+ rdtscll(tmp_tsc);
+ v3_update_time(info, tmp_tsc - info->time_state.cached_host_tsc);
rdtscll(info->time_state.cached_host_tsc);
- guest_ctrl->TSC_OFFSET = info->time_state.guest_tsc - info->time_state.cached_host_tsc;
+ // guest_ctrl->TSC_OFFSET = info->time_state.guest_tsc - info->time_state.cached_host_tsc;
//V3_Print("Calling v3_svm_launch\n");
v3_last_exit = (uint32_t)(guest_ctrl->exit_code);
- rdtscll(tmp_tsc);
+ //rdtscll(tmp_tsc);
+ // v3_update_time(info, tmp_tsc - info->time_state.cached_host_tsc);
//PrintDebug("SVM Returned\n");
info->num_exits++;
- v3_update_time(info, tmp_tsc - info->time_state.cached_host_tsc);
+
// Save Guest state from VMCB
#include <palacios/vm_guest_mem.h>
#include <palacios/vmm_lowlevel.h>
#include <palacios/vmm_sprintf.h>
-
+#include <palacios/vmm_muxer.h>
v3_cpu_mode_t v3_get_vm_cpu_mode(struct guest_info * info) {
int v3_init_vm(struct v3_vm_info * vm) {
v3_cpu_arch_t cpu_type = v3_get_cpu_type(v3_get_cpu_id());
+
+ if (v3_get_foreground_vm() == NULL) {
+ v3_set_foreground_vm(vm);
+ }
+
#ifdef CONFIG_TELEMETRY
v3_init_telemetry(vm);
#endif
#include <palacios/vmm.h>
#include <palacios/vmm_host_events.h>
#include <palacios/vm_guest.h>
+#include <palacios/vmm_muxer.h>
int v3_init_host_events(struct v3_vm_info * vm) {
struct v3_host_events * host_evts = &(vm->host_event_hooks);
int v3_deliver_keyboard_event(struct v3_vm_info * vm,
struct v3_keyboard_event * evt) {
- struct v3_host_events * host_evts = &(vm->host_event_hooks);
+ struct v3_host_events * host_evts = NULL;
struct v3_host_event_hook * hook = NULL;
+ if (vm == NULL) {
+ vm = v3_get_foreground_vm();
+ }
+
+ host_evts = &(vm->host_event_hooks);
+
if (vm->run_state != VM_RUNNING) {
return -1;
}
int v3_deliver_mouse_event(struct v3_vm_info * vm,
struct v3_mouse_event * evt) {
- struct v3_host_events * host_evts = &(vm->host_event_hooks);
+ struct v3_host_events * host_evts = NULL;
struct v3_host_event_hook * hook = NULL;
+ if (vm == NULL) {
+ vm = v3_get_foreground_vm();
+ }
+
+ host_evts = &(vm->host_event_hooks);
+
if (vm->run_state != VM_RUNNING) {
return -1;
}
int v3_deliver_timer_event(struct v3_vm_info * vm,
struct v3_timer_event * evt) {
- struct v3_host_events * host_evts = &(vm->host_event_hooks);
+ struct v3_host_events * host_evts = NULL;
struct v3_host_event_hook * hook = NULL;
+ if (vm == NULL) {
+ vm = v3_get_foreground_vm();
+ }
+
+ host_evts = &(vm->host_event_hooks);
+
if (vm->run_state != VM_RUNNING) {
return -1;
}
--- /dev/null
+/*
+ * This file is part of the Palacios Virtual Machine Monitor developed
+ * by the V3VEE Project with funding from the United States National
+ * Science Foundation and the Department of Energy.
+ *
+ * The V3VEE Project is a joint project between Northwestern University
+ * and the University of New Mexico. You can find out more at
+ * http://www.v3vee.org
+ *
+ * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
+ * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org>
+ * All rights reserved.
+ *
+ * Author: Jack Lange <jarusl@cs.northwestern.edu>
+ *
+ * This is free software. You are permitted to use,
+ * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
+ */
+
+#include <palacios/vmm.h>
+#include <palacios/vmm_muxer.h>
+#include <palacios/vmm_list.h>
+
+
+
+static struct v3_vm_info * foreground_vm = NULL;
+
+// list of notification callbacks
+static LIST_HEAD(cb_list);
+
+
+struct mux_callback {
+ struct list_head cb_node;
+
+ int (*focus_change)(struct v3_vm_info * old_vm, struct v3_vm_info * new_vm);
+};
+
+
+struct v3_vm_info * v3_get_foreground_vm() {
+ return foreground_vm;
+}
+
+
+void v3_set_foreground_vm(struct v3_vm_info * vm) {
+ struct mux_callback * tmp_cb;
+
+ list_for_each_entry(tmp_cb, &(cb_list), cb_node) {
+ tmp_cb->focus_change(foreground_vm, vm);
+ }
+
+ foreground_vm = vm;
+}
+
+
+int v3_add_mux_notification(int (*focus_change)(struct v3_vm_info * old_vm,
+ struct v3_vm_info * new_vm)) {
+
+ struct mux_callback * cb = (struct mux_callback *)V3_Malloc(sizeof(struct mux_callback));
+
+ cb->focus_change = focus_change;
+
+ list_add(&(cb->cb_node), &cb_list);
+
+ return 0;
+}
vmcs_write(VMCS_GUEST_CR3, guest_cr3);
}
+ // We do timer injection here to track real host time.
+ rdtscll(tmp_tsc);
+ v3_update_time(info, tmp_tsc - info->time_state.cached_host_tsc);
rdtscll(info->time_state.cached_host_tsc);
if (info->vm_info->run_state == VM_STOPPED) {
return -1;
}
- rdtscll(tmp_tsc);
+ // rdtscll(tmp_tsc);
+ // v3_update_time(info, tmp_tsc - info->time_state.cached_host_tsc);
info->num_exits++;
- v3_update_time(info, tmp_tsc - info->time_state.cached_host_tsc);
/* Update guest state */
v3_vmx_save_vmcs(info);
#endif
-#ifdef CONFIG_VNET
-#include <palacios/vmm_vnet.h>
-#endif
/* At this point the GPRs are already copied into the guest_info state */
int v3_handle_vmx_exit(struct guest_info * info, struct vmx_exit_info * exit_info) {
}
-#ifdef CONFIG_VNET
- v3_vnet_heartbeat(info);
-#endif
-
-
#ifdef CONFIG_TELEMETRY
if (info->vm_info->enable_telemetry) {
v3_telemetry_end_exit(info, exit_info->exit_reason);