Date: Wed, 31 Oct 2012 03:29:52 +0000 (UTC) From: Peter Grehan <grehan@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r242385 - projects/bhyve/usr.sbin/bhyve Message-ID: <201210310329.q9V3Tq8m038351@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: grehan Date: Wed Oct 31 03:29:52 2012 New Revision: 242385 URL: http://svn.freebsd.org/changeset/base/242385 Log: 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 Modified: projects/bhyve/usr.sbin/bhyve/fbsdrun.c Modified: projects/bhyve/usr.sbin/bhyve/fbsdrun.c ============================================================================== --- projects/bhyve/usr.sbin/bhyve/fbsdrun.c Wed Oct 31 02:54:44 2012 (r242384) +++ projects/bhyve/usr.sbin/bhyve/fbsdrun.c Wed Oct 31 03:29:52 2012 (r242385) @@ -213,7 +213,8 @@ fbsdrun_addcpu(struct vmctx *ctx, int vc 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 v 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 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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210310329.q9V3Tq8m038351>