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.


telemetry updates
[palacios.git] / palacios / src / devices / sym_swap.c
index 35b46cc..4b7270d 100644 (file)
@@ -24,6 +24,9 @@
 
 #define SWAP_CAPACITY (150 * 1024 * 1024)
 
+#ifdef CONFIG_SYMBIOTIC_SWAP_TELEMETRY
+#include <palacios/vmm_telemetry.h>
+#endif
 
 
 /* This is the first page that linux writes to the swap area */
@@ -60,6 +63,12 @@ struct swap_state {
 
     union swap_header * hdr;
 
+#ifdef CONFIG_SYMBIOTIC_SWAP_TELEMETRY
+    uint32_t pages_in;
+    uint32_t pages_out;
+#endif
+
+
     uint64_t capacity;
     uint8_t * swap_space;
     addr_t swap_base_addr;
@@ -158,7 +167,11 @@ static int swap_read(uint8_t * buf, int sector_count, uint64_t lba,  void * priv
     if ((swap->active == 1) && (offset != 0)) {
        int i = 0;
        // Notify the shadow paging layer
-       PrintDebug("Swapped in %d pages\n", length / 4096);
+
+#ifdef CONFIG_SYMBIOTIC_SWAP_TELEMETRY
+       swap->pages_in += length / 4096;
+#endif
+
        for (i = 0; i < length; i += 4096) {
            set_index_usage(swap, get_swap_index_from_offset(offset + i), 0);
            v3_swap_in_notify(dev->vm, get_swap_index_from_offset(offset + i), swap->hdr->info.type);
@@ -210,7 +223,10 @@ static int swap_write(uint8_t * buf, int sector_count, uint64_t lba, void * priv
 
     if ((swap->active == 1) && (offset != 0)) {
        int i = 0;
-       PrintDebug("Swapped out %d pages\n", length / 4096);
+
+#ifdef CONFIG_SYMBIOTIC_SWAP_TELEMETRY
+       swap->pages_out += length / 4096;
+#endif
 
        for (i = 0; i < length; i += 4096) {
            set_index_usage(swap, get_swap_index_from_offset(offset + i), 1);
@@ -242,6 +258,18 @@ static struct v3_device_ops dev_ops = {
 };
 
 
+#ifdef CONFIG_SYMBIOTIC_SWAP_TELEMETRY
+static void telemetry_cb(struct guest_info * info, void * private_data, char * hdr) {
+    struct vm_device * dev = (struct vm_device *)private_data;
+    struct swap_state * swap = (struct swap_state *)(dev->private_data);
+
+    V3_Print("%sSwap Device:\n", hdr);
+    V3_Print("%s\tPages Swapped in=%d\n", hdr, swap->pages_in);
+    V3_Print("%s\tPages Swapped out=%d\n", hdr, swap->pages_out);
+
+}
+#endif
+
 
 
 
@@ -290,6 +318,12 @@ static int swap_init(struct guest_info * vm, void * cfg_data) {
 
     v3_virtio_register_harddisk(virtio_blk, &hd_ops, dev);
 
+#ifdef CONFIG_SYMBIOTIC_SWAP_TELEMETRY
+    if (vm->enable_telemetry) {
+       v3_add_telemetry_cb(vm, telemetry_cb, dev);
+    }
+#endif
+
     return 0;
 }