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.


added inspection framework
[palacios.git] / palacios / src / palacios / vmm_inspector.c
1 /* 
2  * This file is part of the Palacios Virtual Machine Monitor developed
3  * by the V3VEE Project with funding from the United States National 
4  * Science Foundation and the Department of Energy.  
5  *
6  * The V3VEE Project is a joint project between Northwestern University
7  * and the University of New Mexico.  You can find out more at 
8  * http://www.v3vee.org
9  *
10  * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> 
11  * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org> 
12  * All rights reserved.
13  *
14  * Author: Jack Lange <jarusl@cs.northwestern.edu>
15  *
16  * This is free software.  You are permitted to use,
17  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
18  */
19
20
21 #include <palacios/vmm_inspector.h>
22 #include <palacios/vmm.h>
23 #include <palacios/vm_guest.h>
24 #include <palacios/vmm_sprintf.h>
25
26 // Note that v3_inspect_node_t is actuall a struct v3_mtree
27 // Its set as void for opaque portability
28
29
30 int v3_init_inspector(struct v3_vm_info * vm) {
31     struct v3_inspector_state * state = (struct v3_inspector_state *)&(vm->inspector);
32
33     strncpy(state->state_tree.name, "vm->name", 50);
34     state->state_tree.subtree = 1;
35
36     return 0;
37 }
38
39
40 int  v3_init_inspector_core(struct guest_info * core) {
41     struct v3_inspector_state * vm_state = &(core->vm_info->inspector);
42     char core_name[50];
43
44     snprintf(core_name, 50, "core.%d", core->cpu_id);
45
46     {
47         struct v3_mtree * core_node = v3_mtree_create_subtree(&(vm_state->state_tree), core_name);
48         struct v3_mtree * gpr_node = v3_mtree_create_subtree(core_node, "GPRS");
49
50         v3_inspect_64(gpr_node, "RAX", (uint64_t *)&(core->vm_regs.rax));    
51     }
52
53     return 0;
54 }
55
56
57 v3_inspect_node_t * v3_inspect_add_subtree(v3_inspect_node_t * root, char * name) {
58     return v3_mtree_create_subtree(root, name);
59 }
60
61 int v3_inspect_8(v3_inspect_node_t * node, char * name, uint8_t * val) {
62     v3_mtree_create_value(node, name, 1, val);
63     return 0;
64 }
65
66
67 int v3_inspect_16(v3_inspect_node_t * node, char * name, uint16_t * val) {
68     v3_mtree_create_value(node, name, 2, val);
69
70     return 0;
71 }
72
73 int v3_inspect_32(v3_inspect_node_t * node, char * name, uint32_t * val) {
74     v3_mtree_create_value(node, name, 4, val); 
75     return 0;
76 }
77
78 int v3_inspect_64(v3_inspect_node_t * node, char * name, uint64_t * val) {
79     v3_mtree_create_value(node, name, 8, val);
80     return 0;
81 }
82
83 int v3_inspect_addr(v3_inspect_node_t * node, char * name, addr_t * val) {
84     v3_mtree_create_value(node, name, sizeof(addr_t), val);
85     return 0;
86 }
87
88 int v3_inspect_buf(v3_inspect_node_t * node, char * name, 
89                    uint8_t * buf, uint64_t size) {
90     v3_mtree_create_value(node, name, size, buf);
91
92     return 0;
93 }
94
95
96
97
98
99 int v3_get_inspection_value(v3_inspect_node_t * node, char * name, 
100                            struct v3_inspection_value * value) {
101     struct v3_mtree * mt_node = v3_mtree_find_node(node, name);
102     
103     if (!mt_node) {
104         return -1;
105     }
106     
107     value->value = mt_node->value;
108     value->size = mt_node->size;
109     value->flags = mt_node->user_flags;
110     value->name = mt_node->name;
111
112
113     return 0;
114 }
115
116
117 v3_inspect_node_t * v3_get_inspection_root(struct v3_vm_info * vm) {
118     return &(vm->inspector.state_tree);
119 }
120
121 v3_inspect_node_t * v3_get_inspection_subtree(v3_inspect_node_t * root, char * name) {
122     return v3_mtree_find_subtree(root, name);
123 }
124
125