From nobody Sun Dec 6 20:46:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1796248711; cv=none; d=zohomail.com; s=zohoarc; b=MPFer0AhnKwx7zcryg1W7QBFw9SSfHsb0lMZRWk06Zm+y+JM27osw9ppjyZkZly0MSve5F0a0g7Vhm6X02T8wIMNvc9vjMFSvOXZQTb4Xj533rSEcgPu/iB3EuwQUBrkAtnOAMkqaLBsRYtMNMv2rdnOapRUT8QMLqRUcjj0Nfs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1796248711; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Oh38ghsE4QPwQdEXEqkZGGAZ+f3H31WqUbnrlbbIeRA=; b=nqYlc0aqhlYky/UwAiOrFyUfcW/tsXBLvVm7t1DJJMuT6McW8KgKuYhIx9LSVnIwahA3Imlao3QN4F3XIFBrmWr9Idkgcn/gUqksq+XGOu2NCdOEigkNDRnJ/lGEJYb1ubg/PZfzRLNJCwuc5ny3es9HMZsfB/hEFH/b7qmHCS8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1796248711200628.829084128387; Wed, 2 Dec 2026 13:58:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xYsLA-0007RE-JM; Wed, 02 Dec 2026 16:58:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xYsL5-0007Qg-I7 for qemu-devel@nongnu.org; Wed, 02 Dec 2026 16:58:11 -0500 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xYsL4-000057-21 for qemu-devel@nongnu.org; Wed, 02 Dec 2026 16:58:11 -0500 Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B2LH8Ee1959430 for ; Wed, 2 Dec 2026 21:58:08 GMT Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4jamhysyar-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 02 Dec 2026 21:58:07 +0000 (GMT) Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-949b0d3232fso1853090385a.1 for ; Wed, 02 Dec 2026 13:58:07 -0800 (PST) Received: from localhost.localdomain (pmd666.hd.free.fr. [82.67.153.177]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbe007079fsm19197275e9.15.2026.12.02.13.58.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 02 Dec 2026 13:58:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=qcppdkim1; bh=Oh38ghsE4QPwQdEXEqkZGG AZ+f3H31WqUbnrlbbIeRA=; b=e94jtw+01PiEAiZtb0j35Aye09LYEorr92O3C+ 74CDfygWudOIUQ9Zz7twaOCU+iHuz6wWmv2JJflmF43mc1A+wt9xKCff+88s5B2O NsKZVMjt1PUChkh4Exx//wdfrgmp/nk7GYUxTrkgjy2sxIuT0Bw6IwhD6ZCFvEyV XlEOsnWl1So78nJxW2121qrxtKPkn1DFAx07dof8dHkS6RZ5nhoogTbt1vgWS95h kooP+90/skWESSstgYhBVs+AQzR+djiJWCp3fQ45GYUZx5odcilhXJS3sPY47Puy PzKotdJo2pmqcAdcGJ3swUOiCy/1LTjyEXZHy/1oL4rBTrLw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1796248687; x=1796853487; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Oh38ghsE4QPwQdEXEqkZGGAZ+f3H31WqUbnrlbbIeRA=; b=EJSNk6f1cNZ/noNwIcbQXsFKWqHWulIz5RT3r/hNrQyfby+xR8WvmZDSg6HZC48vWj aPkqLaWh2pNs3rVBFcu43AYly4BtrO9b8nDa6ucpMk7U75XVvSQNmW4YNv3sfjgJ9zza uZoqw7Rt81CPchSNssvP66H+JgqIlWfI7sFx/JYqWwLOmGd0kw+XTqXgPrxsBGBbWyNL D5UKIh7v2ch984zea97QduSe0h11HMsm0l46tDQXvgBBACLPIoN8PjCE1Q3K15uw1yNg BhZkhTYfOQ7V6/ZyUOcKUPCLb4CSKIBdJRKJM8ts9tNdJwqHbd2OmKFlcZeQ2Ho0tMQb XERQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796248687; x=1796853487; h=content-transfer-encoding:content-type:mime-version:message-id:date :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=Oh38ghsE4QPw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0:93e:fc4e:c490 with SMTP id af79cd13be357-949ba9c721emr7745056085a.15.1796248687307; Wed, 02 Dec 2026 13:58:07 -0800 (PST) X-Received: by 2002:a05:620a:2728:b0:93e:fc4e:c490 with SMTP id af79cd13be357-949ba9c721emr7745053585a.15.1796248686863; Wed, 02 Dec 2026 13:58:06 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH RISU v2] risu: Handle short reads when replaying a trace from stdin Date: Wed, 2 Dec 2026 22:58:04 +0100 Message-ID: <20261202215804.44569-1-philmd@oss.qualcomm.com> X-Mailer: git-send-email 2.55.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: ZV5XQF_ETuSkLIefjAoaxR7fepGIeBHL X-Proofpoint-ORIG-GUID: ZV5XQF_ETuSkLIefjAoaxR7fepGIeBHL X-Authority-Analysis: v=2.4 cv=EYBd0/mC c=1 sm=1 tr=0 ts=6b10946f cx=c_pps a=hnmNkyzTK/kJ09Xio7VxxA==:117 a=nz36NW0qrpeEijYxj/H2Ew==:17 a=IkcTkHD0fZMA:10 a=pUM-KoujPXoA:10 a=M51BFTxLslgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=gowsoOTTUOVcmtlkKump:22 a=EUspDBNiAAAA:8 a=bRRs37joBVk_dw52dZsA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=PEH46H7Ffwr30OY-TuGO:22 X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAyMDA4NyBTYWx0ZWRfXwt4+mWeMQbhc PrENNxfGN5ViwmB+tk4PfRbG1rQ2FlLqhQOD24OArMzNXfkVugmHk2SwpDcVbJeCo0Fyf6h1FiP dayCMMaFGjBem+h+M+uG9lr4OyqFANQ= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAyMDA4NyBTYWx0ZWRfXyob6z5CrNOqn 6xIQ+xCUbv0hlJ9sJacuePXhiy+NvXbmJaa3WpTptNF2OZouUuNif+yRzzJoJTNt8MflUq0FZxY aoS0NufKD8lZ1RzJYqHGbskJIXlY0VarKjzteEfxF2KlfPlVzdXdQ9282LAmOBuCHw1ieisrHcX WY8PFfcuNsuW2pTtMq+HJcb+zazVsPLlajrIr3pGhQW88Zl5LshvXG+hOBqF7+sAQ57pYF+XlSa M7SmnSB5uPN5gXJXfvwO9zrKGt1v3WNWxOJe7+pvH+HhrwJioi2X2l4FxTz2ZHlP0RAJwB4jSIt 8EiOAuaFjuVyvsv9x/y7cd02hHE91qgLLhFvWmkixUoWE//yMNyuxzzBPfHcjYywXqJQ/LrjCnQ MJx+uDBvGoMfU1eokAfbVLt3wzpEgoyp6/BwkRUvkcqCQTVKbJaaNp7pNwwBcurEpITmEuDI+1N 2S+61fzQ/9PvCiBzM4Q== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-02_06,2026-12-02_07,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 spamscore=0 adultscore=0 bulkscore=0 clxscore=1015 priorityscore=1501 suspectscore=0 malwarescore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612020087 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=philmd@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @qualcomm.com) X-ZM-MESSAGEID: 1796248713074158500 With "-t -" the trace is read from a pipe, where read() may return fewer bytes than requested, which was reported as an I/O error. Loop until the whole record is read, retrying on EINTR. Without zlib this is how a compressed trace has to be replayed: $ gunzip -c trace.gz | risu -t - image.bin Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- v2: Declare variable in function prologue. --- risu.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/risu.c b/risu.c index c28b4a5..db268f4 100644 --- a/risu.c +++ b/risu.c @@ -60,6 +60,7 @@ static sigjmp_buf jmpbuf; static RisuResult read_buffer(void *ptr, size_t bytes) { size_t res; + char *p; =20 if (!trace) { return recv_data_pkt(comm_fd, ptr, bytes); @@ -68,7 +69,19 @@ static RisuResult read_buffer(void *ptr, size_t bytes) #ifdef HAVE_ZLIB if (comm_fd =3D=3D STDIN_FILENO) { #endif - res =3D read(comm_fd, ptr, bytes); + p =3D ptr; + res =3D 0; + while (res < bytes) { + ssize_t r =3D read(comm_fd, p + res, bytes - res); + + if (r < 0 && errno =3D=3D EINTR) { + continue; + } + if (r <=3D 0) { + break; + } + res +=3D r; + } #ifdef HAVE_ZLIB } else { res =3D gzread(gz_trace_file, ptr, bytes); --=20 2.55.0