return NULL;
}
- set_cpus_allowed_ptr(thread, cpumask_of(cpu_id));
+ if (set_cpus_allowed_ptr(thread, cpumask_of(cpu_id)) != 0) {
+ kthread_stop(thread);
+ return NULL;
+ }
+
wake_up_process(thread);
return thread;
case V3_VM_LAUNCH: {
printk("palacios: launching vm\n");
- if (v3_start_vm(guest->v3_ctx, 0xfffffffe) < 0) {
+ if (v3_start_vm(guest->v3_ctx, (0x1 << num_online_cpus()) - 1) < 0) {
printk("palacios: launch of vm failed\n");
return -1;
}
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++;
+ }
}
}
vcore_id--;
}
+ if (vcore_id >= 0) {
+ PrintError("Error starting VM: Not enough available CPU cores\n");
+ v3_stop_vm(vm);
+ return -1;
+ }
+
return 0;