From e365fca6c8e62e74fb5bfd1aa5ef885538c80a18 Mon Sep 17 00:00:00 2001 From: Neel Natu Date: Sat, 27 Oct 2012 22:33:23 +0000 Subject: [PATCH] Present the bvm console device to the guest only when explicitly requested via the "-b" command line option. Reviewed by: grehan Obtained from: NetApp --- usr.sbin/bhyve/consport.c | 15 ++++++++++++++- usr.sbin/bhyve/fbsdrun.c | 11 +++++++++-- usr.sbin/bhyve/inout.h | 2 ++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/usr.sbin/bhyve/consport.c b/usr.sbin/bhyve/consport.c index 8e2156a061ab..3915b6d71a2b 100644 --- a/usr.sbin/bhyve/consport.c +++ b/usr.sbin/bhyve/consport.c @@ -124,4 +124,17 @@ console_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes, return (0); } -INOUT_PORT(console, BVM_CONSOLE_PORT, IOPORT_F_INOUT, console_handler); + +static struct inout_port consport = { + "bvmcons", + BVM_CONSOLE_PORT, + IOPORT_F_INOUT, + console_handler +}; + +void +init_bvmcons(void) +{ + + register_inout(&consport); +} diff --git a/usr.sbin/bhyve/fbsdrun.c b/usr.sbin/bhyve/fbsdrun.c index 9905f19c6b44..9d604ce2aa1f 100644 --- a/usr.sbin/bhyve/fbsdrun.c +++ b/usr.sbin/bhyve/fbsdrun.c @@ -563,21 +563,25 @@ vm_loop(struct vmctx *ctx, int vcpu, uint64_t rip) int main(int argc, char *argv[]) { - int c, error, gdb_port, inject_bkpt, tmp, err, ioapic; + int c, error, gdb_port, inject_bkpt, tmp, err, ioapic, bvmcons; struct vmctx *ctx; uint64_t rip; + bvmcons = 0; inject_bkpt = 0; progname = basename(argv[0]); gdb_port = DEFAULT_GDB_PORT; guest_ncpus = 1; ioapic = 0; - while ((c = getopt(argc, argv, "aehBHIPxp:g:c:z:s:S:n:m:M:")) != -1) { + while ((c = getopt(argc, argv, "abehBHIPxp:g:c:z:s:S:n:m:M:")) != -1) { switch (c) { case 'a': disable_x2apic = 1; break; + case 'b': + bvmcons = 1; + break; case 'B': inject_bkpt = 1; break; @@ -707,6 +711,9 @@ main(int argc, char *argv[]) if (gdb_port != 0) init_dbgport(gdb_port); + if (bvmcons) + init_bvmcons(); + error = vm_get_register(ctx, BSP, VM_REG_GUEST_RIP, &rip); assert(error == 0); diff --git a/usr.sbin/bhyve/inout.h b/usr.sbin/bhyve/inout.h index f6a8db2acf15..a73b78d80800 100644 --- a/usr.sbin/bhyve/inout.h +++ b/usr.sbin/bhyve/inout.h @@ -62,4 +62,6 @@ int emulate_inout(struct vmctx *, int vcpu, int in, int port, int bytes, uint32_t *eax, int strict); int register_inout(struct inout_port *iop); +void init_bvmcons(void); + #endif /* _INOUT_H_ */