From patchwork Mon Feb 2 21:27:35 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "David S. Ahern" X-Patchwork-Id: 5106 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n12LRgiE018085 for ; Mon, 2 Feb 2009 21:27:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758117AbZBBV1j (ORCPT ); Mon, 2 Feb 2009 16:27:39 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758097AbZBBV1j (ORCPT ); Mon, 2 Feb 2009 16:27:39 -0500 Received: from sj-iport-6.cisco.com ([171.71.176.117]:45961 "EHLO sj-iport-6.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757505AbZBBV1i (ORCPT ); Mon, 2 Feb 2009 16:27:38 -0500 X-IronPort-AV: E=Sophos;i="4.37,367,1231113600"; d="scan'208";a="241481576" Received: from sj-dkim-3.cisco.com ([171.71.179.195]) by sj-iport-6.cisco.com with ESMTP; 02 Feb 2009 21:27:37 +0000 Received: from sj-core-1.cisco.com (sj-core-1.cisco.com [171.71.177.237]) by sj-dkim-3.cisco.com (8.12.11/8.12.11) with ESMTP id n12LRbJS008452; Mon, 2 Feb 2009 13:27:37 -0800 Received: from xbh-sjc-211.amer.cisco.com (xbh-sjc-211.cisco.com [171.70.151.144]) by sj-core-1.cisco.com (8.13.8/8.13.8) with ESMTP id n12LRb74018651; Mon, 2 Feb 2009 21:27:37 GMT Received: from xfe-sjc-211.amer.cisco.com ([171.70.151.174]) by xbh-sjc-211.amer.cisco.com with Microsoft SMTPSVC(6.0.3790.1830); Mon, 2 Feb 2009 13:27:37 -0800 Received: from [64.101.76.177] ([64.101.76.177]) by xfe-sjc-211.amer.cisco.com with Microsoft SMTPSVC(6.0.3790.1830); Mon, 2 Feb 2009 13:27:36 -0800 Message-ID: <49876547.1080904@cisco.com> Date: Mon, 02 Feb 2009 14:27:35 -0700 From: "David S. Ahern" User-Agent: Thunderbird 2.0.0.19 (X11/20090105) MIME-Version: 1.0 To: KVM list , qemu-devel@nongnu.org CC: Michael Tokarev Subject: Re: more about serial ports: do they even work? References: <497E1B15.2090908@msgid.tls.msk.ru> <497E1F7D.90300@msgid.tls.msk.ru> In-Reply-To: <497E1F7D.90300@msgid.tls.msk.ru> X-OriginalArrivalTime: 02 Feb 2009 21:27:37.0020 (UTC) FILETIME=[11A4F7C0:01C9857D] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; l=3094; t=1233610057; x=1234474057; c=relaxed/simple; s=sjdkim3002; h=Content-Type:From:Subject:Content-Transfer-Encoding:MIME-Version; d=cisco.com; i=daahern@cisco.com; z=From:=20=22David=20S.=20Ahern=22=20 |Subject:=20Re=3A=20more=20about=20serial=20ports=3A=20do=2 0they=20even=20work? |Sender:=20; bh=tli9ZO5HEx7SlYfm29Keujppk2O8ZcsTtxBb85w44AM=; b=D6sAeGDXJYYnYi8NjNZi9QaN4ocmFpJMrsbtnLZiCq1lsvXZtkPdIsbodB Y6jDF02ZA8uQdLSb0+AZj1C/VOw1/LLCAmG9HARfTtx2z233QZlUgJryfSeJ 8GDLAZ3TX2; Authentication-Results: sj-dkim-3; header.From=daahern@cisco.com; dkim=pass ( sig from cisco.com/sjdkim3002 verified; ); Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org I don't recall seeing a followup to this post. To put Michael's second suggestion into patch form, the following fixes the problem for me: Is this approach palatable to folks? david Michael Tokarev wrote: > Michael Tokarev ?????: >> After some debugging and debugging, with a help >> Hollis Blanchard on #kvm@freenode, I discovered >> that kvm (or, rather, qemu) does not work correctly >> with serial ports, at least on linux. One problem >> report has already here, author Cc'd -- see e.g. >> http://marc.info/?l=kvm&m=122995568009533&w=2 . >> >> Here's what's going on. >> >> When opening a host's port, kvm resets the status >> lines, doing this: >> >> ioctl(13, TIOCMGET, [TIOCM_DTR|TIOCM_RTS|TIOCM_CTS|TIOCM_DSR|0x4000]) >> ioctl(13, TIOCMSET, [TIOCM_DTR|TIOCM_RTS]) >> >> which results in the following set >> >> ioctl(13, TIOCMGET, [TIOCM_DTR|TIOCM_RTS|TIOCM_CTS|TIOCM_DSR]) > > Here's the possible solution (NotAPAtch(tm)): > > In kvm-xx/qemu/qemu-char.c: > > case CHR_IOCTL_SERIAL_SET_TIOCM: > { > int sarg = *(int *)arg; > int targ = 0; <==== change this 0 to 0x4000 > if (sarg | CHR_TIOCM_DTR) > targ |= TIOCM_DTR; > if (sarg | CHR_TIOCM_RTS) > targ |= TIOCM_RTS; > ioctl(s->fd_in, TIOCMSET, &targ); > } > break; > > This is obviously a hack, esp. since this bit is not > always present even on linux (after reading 8250.c > driver). > > Real fix will be, I guess, to read the full set > first, and combine it with DTR|RTS received from > guest, something like this: > > case > { > int sarg = *(int *)arg; > int targ = 0; > ioctl(s->fd_in, TIOCMGET, &targ); > if (!(sarg | CHR_TIOCM_DTR)) > targ &= ~TIOCM_DTR; > if (!(sarg | CHR_TIOCM_RTS)) > targ ~= ~TIOCM_RTS; > ioctl(s->fd_in, TIOCMSET, &targ); > } > break; > > I.e., to always keep all the other bits, but > allow changing DTR and RTS. > > Again, I don't know how it's linux-specific, but > it seems the solution above should work on other > platforms just fine. > > /mjt --- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- kvm-81.orig/qemu/qemu-char.c 2008-12-14 06:16:27.000000000 -0700 +++ kvm-81/qemu/qemu-char.c 2009-02-02 14:12:20.000000000 -0700 @@ -1078,20 +1078,21 @@ if (sarg | TIOCM_DTR) *targ |= CHR_TIOCM_DTR; if (sarg | TIOCM_RTS) *targ |= CHR_TIOCM_RTS; } break; case CHR_IOCTL_SERIAL_SET_TIOCM: { int sarg = *(int *)arg; int targ = 0; + ioctl(s->fd_in, TIOCMGET, &targ); if (sarg | CHR_TIOCM_DTR) targ |= TIOCM_DTR; if (sarg | CHR_TIOCM_RTS) targ |= TIOCM_RTS; ioctl(s->fd_in, TIOCMSET, &targ); } break; default: return -ENOTSUP; }