svn commit: r242195 - projects/bhyve/usr.sbin/bhyve
Neel Natu
neel at FreeBSD.org
Sat Oct 27 22:58:03 UTC 2012
Author: neel
Date: Sat Oct 27 22:58:02 2012
New Revision: 242195
URL: http://svn.freebsd.org/changeset/base/242195
Log:
Present the bvm dbgport to the guest only when explicitly requested via
the "-g" command line option.
Suggested by: grehan
Obtained from: NetApp
Modified:
projects/bhyve/usr.sbin/bhyve/dbgport.c
Modified: projects/bhyve/usr.sbin/bhyve/dbgport.c
==============================================================================
--- projects/bhyve/usr.sbin/bhyve/dbgport.c Sat Oct 27 22:54:23 2012 (r242194)
+++ projects/bhyve/usr.sbin/bhyve/dbgport.c Sat Oct 27 22:58:02 2012 (r242195)
@@ -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,
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);
+}
More information about the svn-src-projects
mailing list