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 and fixes based on Coverity pass
Peter Dinda [Fri, 3 Jun 2016 21:43:03 +0000 (16:43 -0500)]
nautilus/palacios-stubs.c
palacios/src/palacios/vmm_cpu_mapper.c
palacios/src/palacios/vmm_xml.c

index a1b8183..45d8e7b 100644 (file)
@@ -198,14 +198,17 @@ void *palacios_allocate_pages(int num_pages, unsigned int alignment, int node_id
  * a single call while palacios_free_page() only frees a single page.
  */
 
-void palacios_free_pages(void * page_paddr, int num_pages) {
+void palacios_free_pages(void * page_paddr, int num_pages) 
+{
+    //INFO("freepages: %p (%llu pages) alignment=%u\n", page_paddr, num_pages);
+
     if (!page_paddr) { 
        ERROR("Ignoring free pages: 0x%p (0x%lx)for %d pages\n", page_paddr, (uintptr_t)page_paddr, num_pages);
        return;
     }
+
     free(page_paddr);
 
-    INFO("freepages: %p (%llu pages) alignment=%u\n", page_paddr, num_pages);
 }
 
 
@@ -244,6 +247,7 @@ palacios_valloc(unsigned int size)
 {
     void * addr = NULL;
 
+
     if (size==0) { 
       ERROR("ALERT ALERT attempt to vmalloc zero bytes rejected\n");
       return NULL;
@@ -268,14 +272,15 @@ palacios_valloc(unsigned int size)
 
 void palacios_vfree(void *p)
 {
+  //INFO("vfree: 0x%p\n",p);
+
   if (!p) { 
       ERROR("Ignoring vfree: 0x%p\n",p);
       return;
   }
-  // no vfree currently
+
   free(p);
 
-  //INFO("vfree: 0x%p\n",p);
 }
 
 /**
@@ -294,14 +299,14 @@ palacios_alloc(unsigned int size)
 void
 palacios_free(void *addr)
 {
-    return;
+    //INFO("free: %p\n",addr-ALLOC_PAD);
+
     if (!addr) {
        ERROR("Ignoring free : 0x%p\n", addr);
        return;
     }
-    // no kfree
+
     free(addr-ALLOC_PAD);
-    //INFO("free: %p\n",addr-ALLOC_PAD);
 }
 
 /**
@@ -312,8 +317,11 @@ palacios_vaddr_to_paddr(
        void *                  vaddr
 )
 {
-    return vaddr; // our memory mapping is identity
-
+  // our memory mapping is identity
+  // this currently does not include Nautilus PA offsetting
+  // as in Multiverse, but we don't envision running a VM
+  // within an HRT either, so we should be fine
+  return vaddr; 
 }
 
 /**
@@ -324,7 +332,7 @@ palacios_paddr_to_vaddr(
        void *                  paddr
 )
 {
-    return paddr; // our memory mapping is identity
+    return paddr; // our memory mapping is identity, see v->p comment
 }
 
 /**
@@ -756,6 +764,9 @@ int palacios_vmm_init(char * options)
     
             *(cpu_mask + major) |= (0x1 << minor);
         }
+    } else {
+      ERROR("Must initialize at least one CPU\n");
+      return -1;
     }
 
 
@@ -788,6 +799,8 @@ int palacios_vmm_init(char * options)
     nautilus_console_init();
 #endif
 
+    palacios_free(cpu_mask);
+
 
     return 0;
 
@@ -817,6 +830,7 @@ void palacios_inform_new_vm_pre(char *name)
   for (i=0;i<NR_VMS;i++) { 
     if (!vms[i].name[0]) {
       strncpy(vms[i].name,name,MAX_VM_NAME);
+      vms[i].name[MAX_VM_NAME-1]=0;
       selected_vm = &vms[i];
       return;
     }
index 449e2e7..88256dd 100644 (file)
@@ -221,14 +221,14 @@ int default_mapper_admit(struct v3_vm_info *vm, unsigned int cpu_mask){
 
        }
 
-    core->pcpu_id = core_idx;
-    vcore_id--;
+       core->pcpu_id = core_idx;
+       vcore_id--;
     }
 
-    if (vcore_id >= 0) { // dead code...
-       v3_stop_vm(vm);
-       return -1;
-    }
+    //    if (vcore_id >= 0) { // dead code...
+    //v3_stop_vm(vm);
+    //return -1;
+    //}
 
     return 0;
 }
index f3cf7e3..a9c6659 100644 (file)
@@ -480,8 +480,12 @@ static struct v3_xml * parse_str(char * buf, size_t len) {
     char ** attr; 
     int attr_idx;
 
-    if (!buf) {
-       return NULL;
+    if (buf==NULL) {
+      return NULL;
+    }
+
+    if (root==NULL) {
+      return NULL;
     }
 
     root->str_ptr = buf;
@@ -692,7 +696,8 @@ static struct v3_xml * parse_str(char * buf, size_t len) {
            return NULL;
         }
 
-        if (! buf || ! *buf) {
+       // at this point, buf cannot be NULL
+        if (!*buf) {
            break;
        }