summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bhyve
diff options
context:
space:
mode:
authorgrehan <grehan@FreeBSD.org>2012-10-31 03:29:52 +0000
committergrehan <grehan@FreeBSD.org>2012-10-31 03:29:52 +0000
commit36e2485283941cef37e24de91d997041ad325573 (patch)
treee21a0d555f90f740b9673cd0f7876d2da0a44f2b /usr.sbin/bhyve
parent55bf9997b92988e5555ae278f82221fb9e0f2291 (diff)
downloadFreeBSD-src-36e2485283941cef37e24de91d997041ad325573.zip
FreeBSD-src-36e2485283941cef37e24de91d997041ad325573.tar.gz
Exit if the requested num vCPUs exceeds the maximum rather
than waiting until AP bringup detects an out-of-range vCPU. While here, fix all error output to use fprintf(stderr, ... Reviewed by: neel Reported by: @allanjude
Diffstat (limited to 'usr.sbin/bhyve')
-rw-r--r--usr.sbin/bhyve/fbsdrun.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/usr.sbin/bhyve/fbsdrun.c b/usr.sbin/bhyve/fbsdrun.c
index 9d604ce..418faa7 100644
--- a/usr.sbin/bhyve/fbsdrun.c
+++ b/usr.sbin/bhyve/fbsdrun.c
@@ -213,7 +213,8 @@ fbsdrun_addcpu(struct vmctx *ctx, int vcpu, uint64_t rip)
int error;
if (cpumask & (1 << vcpu)) {
- printf("addcpu: attempting to add existing cpu %d\n", vcpu);
+ fprintf(stderr, "addcpu: attempting to add existing cpu %d\n",
+ vcpu);
exit(1);
}
@@ -325,7 +326,8 @@ vmexit_inout(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu)
static int
vmexit_rdmsr(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu)
{
- printf("vm exit rdmsr 0x%x, cpu %d\n", vme->u.msr.code, *pvcpu);
+ fprintf(stderr, "vm exit rdmsr 0x%x, cpu %d\n", vme->u.msr.code,
+ *pvcpu);
return (VMEXIT_ABORT);
}
@@ -366,13 +368,14 @@ static int
vmexit_vmx(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
{
- printf("vm exit[%d]\n", *pvcpu);
- printf("\treason\t\tVMX\n");
- printf("\trip\t\t0x%016lx\n", vmexit->rip);
- printf("\tinst_length\t%d\n", vmexit->inst_length);
- printf("\terror\t\t%d\n", vmexit->u.vmx.error);
- printf("\texit_reason\t%u\n", vmexit->u.vmx.exit_reason);
- printf("\tqualification\t0x%016lx\n", vmexit->u.vmx.exit_qualification);
+ fprintf(stderr, "vm exit[%d]\n", *pvcpu);
+ fprintf(stderr, "\treason\t\tVMX\n");
+ fprintf(stderr, "\trip\t\t0x%016lx\n", vmexit->rip);
+ fprintf(stderr, "\tinst_length\t%d\n", vmexit->inst_length);
+ fprintf(stderr, "\terror\t\t%d\n", vmexit->u.vmx.error);
+ fprintf(stderr, "\texit_reason\t%u\n", vmexit->u.vmx.exit_reason);
+ fprintf(stderr, "\tqualification\t0x%016lx\n",
+ vmexit->u.vmx.exit_qualification);
return (VMEXIT_ABORT);
}
@@ -445,11 +448,12 @@ vmexit_paging(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
if (err) {
if (err == EINVAL) {
- printf("Failed to emulate instruction at 0x%lx\n",
- vmexit->rip);
+ fprintf(stderr,
+ "Failed to emulate instruction at 0x%lx\n",
+ vmexit->rip);
} else if (err == ESRCH) {
- printf("Unhandled memory access to 0x%lx\n",
- vmexit->u.paging.gpa);
+ fprintf(stderr, "Unhandled memory access to 0x%lx\n",
+ vmexit->u.paging.gpa);
}
return (VMEXIT_ABORT);
@@ -643,6 +647,12 @@ main(int argc, char *argv[])
if (guest_ncpus <= 1)
guest_vcpu_mux = 0;
+ if (guest_ncpus > VM_MAXCPU) {
+ fprintf(stderr, "%d vCPUs requested, max %d\n",
+ guest_ncpus, VM_MAXCPU);
+ exit(1);
+ }
+
/* vmexit on hlt if guest is muxed */
if (guest_vcpu_mux) {
guest_vmexit_on_hlt = 1;
@@ -660,7 +670,7 @@ main(int argc, char *argv[])
if (fbsdrun_vmexit_on_hlt()) {
err = vm_get_capability(ctx, BSP, VM_CAP_HALT_EXIT, &tmp);
if (err < 0) {
- printf("VM exit on HLT not supported\n");
+ fprintf(stderr, "VM exit on HLT not supported\n");
exit(1);
}
vm_set_capability(ctx, BSP, VM_CAP_HALT_EXIT, 1);
@@ -673,7 +683,8 @@ main(int argc, char *argv[])
*/
err = vm_get_capability(ctx, BSP, VM_CAP_PAUSE_EXIT, &tmp);
if (err < 0) {
- printf("SMP mux requested, no pause support\n");
+ fprintf(stderr,
+ "SMP mux requested, no pause support\n");
exit(1);
}
vm_set_capability(ctx, BSP, VM_CAP_PAUSE_EXIT, 1);
@@ -686,7 +697,7 @@ main(int argc, char *argv[])
err = vm_set_x2apic_state(ctx, BSP, X2APIC_ENABLED);
if (err) {
- printf("Unable to set x2apic state (%d)\n", err);
+ fprintf(stderr, "Unable to set x2apic state (%d)\n", err);
exit(1);
}
OpenPOWER on IntegriCloud