From: Jack Lange Date: Thu, 27 Oct 2011 17:55:36 +0000 (-0400) Subject: added error checking to guest launch to handle core mapping bugs X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=f82ccce5ce7629dce6f1a6feee8b47fa13a6756d added error checking to guest launch to handle core mapping bugs --- diff --git a/linux_module/palacios-stubs.c b/linux_module/palacios-stubs.c index 21aa4fd..2499339 100644 --- a/linux_module/palacios-stubs.c +++ b/linux_module/palacios-stubs.c @@ -218,7 +218,11 @@ palacios_start_thread_on_cpu(int cpu_id, 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; diff --git a/linux_module/vm.c b/linux_module/vm.c index 9869334..a1af564 100644 --- a/linux_module/vm.c +++ b/linux_module/vm.c @@ -130,7 +130,7 @@ static long v3_vm_ioctl(struct file * filp, 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; } diff --git a/palacios/src/palacios/vmm.c b/palacios/src/palacios/vmm.c index 8b4eed5..afc8c1c 100644 --- a/palacios/src/palacios/vmm.c +++ b/palacios/src/palacios/vmm.c @@ -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++; + } } } @@ -323,6 +327,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;