From nobody Sun Nov 2 00:53:15 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508495204016221.2518628353223; Fri, 20 Oct 2017 03:26:44 -0700 (PDT) Received: from localhost ([::1]:52966 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5UVi-0004bK-7T for importer@patchew.org; Fri, 20 Oct 2017 06:26:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5UUe-00048E-MZ for qemu-devel@nongnu.org; Fri, 20 Oct 2017 06:25:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5UUZ-0006qi-Cu for qemu-devel@nongnu.org; Fri, 20 Oct 2017 06:25:32 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:57820 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e5UUZ-0006q7-32 for qemu-devel@nongnu.org; Fri, 20 Oct 2017 06:25:27 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v9KANdJO040243 for ; Fri, 20 Oct 2017 06:25:22 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0b-001b2d01.pphosted.com with ESMTP id 2dqdha5e70-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 20 Oct 2017 06:25:22 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 20 Oct 2017 11:25:21 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 20 Oct 2017 11:25:18 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v9KAPIWm13500440; Fri, 20 Oct 2017 10:25:18 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 37EC952045; Fri, 20 Oct 2017 10:19:35 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 26C6252043; Fri, 20 Oct 2017 10:19:35 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id A127020F62C; Fri, 20 Oct 2017 12:25:17 +0200 (CEST) From: Christian Borntraeger To: Cornelia Huck Date: Fri, 20 Oct 2017 12:25:17 +0200 X-Mailer: git-send-email 2.9.4 X-TM-AS-GCONF: 00 x-cbid: 17102010-0012-0000-0000-00000583BE0E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17102010-0013-0000-0000-000018FE2178 Message-Id: <20171020102517.28385-1-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-10-20_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710200152 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH] s390-ccw: print carriage return with new lines X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , Bjoern Walk , David Hildenbrand , Pierre Morel , qemu-devel , Alexander Graf , Christian Borntraeger , Halil Pasic , "Jason J . Herne" , "Collin L. Walling" , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Collin L. Walling" The sclp console in the s390 bios writes raw data, leading console emulators (such as virsh console) to treat a new line ('\n') as just a new line instead of as a Unix line feed. Because of this, output appears in a "stair case" pattern. Let's print \r\n on every occurrence of a new line in the string passed to write to amend this issue. This is in sync with the guest Linux code in drivers/s390/char/sclp_vt220.c which also does a line feed conversion in the console part of the driver.=20 This fixes the s390-ccw and s390-netboot output like $ virsh start test --console Domain test started Connected to domain test Escape character is ^] Network boot starting... Using MAC address: 02:01:02:03:04:05 Requesting = information via DHCP: 010 Signed-off-by: Collin L. Walling Signed-off-by: Christian Borntraeger --- pc-bios/s390-ccw/s390-ccw.h | 3 +++ pc-bios/s390-ccw/sclp.c | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h index 25d4d21..a8bd204 100644 --- a/pc-bios/s390-ccw/s390-ccw.h +++ b/pc-bios/s390-ccw/s390-ccw.h @@ -33,6 +33,9 @@ typedef unsigned long long __u64; #ifndef EBUSY #define EBUSY 2 #endif +#ifndef EFBIG +#define EFBIG 3 +#endif #ifndef NULL #define NULL 0 #endif diff --git a/pc-bios/s390-ccw/sclp.c b/pc-bios/s390-ccw/sclp.c index b1fc8ff..4795259 100644 --- a/pc-bios/s390-ccw/sclp.c +++ b/pc-bios/s390-ccw/sclp.c @@ -76,17 +76,28 @@ static int _strlen(const char *str) long write(int fd, const void *str, size_t len) { WriteEventData *sccb =3D (void *)_sccb; + const char *p; + size_t data_len =3D 0; =20 if (fd !=3D 1 && fd !=3D 2) { return -EIO; } =20 - sccb->h.length =3D sizeof(WriteEventData) + len; + for (p =3D str; *p; ++p) { + if (data_len > SCCB_DATA_LEN - 1) { + return -EFBIG; + } + if (*p =3D=3D '\n') { + sccb->data[data_len++] =3D '\r'; + } + sccb->data[data_len++] =3D *p; + } + + sccb->h.length =3D sizeof(WriteEventData) + data_len; sccb->h.function_code =3D SCLP_FC_NORMAL_WRITE; - sccb->ebh.length =3D sizeof(EventBufferHeader) + len; + sccb->ebh.length =3D sizeof(EventBufferHeader) + data_len; sccb->ebh.type =3D SCLP_EVENT_ASCII_CONSOLE_DATA; sccb->ebh.flags =3D 0; - memcpy(sccb->data, str, len); =20 sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb); =20 --=20 2.9.4