svn commit: r309120 - head/usr.sbin/bhyve

Jakub Wojciech Klama jceel at FreeBSD.org
Thu Nov 24 21:53:43 UTC 2016


Author: jceel
Date: Thu Nov 24 21:53:42 2016
New Revision: 309120
URL: https://svnweb.freebsd.org/changeset/base/309120

Log:
  Allow opening virtio-console ports from the host side before guest
  enumerates them.
  
  Approved by:	trasz
  Sponsored by:	iXsystems, Inc.

Modified:
  head/usr.sbin/bhyve/pci_virtio_console.c

Modified: head/usr.sbin/bhyve/pci_virtio_console.c
==============================================================================
--- head/usr.sbin/bhyve/pci_virtio_console.c	Thu Nov 24 21:32:04 2016	(r309119)
+++ head/usr.sbin/bhyve/pci_virtio_console.c	Thu Nov 24 21:53:42 2016	(r309120)
@@ -90,6 +90,7 @@ struct pci_vtcon_port {
 	bool                     vsp_enabled;
 	bool                     vsp_console;
 	bool                     vsp_rx_ready;
+	bool                     vsp_open;
 	int                      vsp_rxq;
 	int                      vsp_txq;
 	void *                   vsp_arg;
@@ -116,6 +117,7 @@ struct pci_vtcon_softc {
 	char *                   vsc_rootdir;
 	int                      vsc_kq;
 	int                      vsc_nports;
+	bool                     vsc_ready;
 	struct pci_vtcon_port    vsc_control_port;
  	struct pci_vtcon_port    vsc_ports[VTCON_MAXPORTS];
 	struct pci_vtcon_config *vsc_config;
@@ -359,6 +361,7 @@ pci_vtcon_sock_accept(int fd __unused, e
 	sock->vss_open = true;
 	sock->vss_conn_fd = s;
 	sock->vss_conn_evp = mevent_add(s, EVF_READ, pci_vtcon_sock_rx, sock);
+
 	pci_vtcon_open_port(sock->vss_port, true);
 }
 
@@ -454,11 +457,15 @@ pci_vtcon_control_tx(struct pci_vtcon_po
 
 	switch (ctrl->event) {
 	case VTCON_DEVICE_READY:
+		sc->vsc_ready = true;
 		/* set port ready events for registered ports */
 		for (i = 0; i < VTCON_MAXPORTS; i++) {
 			tmp = &sc->vsc_ports[i];
 			if (tmp->vsp_enabled)
 				pci_vtcon_announce_port(tmp);
+
+			if (tmp->vsp_open)
+				pci_vtcon_open_port(tmp, true);
 		}
 		break;
 
@@ -500,6 +507,11 @@ pci_vtcon_open_port(struct pci_vtcon_por
 {
 	struct pci_vtcon_control event;
 
+	if (!port->vsp_sc->vsc_ready) {
+		port->vsp_open = true;
+		return;
+	}
+
 	event.id = port->vsp_id;
 	event.event = VTCON_PORT_OPEN;
 	event.value = (int)open;


More information about the svn-src-head mailing list