From nobody Tue Nov 26 11:53:26 2024 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1708936317; cv=none; d=zohomail.com; s=zohoarc; b=XFRe5SSConR51idrq23Urkkt5Rborpz/CYFikLlyPi5IN/MMvRN8KHIQ7se8CMq6Jd/riCIMUW2HpD3BY4KcZC3QvDvDNDQbCLfM3M7Q1JCovQ/0kSNrVRjh1bajldEyTaATqgKMGgaEiwKFn4xEECvuiQNABtoGrNbDn/vOMG8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708936317; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zYd02SLfgP/LCWG+Mrru0HvWw0TZYZU2hsjtTtlA/n0=; b=i8rBZYAN/92S9LIGR9ci4U0K9cKSzqKM3TGNTb6+a9iS/Gt9spYVlyi7JgYGn58LImNRz35yERPg6AhJbpLvwiQDIKJ1pzYcWwXfWLWsQqvWzEu7xZriJHhWBOTgFz4zu9kM7yvBGnrCklVzMIYY8o48/To4fqSpuUJ5rncZX2w= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708936317134928.6129860058184; Mon, 26 Feb 2024 00:31:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1reWON-0003Ex-5f; Mon, 26 Feb 2024 03:31:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1reWNj-0002iI-T3 for qemu-devel@nongnu.org; Mon, 26 Feb 2024 03:30:40 -0500 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1reWNg-0005ly-2Y for qemu-devel@nongnu.org; Mon, 26 Feb 2024 03:30:39 -0500 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1d944e8f367so18803545ad.0 for ; Mon, 26 Feb 2024 00:30:35 -0800 (PST) Received: from wheely.local0.net ([1.146.74.212]) by smtp.gmail.com with ESMTPSA id w16-20020a1709026f1000b001d9641003cfsm3511260plk.142.2024.02.26.00.30.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 00:30:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708936234; x=1709541034; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zYd02SLfgP/LCWG+Mrru0HvWw0TZYZU2hsjtTtlA/n0=; b=AGq5JgMLLfr0xL8WLi0hsvG3oK24dqexlmr9MhTd6cE2HMrfQbMpeI3FNC6+VQiQrX kfQ076nFw97wrWshcbnxhJJkRPp/di/NRVkBPnbv9XVeMTE5EWiGu9TJ/vtOvDeRCWAN MVU5QbYeGLmL5iMtpRFdU/91VPKi/YtQKuRwwZvg6YZR/6RK68G0fGImST7RUmbj9Au2 0rMtgo21TctNtr00xeQVAha6e0sUMsuSgOrt+RyHXpyegN17Pw34UWP2l/yw3RIqpgeM EV+GkOIFYREI7SqYCAJxkG/m7FoFenz+7UI5xwzj1WAmmfcpch5e8gb3whTFbmKe3Dp+ JMFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708936234; x=1709541034; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zYd02SLfgP/LCWG+Mrru0HvWw0TZYZU2hsjtTtlA/n0=; b=Au33BgwePgbLQeHtRktu9VsYqf7yWWd4ynd0ASptObWy5gNmXxoRxPqsfoL4dVThnT llHNZ9uoq1hy9y8/i7/FzR1geBKCFGOYV6iNZ7xFGNIRfV7fV3YF4zWUu9Sz1JbG4Shr pFkQ8DX2xTwuu8kWice2XM7X6gmOsXETorEbE+mqqmySEBfCBv0uSaVD53bNrjkRcU0/ C+GzJzc491ev5k6msreONE0I7KvK49PVwY7dkP58DCcYnHP0nuBtsQsjFvuZTX6Aj/Nd tvni0F/15ibW5cj3CKo+IRXAH6nXWWgon1c1fESfxxXpD2H2h5vQSUPm9Zc/pAVJIfpm hRBA== X-Gm-Message-State: AOJu0YwVoxF3jW4sECpkrkemynel9dUs6tg+x509Z7Q2z3RCX7MI1kxH TTLq9hEtiik1GVSvfn5+98Ouu1XPDEYB6TppX5SeTK904k1Suj8POfsbzqqa X-Google-Smtp-Source: AGHT+IF06vW+rgzrCQoP9CAbjzhrZ501ApCh3EqJTIYUcz5qVlDJjykmW9r/4yHgZNVZ4VYLAa4bdw== X-Received: by 2002:a17:902:cf0d:b0:1dc:affd:6510 with SMTP id i13-20020a170902cf0d00b001dcaffd6510mr171831plg.49.1708936234272; Mon, 26 Feb 2024 00:30:34 -0800 (PST) From: Nicholas Piggin To: qemu-devel@nongnu.org Cc: Nicholas Piggin , Pavel Dovgalyuk , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , John Snow , Cleber Rosa , Wainer dos Santos Moschetta , Beraldo Leal Subject: [PATCH v3 6/9] chardev: set record/replay on the base device of a muxed device Date: Mon, 26 Feb 2024 18:29:42 +1000 Message-ID: <20240226082945.1452499-7-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240226082945.1452499-1-npiggin@gmail.com> References: <20240226082945.1452499-1-npiggin@gmail.com> 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=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=npiggin@gmail.com; helo=mail-pl1-x62e.google.com 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 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 @gmail.com) X-ZM-MESSAGEID: 1708936319062100002 Content-Type: text/plain; charset="utf-8" chardev events to a muxed device don't get recorded because e.g., qemu_chr_be_write() checks whether the base device has the record flag set. This can be seen when replaying a trace that has characters typed into the console, an examination of the log shows they are not recorded. Setting QEMU_CHAR_FEATURE_REPLAY on the base chardev fixes the problem. Signed-off-by: Nicholas Piggin --- chardev/char.c | 71 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 21 deletions(-) diff --git a/chardev/char.c b/chardev/char.c index 3c43fb1278..ba847b6e9e 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -615,11 +615,24 @@ ChardevBackend *qemu_chr_parse_opts(QemuOpts *opts, E= rror **errp) return backend; } =20 -Chardev *qemu_chr_new_from_opts(QemuOpts *opts, GMainContext *context, - Error **errp) +static void qemu_chardev_set_replay(Chardev *chr, Error **errp) +{ + if (replay_mode !=3D REPLAY_MODE_NONE) { + if (CHARDEV_GET_CLASS(chr)->chr_ioctl) { + error_setg(errp, "Replay: ioctl is not supported " + "for serial devices yet"); + return; + } + qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_REPLAY); + replay_register_char_driver(chr); + } +} + +static Chardev *__qemu_chr_new_from_opts(QemuOpts *opts, GMainContext *con= text, + bool replay, Error **errp) { const ChardevClass *cc; - Chardev *chr =3D NULL; + Chardev *base =3D NULL, *chr =3D NULL; ChardevBackend *backend =3D NULL; const char *name =3D qemu_opt_get(opts, "backend"); const char *id =3D qemu_opts_id(opts); @@ -657,11 +670,11 @@ Chardev *qemu_chr_new_from_opts(QemuOpts *opts, GMain= Context *context, chr =3D qemu_chardev_new(bid ? bid : id, object_class_get_name(OBJECT_CLASS(cc)), backend, context, errp); - if (chr =3D=3D NULL) { goto out; } =20 + base =3D chr; if (bid) { Chardev *mux; qapi_free_ChardevBackend(backend); @@ -681,11 +694,25 @@ Chardev *qemu_chr_new_from_opts(QemuOpts *opts, GMain= Context *context, out: qapi_free_ChardevBackend(backend); g_free(bid); + + if (replay && base) { + /* RR should be set on the base device, not the mux */ + qemu_chardev_set_replay(base, errp); + } + return chr; } =20 -Chardev *qemu_chr_new_noreplay(const char *label, const char *filename, - bool permit_mux_mon, GMainContext *context) +Chardev *qemu_chr_new_from_opts(QemuOpts *opts, GMainContext *context, + Error **errp) +{ + /* XXX: should this really not record/replay? */ + return __qemu_chr_new_from_opts(opts, context, false, errp); +} + +static Chardev *__qemu_chr_new(const char *label, const char *filename, + bool permit_mux_mon, GMainContext *context, + bool replay) { const char *p; Chardev *chr; @@ -693,14 +720,22 @@ Chardev *qemu_chr_new_noreplay(const char *label, con= st char *filename, Error *err =3D NULL; =20 if (strstart(filename, "chardev:", &p)) { - return qemu_chr_find(p); + chr =3D qemu_chr_find(p); + if (replay) { + qemu_chardev_set_replay(chr, &err); + if (err) { + error_report_err(err); + return NULL; + } + } + return chr; } =20 opts =3D qemu_chr_parse_compat(label, filename, permit_mux_mon); if (!opts) return NULL; =20 - chr =3D qemu_chr_new_from_opts(opts, context, &err); + chr =3D __qemu_chr_new_from_opts(opts, context, replay, &err); if (!chr) { error_report_err(err); goto out; @@ -722,24 +757,18 @@ out: return chr; } =20 +Chardev *qemu_chr_new_noreplay(const char *label, const char *filename, + bool permit_mux_mon, GMainContext *context) +{ + return __qemu_chr_new(label, filename, permit_mux_mon, context, false); +} + static Chardev *qemu_chr_new_permit_mux_mon(const char *label, const char *filename, bool permit_mux_mon, GMainContext *context) { - Chardev *chr; - chr =3D qemu_chr_new_noreplay(label, filename, permit_mux_mon, context= ); - if (chr) { - if (replay_mode !=3D REPLAY_MODE_NONE) { - qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_REPLAY); - } - if (qemu_chr_replay(chr) && CHARDEV_GET_CLASS(chr)->chr_ioctl) { - error_report("Replay: ioctl is not supported " - "for serial devices yet"); - } - replay_register_char_driver(chr); - } - return chr; + return __qemu_chr_new(label, filename, permit_mux_mon, context, true); } =20 Chardev *qemu_chr_new(const char *label, const char *filename, --=20 2.42.0