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 device checkpoint hooks
[palacios.git] / palacios / src / palacios / vmm_dev_mgr.c
index 5abb57b..e6fad69 100644 (file)
 #include <palacios/vmm.h>
 #include <palacios/vmm_decoder.h>
 
+#ifdef V3_CONFIG_CHECKPOINT
+#include <palacios/vmm_checkpoint.h>
+#endif
+
 
-#ifndef CONFIG_DEBUG_DEV_MGR
+#ifndef V3_CONFIG_DEBUG_DEV_MGR
 #undef PrintDebug
 #define PrintDebug(fmt, args...)
 #endif
@@ -50,7 +54,7 @@ int V3_init_devices() {
     struct v3_device_info * tmp_dev =  __start__v3_devices;
     int i = 0;
 
-#ifdef CONFIG_DEBUG_DEV_MGR
+#ifdef V3_CONFIG_DEBUG_DEV_MGR
     {
        int num_devices = (__stop__v3_devices - __start__v3_devices) / sizeof(struct v3_device_info);
        PrintDebug("%d Virtual devices registered with Palacios\n", num_devices);
@@ -126,6 +130,72 @@ int v3_free_vm_devices(struct v3_vm_info * vm) {
     return 0;
 }
 
+#ifdef V3_CONFIG_CHECKPOINT
+
+int v3_save_vm_devices(struct v3_vm_info * vm, struct v3_chkpt * chkpt) {
+    struct vmm_dev_mgr * mgr = &(vm->dev_mgr);
+    struct vm_device * dev;
+    struct v3_chkpt_ctx * dev_mgr_ctx = NULL;
+
+    uint32_t num_saved_devs = 0;
+    uint32_t table_len = mgr->num_devs * 32;
+    char * name_table = NULL;
+    uint32_t tbl_offset = 0;
+    
+    name_table = V3_Malloc(table_len);
+
+    memset(name_table, 0, table_len);
+    
+
+    dev_mgr_ctx = v3_chkpt_open_ctx(chkpt, NULL, "devices");
+
+    list_for_each_entry(dev, &(mgr->dev_list), dev_link) {
+
+       if (dev->ops->save) {
+           struct v3_chkpt_ctx * dev_ctx = NULL;
+
+           
+           dev_ctx = v3_chkpt_open_ctx(chkpt, dev_mgr_ctx, dev->name);
+
+           dev->ops->save(dev_ctx, dev->private_data);
+
+           v3_chkpt_close_ctx(dev_ctx);
+
+           // Error checking?? 
+
+           strncpy(name_table + tbl_offset, dev->name, 32);
+           tbl_offset += 32;
+           num_saved_devs++;
+       } else {
+           PrintError("Error: %s save() not implemented\n",  dev->name);
+       }
+    }
+
+    
+    // Specify which devices were saved
+    v3_chkpt_save(dev_mgr_ctx, "num_devs", 4, &num_saved_devs); 
+    v3_chkpt_save(dev_mgr_ctx, "names", table_len, name_table);
+    V3_Free(name_table);
+
+    v3_chkpt_close_ctx(dev_mgr_ctx);
+    
+    return 0;
+}
+
+
+int v3_load_vm_devices(struct v3_vm_info * vm, struct v3_chkpt * chkpt) {
+
+    PrintError("TODO... \n");
+
+    // Read devices from checkpoint data
+    // selectively load them
+
+    return 0;
+}
+
+
+#endif
+
 static int free_frontends(struct v3_vm_info * vm, struct vmm_dev_mgr * mgr);
 
 int v3_deinit_dev_mgr(struct v3_vm_info * vm) {