#include <palacios/vmm_hashtable.h>
-#ifdef CONFIG_SWAPBYPASS_TELEMETRY
+#ifdef V3_CONFIG_SWAPBYPASS_TELEMETRY
#include <palacios/vmm_telemetry.h>
#endif
struct v3_dev_blk_ops * ops;
void * private_data;
-#ifdef CONFIG_SWAPBYPASS_TELEMETRY
+#ifdef V3_CONFIG_SWAPBYPASS_TELEMETRY
uint32_t pages_in;
uint32_t pages_out;
#endif
swap->unswapped_pages += (length / 4096);
-#ifdef CONFIG_SWAPBYPASS_TELEMETRY
+#ifdef V3_CONFIG_SWAPBYPASS_TELEMETRY
swap->pages_in += length / 4096;
#endif
swap->swapped_pages += written_pages;
-#ifdef CONFIG_SWAPBYPASS_TELEMETRY
+#ifdef V3_CONFIG_SWAPBYPASS_TELEMETRY
swap->pages_out += length / 4096;
#endif
};
-#ifdef CONFIG_SWAPBYPASS_TELEMETRY
+#ifdef V3_CONFIG_SWAPBYPASS_TELEMETRY
static void telemetry_cb(struct v3_vm_info * vm, void * private_data, char * hdr) {
struct swap_state * swap = (struct swap_state *)private_data;
swap = (struct swap_state *)V3_Malloc(sizeof(struct swap_state));
+ if (!swap) {
+ PrintError("Cannot allocate in connect\n");
+ return -1;
+ }
+
swap->vm = vm;
swap->cache_size = cache_size;
swap->io_flag = 0;
INIT_LIST_HEAD(&(swap->entry_list));
INIT_LIST_HEAD(&(swap->free_list));
swap->entry_map = (struct cache_entry *)V3_Malloc(sizeof(struct cache_entry) * (cache_size / 4096));
+
+ if (!swap->entry_map) {
+ PrintError("Cannot allocate in connect\n");
+ return -1;
+ }
+
for (i = 0; i < (cache_size / 4096); i++) {
list_add(&(swap->entry_map[i].cache_node), &(swap->free_list));
swap->active = 0;
swap->cache_base_addr = (addr_t)V3_AllocPages(swap->cache_size / 4096);
+
+ if (!swap->cache_base_addr) {
+ PrintError("Cannot allocate cache space\n");
+ V3_Free(swap);
+ return -1;
+ }
+
+
swap->cache = (uint8_t *)V3_VAddr((void *)(addr_t)(swap->cache_base_addr));
memset(swap->cache, 0, swap->cache_size);
}
}
-#ifdef CONFIG_SWAPBYPASS_TELEMETRY
+#ifdef V3_CONFIG_SWAPBYPASS_TELEMETRY
if (vm->enable_telemetry == 1) {
v3_add_telemetry_cb(vm, telemetry_cb, swap);