From owner-svn-src-head@freebsd.org Thu Dec 5 05:35:29 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 86C751BBD98; Thu, 5 Dec 2019 05:35:29 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 47T4Dw5cPMz3Jw7; Thu, 5 Dec 2019 05:35:28 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (localhost [127.0.0.1]) by gndrsh.dnsmgr.net (8.13.3/8.13.3) with ESMTP id xB55ZQuL042494; Wed, 4 Dec 2019 21:35:26 -0800 (PST) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: (from freebsd@localhost) by gndrsh.dnsmgr.net (8.13.3/8.13.3/Submit) id xB55ZQxt042493; Wed, 4 Dec 2019 21:35:26 -0800 (PST) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201912050535.xB55ZQxt042493@gndrsh.dnsmgr.net> Subject: Re: svn commit: r355301 - head/usr.sbin/bhyve In-Reply-To: To: Vincenzo Maffione Date: Wed, 4 Dec 2019 21:35:26 -0800 (PST) CC: John Baldwin , Ian Lepore , Rodney Grimes , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: 47T4Dw5cPMz3Jw7 X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of freebsd@gndrsh.dnsmgr.net has no SPF policy when checking 69.59.192.140) smtp.mailfrom=freebsd@gndrsh.dnsmgr.net X-Spamd-Result: default: False [0.73 / 15.00]; ARC_NA(0.00)[]; HAS_REPLYTO(0.00)[rgrimes@freebsd.org]; NEURAL_HAM_MEDIUM(-0.34)[-0.342,0]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; DMARC_NA(0.00)[dnsmgr.net]; AUTH_NA(1.00)[]; REPLYTO_DOM_NEQ_FROM_DOM(0.00)[]; IP_SCORE(0.04)[ip: (0.14), ipnet: 69.59.192.0/19(0.07), asn: 13868(0.03), country: US(-0.05)]; NEURAL_SPAM_LONG(0.13)[0.133,0]; RCPT_COUNT_SEVEN(0.00)[7]; R_SPF_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:13868, ipnet:69.59.192.0/19, country:US]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 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, 05 Dec 2019 05:35:29 -0000 > I see, thanks for the pointers. > It looks like cfmakeraw() and tcsetattr() were what I was looking for. > A bhyve-specific printf wrapper looks the right solution to me. > I can try to sketch a patch for you guys to review, if that's useful. > > Cheers, > Vincenzo Meanwhile could you please revert the commit, and add a note to D22552 to the effects that this was not the right solution? Thanks, Rod > Il giorno mar 3 dic 2019 alle ore 18:38 John Baldwin ha > scritto: > > > On 12/3/19 7:14 AM, Ian Lepore wrote: > > > On Mon, 2019-12-02 at 23:22 -0800, Rodney W. Grimes wrote: > > >>> On Mon, 2019-12-02 at 20:51 +0000, Vincenzo Maffione wrote: > > >>>> Author: vmaffione > > >>>> Date: Mon Dec 2 20:51:46 2019 > > >>>> New Revision: 355301 > > >>>> URL: https://svnweb.freebsd.org/changeset/base/355301 > > >>>> > > >>>> Log: > > >>>> bhyve: uniform printf format string newlines > > >>>> > > >>>> Some of the printf statements only use LF to get a newline. > > >>>> However, a CR character is also required for the serial console to > > >>>> print debug logs in a nice way. > > >>>> Fix those code locations that only use LF, by adding a CR > > >>>> character. > > >>>> > > >>>> Reviewed by: markj, aleksandr.fedorov@itglobal.com > > >>>> MFC after: 1 week > > >>>> Differential Revision: https://reviews.freebsd.org/D22552 > > >>>> > > >>>> Modified: > > >>>> head/usr.sbin/bhyve/audio.c > > >>>> head/usr.sbin/bhyve/hda_codec.c > > >>>> head/usr.sbin/bhyve/net_backends.c > > >>>> head/usr.sbin/bhyve/pci_ahci.c > > >>>> head/usr.sbin/bhyve/pci_e82545.c > > >>>> head/usr.sbin/bhyve/pci_hda.c > > >>>> head/usr.sbin/bhyve/pci_nvme.c > > >>>> head/usr.sbin/bhyve/pci_virtio_block.c > > >>>> head/usr.sbin/bhyve/pci_virtio_console.c > > >>>> head/usr.sbin/bhyve/pci_virtio_net.c > > >>>> head/usr.sbin/bhyve/pci_virtio_rnd.c > > >>>> head/usr.sbin/bhyve/pci_virtio_scsi.c > > >>>> head/usr.sbin/bhyve/pci_xhci.c > > >>>> head/usr.sbin/bhyve/rfb.c > > >>>> > > >>> > > >>> These changes seem wrong in a couple ways... > > >>> > > >>> - Lines are terminated by linefeeds in unix-like systems. If > > >>> linefeeds need to be translated to include carriage returns, that's the > > >>> responsibility of the terminal/line-discipline layer, not the source > > >>> strings being printed. > > >> > > >> Fully agree, this change seems wrong to me for Ian's stated reason here. > > >> > > >>> > > >>> - The sequence \n\r is very strange. For systems that do prefer > > >>> carriage returns, the \r always comes before the \n (or stands alone on > > >>> Mac systems), not after. > > >>> > > >>> I have a feeling that the root of this is something like "lots of > > >>> people use bhyve for Windows, so they use Windows apps to look at logs, > > >>> so the logs should be formatted for Windows." If that's the reasoning, > > >>> then why shouldn't we convert EVERY printf in the source base to > > >>> include carriage returns, just in case a windows user wants to browse a > > >>> log file? > > >> > > >> This is not that issue, it is something going on with the line > > >> discipline when using the bhyve console device. I believe the > > >> line displine being different from what bhyve itself is expecting > > >> so when console output is intermixed with output from bhyve itself > > >> things go wrong. > > >> > > >> The printf's in this patch are coming from the bhyve process that > > >> has a fd open to the launching tty, the line discipline on that tty > > >> is changed to something different after you open the > > >> console device from that same controlling tty, or that is my hypothosis > > >> on what is going wrong. > > > > > > There is a cfmakeraw() call in usr.sbin/bhyve/consport.c; that would > > > definitely turn off nl->crnl translations. I think that is the other > > > end of the bhyve console that I posted a patch for yesterday, and I > > > think the console driver is probably still the right place to do that > > > translation (because other console drivers do it that way). But I'm > > > not set up to run bhyve here, so I can't test my theory. > > > > That patch won't work alone. Most people don't use bvmcons, most people > > running bhyve use a standard uart as the console (bvmcons was an early > > console devices before bhyve had a ns8250 uart device model). When using > > the uart as the device model you still have raw output in the bhyve > > process itself. (See cfmakeraw() in uart_emul.c as well). We don't > > get to change how guest OS's use a uart, so any changes have to be in > > usr.sbin/bhyve, not in sys/. > > > > However, to do that you have to actually do something more complicated to > > turn \r\n and \n\r sequences from the guest into plain \n to stdout while > > still DTRT for "bare" \r and \n characters. You also have to make sure > > you do the right thing for input and not just output in the device models. > > > > I'm not quite a fan of this commit as-is since you will get spurious new > > lines now if you don't use a serial console. I would perhaps rather have > > a custom printf() wrapper in bhyve that outputs the \r as needed for > > debug and error printfs only when stdio has been changed to be raw. I > > was busy with family stuff and thanksgiving last week so didn't have time > > to review it before it was committed unfortunately. > > > > -- > > John Baldwin > > -- Rod Grimes rgrimes@freebsd.org