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.


Cleanup of linkage issues for non-Linux hosts
[palacios.git] / linux_module / linux-exts.c
index 7b09021..19160bb 100644 (file)
@@ -53,7 +53,7 @@ int add_global_ctrl(unsigned int cmd,
     ctrl->cmd = cmd;
     ctrl->handler = handler;
 
-    if (__insert_global_ctrl(ctrl) != NULL) {
+    if (__insert_global_ctrl(ctrl) != NULL) { 
         printk("Could not insert guest ctrl %d\n", cmd);
         palacios_free(ctrl);
         return -1;
@@ -65,9 +65,9 @@ int add_global_ctrl(unsigned int cmd,
 }
 
 
-struct global_ctrl * get_global_ctrl(unsigned int cmd) {
+static struct rb_node * find_match(unsigned int cmd) {
     struct rb_node * n = global_ctrls.rb_node;
-    struct global_ctrl * ctrl = NULL;
+    struct global_ctrl *ctrl;
 
     while (n) {
         ctrl = rb_entry(n, struct global_ctrl, tree_node);
@@ -77,7 +77,7 @@ struct global_ctrl * get_global_ctrl(unsigned int cmd) {
         } else if (cmd > ctrl->cmd) {
             n = n->rb_right;
         } else {
-            return ctrl;
+            return n;
         }
     }
 
@@ -85,6 +85,38 @@ struct global_ctrl * get_global_ctrl(unsigned int cmd) {
 }
 
 
+struct global_ctrl * get_global_ctrl(unsigned int cmd) {
+    struct rb_node *n = find_match(cmd);
+
+    if (n) {
+       return rb_entry(n, struct global_ctrl, tree_node);
+    } else {
+       return NULL;
+    }
+}
+      
+
+int remove_global_ctrl(unsigned int cmd)
+{
+    struct rb_node *n = find_match(cmd);
+    struct global_ctrl *c;
+
+    if (!n) { 
+       return -1;
+    }
+
+    c = rb_entry(n, struct global_ctrl, tree_node);
+
+    rb_erase(n,&global_ctrls);
+    
+    if (c) { 
+       palacios_free(c);
+    }
+    
+    return 0;
+}
+
+