From owner-svn-src-head@freebsd.org Thu Nov 24 22:24:06 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 7528DC5408D for ; Thu, 24 Nov 2016 22:24:06 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound1a.eu.mailhop.org (outbound1a.eu.mailhop.org [52.58.109.202]) (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 15C687EF for ; Thu, 24 Nov 2016 22:24:05 +0000 (UTC) (envelope-from ian@freebsd.org) X-MHO-User: b54d83f4-b294-11e6-b17f-19517aec265d X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 73.78.92.27 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [73.78.92.27]) by outbound1.eu.mailhop.org (Halon) with ESMTPSA id b54d83f4-b294-11e6-b17f-19517aec265d; Thu, 24 Nov 2016 22:24:06 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id uAOMNqqV007031; Thu, 24 Nov 2016 15:23:52 -0700 (MST) (envelope-from ian@freebsd.org) Message-ID: <1480026232.1889.63.camel@freebsd.org> Subject: Re: svn commit: r309121 - head/usr.sbin/bhyve From: Ian Lepore To: Jakub Wojciech Klama , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Date: Thu, 24 Nov 2016 15:23:52 -0700 In-Reply-To: <201611242216.uAOMGIi0065703@repo.freebsd.org> References: <201611242216.uAOMGIi0065703@repo.freebsd.org> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.1 FreeBSD GNOME Team Port Mime-Version: 1.0 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 22:24:06 -0000 On Thu, 2016-11-24 at 22:16 +0000, Jakub Wojciech Klama wrote: > 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. >    Doesn't pwritev(2) simplify iterating to handle short writes? -- Ian >   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; >