From nobody Fri Oct 23 15:11:16 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=quarantine dis=none) header.from=net-art.cz ARC-Seal: i=1; a=rsa-sha256; t=1792268535; cv=none; d=zohomail.com; s=zohoarc; b=OhPkQiuC9fRuHL2/KsvoTdWDqhLYK6ghULKy2ab3pv/xEQYn3rJ2pw8T1a+VFJ4oBtiWvC3au4gCQgn3uqdRLFKYwGj5aEiTMZVeCYHelunmAk3ptVGXB9LcG8vVxROBhXg1eKdfg/5fxyGG5X9ZX+XkQ0BeWXeIS429lPWiMiQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792268535; h=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=4nouQlyc+S6Tkqh6tsjVaAC+KhJ5UR7bGIHH+i2voPc=; b=IlaYpP2k1uv5NtGn9urOuY0tytHPtCrSobFbii6FfXWnRPBNgfmdt3FGo1YZmNoHPQdbke5f55rtK451DQbO5P2fwYgxgKg5c2sfYFzzpvlTrtFjtrM2BFY7fhuuN1WAJJOzqwj7CjOkw2wNSPOQO6YBVbLKBMeFVp0Fm8KYI6I= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792268535115123.63573166286301; Sat, 17 Oct 2026 13:22:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xIAuK-0003TA-FH; Sat, 17 Oct 2026 16:21:32 -0400 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 1xIAsE-000342-LV; Sat, 17 Oct 2026 16:19:22 -0400 Received: from reindeer.net-art.cz ([2001:1468:9000:1:1::15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xIAsC-0003BK-8r; Sat, 17 Oct 2026 16:19:22 -0400 Received: by reindeer.net-art.cz (Postfix, from userid 65534) id 323CA3F0B0; Sat, 17 Oct 2026 20:19:13 +0000 (UTC) Received: from owl.net-art.cz (owl.net-art.cz [IPv6:2a03:6920:0:10::101]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client CN "owl.net-art.cz", Issuer "YR2" (not verified)) by reindeer.net-art.cz (Postfix) with ESMTPS id BDB2D3F04F; Sat, 17 Oct 2026 20:19:12 +0000 (UTC) Received: from [185.71.233.107] (account samm@net-art.cz HELO localhost.localdomain) by owl.net-art.cz (CommuniGate Pro SMTP 6.1.20) with ESMTPSA id 3724075; Sat, 17 Oct 2026 22:19:12 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=net-art.cz; s=netart; t=1792268353; bh=4nouQlyc+S6Tkqh6tsjVaAC+KhJ5UR7bGIHH+i2voPc=; h=From:To:Cc:Subject:Date; b=JD45cU1BCj+5VOdqMIxL4VM4c3GZrTVzeimU3anLiEOm8+jAIp+Pp1wtPwA1i1HT/ 986yzHMcFlAEo3MkehVFq5yA+nCueEKHyC4kFtkHKzaRK15c2pHVUFe8xyUsu9Hxcl MFGOduQwO1bfaSEMP9t+wysLZKGcXKlDx7jW7r1y+iudqwOZc7c9bfVdLpFL9vFSTu 8Vem/ZYtl/nTblVBczqztkVx7naIUpm31GMHr86UTMTmo2NZ05eChVbR4OvQi2W+LS 32MqFaoCt3xfOBn1pdCkr9VH3oYNSFEMRYJQpyXi0DqqFpoO6flOxR58oAfIMiHT1Z Lv3o6yJl00UMg== From: Oleksij Samorukov To: qemu-devel@nongnu.org Cc: Michael Roth , Kostiantyn Kostiuk , Alex Samorukov , Alexander Ivanov , qemu-stable@nongnu.org Subject: [PATCH] qga: set FreeBSD virtio-serial channel to raw mode Date: Sat, 17 Oct 2026 22:19:05 +0200 Message-ID: <20261017201905.12211-1-samm@net-art.cz> X-Mailer: git-send-email 2.54.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:1468:9000:1:1::15; envelope-from=samm@net-art.cz; helo=reindeer.net-art.cz X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sat, 17 Oct 2026 16:21:26 -0400 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 @net-art.cz) X-ZM-MESSAGEID: 1792268541646158500 Content-Type: text/plain; charset="utf-8" On FreeBSD the virtio-console port is a tty, unlike Linux's /dev/virtio-ports which is a character device. It defaults to canonical mode with echo and software flow control enabled, so the QGA stream protocol does not work: the initial guest-sync handshake is held in the line discipline and the host eventually times out. The existing FreeBSD-specific code only clears ECHO. Configure the port the same way as the ISA serial path: disable canonical mode, echo and software flow control, and set VMIN/VTIME. Use TCSANOW instead of TCSAFLUSH so a handshake that arrives between open() and tcsetattr() is not discarded. Tested on FreeBSD 15.1 aarch64 under UTM/QEMU. Before the change utmctl ip-address timed out and the guest received zero bytes; after the change QGA commands and guest-set-time work. Cc: qemu-stable@nongnu.org Fixes: c6cd588bb3a29a831c862780631a7d2145ade5de ("qga: Add initial FreeBSD = support") Signed-off-by: Oleksij Samorukov Tested-by: Roman Bogorodskiy --- qga/channel-posix.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/qga/channel-posix.c b/qga/channel-posix.c index 9ccc8b7..c6dfb2d 100644 --- a/qga/channel-posix.c +++ b/qga/channel-posix.c @@ -156,9 +156,10 @@ static gboolean ga_channel_open(GAChannel *c, const gc= har *path, #endif #ifdef __FreeBSD__ /* - * In the default state channel sends echo of every command to a - * client. The client program doesn't expect this and raises an - * error. Suppress echo by resetting ECHO terminal flag. + * FreeBSD's virtio-console port is a tty (unlike Linux's + * /dev/virtio-ports, which is a character device) and defaults to + * canonical mode with echo and software flow control enabled. + * QGA uses a raw stream protocol, so put the port in raw mode. */ struct termios tio; if (tcgetattr(fd, &tio) < 0) { @@ -166,8 +167,19 @@ static gboolean ga_channel_open(GAChannel *c, const gc= har *path, close(fd); return false; } - tio.c_lflag &=3D ~ECHO; - if (tcsetattr(fd, TCSAFLUSH, &tio) < 0) { + tio.c_iflag &=3D ~(IGNBRK | BRKINT | IGNPAR | PARMRK | INPCK | IST= RIP | + INLCR | IGNCR | ICRNL | IXON | IXOFF | IXANY | + IMAXBEL); + tio.c_oflag =3D 0; + tio.c_lflag =3D 0; + tio.c_cflag |=3D CLOCAL | CREAD; + tio.c_cc[VMIN] =3D 1; + tio.c_cc[VTIME] =3D 0; + /* + * Use TCSANOW rather than TCSAFLUSH: the host may already have se= nt + * the initial handshake between open() and tcsetattr(). + */ + if (tcsetattr(fd, TCSANOW, &tio) < 0) { error_setg_errno(errp, errno, "error setting channel termios a= ttrs"); close(fd); return false; --=20 2.54.0 (Apple Git-157)