#include <palacios/vm_guest.h>
-#ifdef CONFIG_SWAPBYPASS_TELEMETRY
+#ifdef V3_CONFIG_SWAPBYPASS_TELEMETRY
#include <palacios/vmm_telemetry.h>
#endif
union swap_header * hdr;
-#ifdef CONFIG_SWAPBYPASS_TELEMETRY
+#ifdef V3_CONFIG_SWAPBYPASS_TELEMETRY
uint32_t pages_in;
uint32_t pages_out;
#endif
int i = 0;
// Notify the shadow paging layer
-#ifdef CONFIG_SWAPBYPASS_TELEMETRY
+#ifdef V3_CONFIG_SWAPBYPASS_TELEMETRY
swap->pages_in += length / 4096;
#endif
if ((swap->active == 1) && (offset != 0)) {
int i = 0;
-#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 vm_device * dev = (struct vm_device *)private_data;
struct swap_state * swap = (struct swap_state *)(dev->private_data);
swap = (struct swap_state *)V3_Malloc(sizeof(struct swap_state) + ((capacity / 4096) / 8));
+ if (!swap) {
+ PrintError("Cannot allocate in init\n");
+ return -1;
+ }
+
swap->vm = vm;
swap->capacity = capacity;
swap->hdr = (union swap_header *)swap;
swap->swap_base_addr = (addr_t)V3_AllocPages(swap->capacity / 4096);
+
+ if (!swap->swap_base_addr) {
+ PrintError("Cannot allocate swap space\n");
+ V3_Free(swap);
+ return -1;
+ }
+
swap->swap_space = (uint8_t *)V3_VAddr((void *)(swap->swap_base_addr));
memset(swap->swap_space, 0, swap->capacity);
return -1;
}
-#ifdef CONFIG_SWAPBYPASS_TELEMETRY
+#ifdef V3_CONFIG_SWAPBYPASS_TELEMETRY
if (vm->enable_telemetry == 1) {
v3_add_telemetry_cb(vm, telemetry_cb, dev);
}