From owner-svn-src-all@freebsd.org Thu Nov 24 22:16:19 2016 Return-Path: Delivered-To: svn-src-all@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 88143C54EAC; Thu, 24 Nov 2016 22:16:19 +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 50A151FAC; Thu, 24 Nov 2016 22:16:19 +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 uAOMGIqV065704; Thu, 24 Nov 2016 22:16:18 GMT (envelope-from jceel@FreeBSD.org) Received: (from jceel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uAOMGIi0065703; Thu, 24 Nov 2016 22:16:18 GMT (envelope-from jceel@FreeBSD.org) Message-Id: <201611242216.uAOMGIi0065703@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 22:16:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r309121 - 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-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Nov 2016 22:16:19 -0000 Author: jceel Date: Thu Nov 24 22:16:18 2016 New Revision: 309121 URL: https://svnweb.freebsd.org/changeset/base/309121 Log: virtio_console: handle short writes to an Unix domain socket gracefully. writev() can do a short write. Retrying it results in a very convoluted and complex code, so we iterate over iovec and do regular stream_write() instead. 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:53:42 2016 (r309120) +++ head/usr.sbin/bhyve/pci_virtio_console.c Thu Nov 24 22:16:18 2016 (r309121) @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); #include "pci_emul.h" #include "virtio.h" #include "mevent.h" +#include "sockstream.h" #define VTCON_RINGSZ 64 #define VTCON_MAXPORTS 16 @@ -425,16 +426,21 @@ pci_vtcon_sock_tx(struct pci_vtcon_port int niov) { struct pci_vtcon_sock *sock; - int ret; + int i, ret; sock = (struct pci_vtcon_sock *)arg; if (sock->vss_conn_fd == -1) return; - ret = writev(sock->vss_conn_fd, iov, niov); + for (i = 0; i < niov; i++) { + ret = stream_write(sock->vss_conn_fd, iov[i].iov_base, + iov[i].iov_len); + if (ret <= 0) + break; + } - if (ret < 0 && errno != EWOULDBLOCK) { + if (ret <= 0) { mevent_delete_close(sock->vss_conn_evp); sock->vss_conn_fd = -1; sock->vss_open = false;