Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Nov 2016 22:16:18 +0000 (UTC)
From:      Jakub Wojciech Klama <jceel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r309121 - head/usr.sbin/bhyve
Message-ID:  <201611242216.uAOMGIi0065703@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;



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