Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Mar 2014 17:00:32 +0400
From:      Roman Bogorodskiy <novel@FreeBSD.org>
To:        freebsd-virtualization@freebsd.org
Subject:   bhyve: allow specifiying tty by fd
Message-ID:  <20140305130030.GA40560@dev.san.ru>

next in thread | raw e-mail | index | archive | help

--gBBFr7Ir9EOA20Yy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi,

Currently bhyve(8) allows to specify either stdio or device path as a
TTY device. However, it could be useful to specify a TTY device by file
descriptor, e.g. when bhyve is being executed in an automated way by 
other application, so a result of openpty(3) could be passed to it.

Attached a poc patch for that. It allows to specify fd this way:

bhyve <snip>  -s 31,lpc -l com1,fd=19 vm0

Roman Bogorodskiy

--gBBFr7Ir9EOA20Yy
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="bhyve_tty_fd.diff"

Index: bhyve.8
===================================================================
--- bhyve.8	(revision 262780)
+++ bhyve.8	(working copy)
@@ -184,6 +184,8 @@
 the bhyve process.
 .It Pa /dev/xxx
 Use the host TTY device for serial port I/O.
+.It Li fd=N
+Use a specified file descriptor of the TTY device.
 .El
 .Pp
 Pass-through devices:
Index: uart_emul.c
===================================================================
--- uart_emul.c	(revision 262780)
+++ uart_emul.c	(working copy)
@@ -585,7 +585,11 @@
 
 	retval = -1;
 
-	fd = open(opts, O_RDWR);
+	if (!strncmp(opts, "fd=", 3)) {
+		fd = atoi(opts+3);
+	} else {
+		fd = open(opts, O_RDWR);
+	}
 	if (fd > 0 && isatty(fd)) {
 		sc->tty.fd = fd;
 		sc->tty.opened = true;

--gBBFr7Ir9EOA20Yy--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140305130030.GA40560>