From owner-svn-src-head@freebsd.org Thu Nov 24 21:53:43 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 82BA7C54A9F; Thu, 24 Nov 2016 21:53:43 +0000 (UTC) (envelope-from jceel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 385B71719; Thu, 24 Nov 2016 21:53:43 +0000 (UTC) (envelope-from jceel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uAOLrgoI057268; Thu, 24 Nov 2016 21:53:42 GMT (envelope-from jceel@FreeBSD.org) Received: (from jceel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uAOLrgfI057267; Thu, 24 Nov 2016 21:53:42 GMT (envelope-from jceel@FreeBSD.org) Message-Id: <201611242153.uAOLrgfI057267@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jceel set sender to jceel@FreeBSD.org using -f From: Jakub Wojciech Klama Date: Thu, 24 Nov 2016 21:53:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r309120 - head/usr.sbin/bhyve X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Nov 2016 21:53:43 -0000 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;