Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Expose HVM state to host + Linux host /proc additions for it
[palacios.git] / palacios / src / palacios / vmm_telemetry.c
index d12a5a7..988090f 100644 (file)
 #include <palacios/vmm_types.h>
 #include <palacios/vmm_telemetry.h>
 #include <palacios/svm_handler.h>
+#include <palacios/vmx_handler.h>
 #include <palacios/vmm_rbtree.h>
 #include <palacios/vmm_sprintf.h>
 
 
+
 #ifdef V3_CONFIG_TELEMETRY_GRANULARITY
 #define DEFAULT_GRANULARITY V3_CONFIG_TELEMETRY_GRANULARITY
 #else 
@@ -160,6 +162,11 @@ static struct exit_event * get_exit(struct guest_info * info, uint_t exit_code)
 static inline struct exit_event * create_exit(uint_t exit_code) {
     struct exit_event * evt = V3_Malloc(sizeof(struct exit_event));
 
+    if (!evt) {
+       PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in createing exit in telemetry\n");
+       return NULL;
+    }
+
     evt->exit_code = exit_code;
     evt->cnt = 0;
     evt->handler_time = 0;
@@ -217,6 +224,11 @@ void v3_add_telemetry_cb(struct v3_vm_info * vm,
     struct v3_telemetry_state * telemetry = &(vm->telemetry);
     struct telemetry_cb * cb = (struct telemetry_cb *)V3_Malloc(sizeof(struct telemetry_cb));
 
+    if (!cb) {
+        PrintError(vm, VCORE_NONE, "Cannot allocate in adding a telemtry callback\n");
+       return ;
+    }
+
     cb->private_data = private_data;
     cb->telemetry_fn = telemetry_fn;
 
@@ -244,13 +256,13 @@ static void print_telemetry_start(struct v3_vm_info *vm, char *hdr_buf)
     struct v3_telemetry_state * telemetry = &(vm->telemetry);
     uint64_t invoke_tsc = 0;
     rdtscll(invoke_tsc);
-    V3_Print("%stelemetry window tsc cnt: %d\n", hdr_buf, (uint32_t)(invoke_tsc - telemetry->prev_tsc));
+    V3_Print(vm,  VCORE_NONE, "%stelemetry window tsc cnt: %u\n", hdr_buf, (uint32_t)(invoke_tsc - telemetry->prev_tsc));
     telemetry->prev_tsc = invoke_tsc;
 }
 
 static void print_telemetry_end(struct v3_vm_info *vm, char *hdr_buf)
 {
-    V3_Print("%s Telemetry done\n", hdr_buf);
+    V3_Print(vm, VCORE_NONE, "%s Telemetry done\n", hdr_buf);
 }
 
 static void print_core_telemetry(struct guest_info * core, char *hdr_buf)
@@ -258,23 +270,41 @@ static void print_core_telemetry(struct guest_info * core, char *hdr_buf)
     struct exit_event * evt = NULL;
     struct rb_node * node = v3_rb_first(&(core->core_telem.exit_root));
 
-    V3_Print("Exit information for Core %d\n", core->vcpu_id);
+    V3_Print(core->vm_info, core, "Exit information for Core %d\n", core->vcpu_id);
     
     if (!node) { 
-       V3_Print("No information yet for this core\n");
+       V3_Print(core->vm_info, core, "No information yet for this core\n");
        return;
     }
 
     do {
-        evt = rb_entry(node, struct exit_event, tree_node);
-        const char * code_str = vmexit_code_to_str(evt->exit_code);
-           
-        V3_Print("%s%s:%sCnt=%u,%sAvg. Time=%u\n", 
-                 hdr_buf, code_str,
-                 (strlen(code_str) > 13) ? "\t" : "\t\t",
-                 evt->cnt,
-                 (evt->cnt >= 100) ? "\t" : "\t\t",
-                 (uint32_t)(evt->handler_time / evt->cnt));
+       extern v3_cpu_arch_t v3_mach_type;
+       const char * code_str = NULL;
+       
+       evt = rb_entry(node, struct exit_event, tree_node);
+
+       switch (v3_mach_type) {
+           case V3_SVM_CPU:
+           case V3_SVM_REV3_CPU:
+               
+               code_str = v3_svm_exit_code_to_str(evt->exit_code);
+               break;
+           case V3_VMX_CPU:
+           case V3_VMX_EPT_CPU:
+           case V3_VMX_EPT_UG_CPU:
+               code_str = v3_vmx_exit_code_to_str(evt->exit_code);
+               break;
+
+           default:
+               continue;
+       }
+
+       V3_Print(core->vm_info, core, "%s%s:%sCnt=%u,%sAvg. Time=%u\n", 
+                hdr_buf, code_str,
+                (strlen(code_str) > 13) ? "\t" : "\t\t",
+                evt->cnt,
+                (evt->cnt >= 100) ? "\t" : "\t\t",
+                (uint32_t)(evt->handler_time / evt->cnt));
     } while ((node = v3_rb_next(node)));
     return;
 }