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.


moved VM runstate settings to avoid race condition
[palacios.git] / palacios / src / palacios / vmm.c
index 8b4eed5..5420759 100644 (file)
@@ -255,7 +255,11 @@ int v3_start_vm(struct v3_vm_info * vm, unsigned int cpu_mask) {
        int minor = i % 8;
        
        if (core_mask[major] & (0x1 << minor)) {
-           avail_cores++;
+           if (v3_cpu_types[i] == V3_INVALID_CPU) {
+               core_mask[major] &= ~(0x1 << minor);
+           } else {
+               avail_cores++;
+           }
        }
     }
 
@@ -266,6 +270,8 @@ int v3_start_vm(struct v3_vm_info * vm, unsigned int cpu_mask) {
        return -1;
     }
 
+    vm->run_state = VM_RUNNING;
+
     // Spawn off threads for each core. 
     // We work backwards, so that core 0 is always started last.
     for (i = 0, vcore_id = vm->num_cores - 1; (i < MAX_CORES) && (vcore_id >= 0); i++) {
@@ -323,6 +329,12 @@ int v3_start_vm(struct v3_vm_info * vm, unsigned int cpu_mask) {
        vcore_id--;
     }
 
+    if (vcore_id >= 0) {
+       PrintError("Error starting VM: Not enough available CPU cores\n");
+       v3_stop_vm(vm);
+       return -1;
+    }
+
 
     return 0;