diff options
author | neel <neel@FreeBSD.org> | 2012-10-27 22:58:02 +0000 |
---|---|---|
committer | neel <neel@FreeBSD.org> | 2012-10-27 22:58:02 +0000 |
commit | 6a8b1eb58304d3599b0ddcb57d8340deac56f139 (patch) | |
tree | 627729b33a841c83aa9edcb4ada9679922c234e7 /usr.sbin | |
parent | 1e4c5ce626aeb0ef445b18d433bc3b6142f88be6 (diff) | |
download | FreeBSD-src-6a8b1eb58304d3599b0ddcb57d8340deac56f139.zip FreeBSD-src-6a8b1eb58304d3599b0ddcb57d8340deac56f139.tar.gz |
Present the bvm dbgport to the guest only when explicitly requested via
the "-g" command line option.
Suggested by: grehan
Obtained from: NetApp
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bhyve/dbgport.c | 67 |
1 files changed, 40 insertions, 27 deletions
diff --git a/usr.sbin/bhyve/dbgport.c b/usr.sbin/bhyve/dbgport.c index 55efdad..034531c 100644 --- a/usr.sbin/bhyve/dbgport.c +++ b/usr.sbin/bhyve/dbgport.c @@ -44,37 +44,12 @@ __FBSDID("$FreeBSD$"); #include "dbgport.h" #define BVM_DBG_PORT 0x224 +#define BVM_DBG_SIG ('B' << 8 | 'V') static int listen_fd, conn_fd; static struct sockaddr_in sin; -void -init_dbgport(int sport) -{ - conn_fd = -1; - - if ((listen_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - perror("socket"); - exit(1); - } - - sin.sin_len = sizeof(sin); - sin.sin_family = AF_INET; - sin.sin_addr.s_addr = htonl(INADDR_ANY); - sin.sin_port = htons(sport); - - if (bind(listen_fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { - perror("bind"); - exit(1); - } - - if (listen(listen_fd, 1) < 0) { - perror("listen"); - exit(1); - } -} - static int dbg_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes, uint32_t *eax, void *arg) @@ -82,6 +57,11 @@ dbg_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes, char ch; int nwritten, nread, printonce; + if (bytes == 2 && in) { + *eax = BVM_DBG_SIG; + return (0); + } + if (bytes != 4) return (-1); @@ -122,4 +102,37 @@ again: return (0); } -INOUT_PORT(dbg, BVM_DBG_PORT, IOPORT_F_INOUT, dbg_handler); +static struct inout_port dbgport = { + "bvmdbg", + BVM_DBG_PORT, + IOPORT_F_INOUT, + dbg_handler +}; + +void +init_dbgport(int sport) +{ + conn_fd = -1; + + if ((listen_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { + perror("socket"); + exit(1); + } + + sin.sin_len = sizeof(sin); + sin.sin_family = AF_INET; + sin.sin_addr.s_addr = htonl(INADDR_ANY); + sin.sin_port = htons(sport); + + if (bind(listen_fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { + perror("bind"); + exit(1); + } + + if (listen(listen_fd, 1) < 0) { + perror("listen"); + exit(1); + } + + register_inout(&dbgport); +} |