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.


5c76193591d5c34fc7bdee8a045e8d3e62bffbe0
[palacios.git] / linux_module / palacios-debugfs.c
1 /* 
2  * DebugFS interface
3  * (c) Jack Lange, 2011
4  */
5
6 #include <linux/kernel.h>
7 #include <linux/fs.h>
8 #include <linux/debugfs.h>
9 #include <linux/uaccess.h>
10
11 #include <palacios/vmm_inspector.h>
12
13 #include "palacios.h"
14
15 struct dentry * v3_dir = NULL;
16
17
18 int palacios_init_debugfs( void ) {
19
20     v3_dir = debugfs_create_dir("v3vee", NULL);
21
22     if (IS_ERR(v3_dir)) {
23         printk("Error creating v3vee debugfs directory\n");
24         return -1;
25     }
26
27     return 0;
28 }
29
30
31 int palacios_deinit_debugfs( void ) {
32     debugfs_remove(v3_dir);
33     return 0;
34 }
35
36
37
38 static int dfs_register_tree(struct dentry * dir, v3_inspect_node_t * root) {
39     v3_inspect_node_t * tmp_node = v3_inspection_first_child(root);
40     struct v3_inspection_value tmp_value;
41
42     while (tmp_node) {
43         tmp_value = v3_inspection_value(tmp_node);
44
45         if (tmp_value.size == 0) {
46             struct dentry * new_dir = debugfs_create_dir(tmp_value.name, dir);
47             dfs_register_tree(new_dir, tmp_node);
48         } else if (tmp_value.size == 1) {
49             debugfs_create_u8(tmp_value.name, 0644, dir, (u8 *)tmp_value.value);
50         } else if (tmp_value.size == 2) {
51             debugfs_create_u16(tmp_value.name, 0644, dir, (u16 *)tmp_value.value);
52         } else if (tmp_value.size == 4) {
53             debugfs_create_u32(tmp_value.name, 0644, dir, (u32 *)tmp_value.value);
54         } else if (tmp_value.size == 8) {
55             debugfs_create_u64(tmp_value.name, 0644, dir, (u64 *)tmp_value.value);
56         } else {
57
58             // buffer
59         }
60
61         tmp_node = v3_inspection_node_next(tmp_node);
62
63     }
64
65     return 0;
66 }
67
68
69 int dfs_register_vm(struct v3_guest * guest) {
70     v3_inspect_node_t * root = v3_get_inspection_root(guest->v3_ctx);
71
72     if (root == NULL) {
73         printk("No inspection root found\n");
74         return -1;
75     }
76
77     dfs_register_tree(v3_dir, root);
78     return 0;
79 }