Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B77D3606A322 for ; Fri, 4 Dec 2026 13:20:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=ThJa9mxD Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xZTCe-0002FH-9v; Fri, 04 Dec 2026 08:19:56 -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 1xZTCd-0002Ee-9Y for qemu-rust@nongnu.org; Fri, 04 Dec 2026 08:19:55 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xZTCb-0004uL-EG for qemu-rust@nongnu.org; Fri, 04 Dec 2026 08:19:55 -0500 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-498f5fa5103so610740f8f.2 for ; Fri, 04 Dec 2026 05:19:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1796390392; x=1796995192; 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:content-type; bh=7W+XZ8/EuSx1+alV05kLMLKiM2RJ8bpHXzTVGGGUAx4=; b=ThJa9mxD3OqXHOEn8VWhsW4P/UqJaNCCfk4WmvQoXtO3LiqA8X/HRq5QRUCf7MGYSX TOofA0S9yFrhiMcUJ1dj3ADQKXG8T0UZ4vnDdhgjNVzI3bB6WCL6j8zzyZU+IYe9p95I 5AYkCg3ga3XV1M1HAMEU+NIVStSQz6OaEXktARE/boIwWGjSGroOMU3YCjVJKNK2aPUq cGRdVXONajusdhsVqYeqNgkumV0Zyeh0w5nlWMlwA1XGPI371w9zFkernMJr0/4TQR// mrlCY8pIGHTkguH3ON8PL+BJ5R3xbdYDwlHevTPEcDkAPoXGKzy7HarlX7Xs/xT5zKYu IO0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796390392; x=1796995192; h=content-transfer-encoding:mime-version:references:in-reply-to :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=7W+XZ8/EuSx1+alV05kLMLKiM2RJ8bpHXzTVGGGUAx4=; b=0zp504BG4MqwLbC+wTwqL/Z7DEybwIdtv4f15VVE57sl/41Uk/2VPdZRzFSDkNo25b vbPiSyLs0F0uxr4kEvYBpEQ8iKHhTnFNMgIsdeoqYo1KedmuC19l32djK3HI7G6wZX0Y IaQMiR9Z22N7nXDMFUKnj6qpEV9WpwuXZI9PSA76rqw5+64lzI1YssZ0Ma1q6yhnMNlb UPCCgiAcHFEwtsdbIhC7d1jeWJjmVDlK9wGglsg0HLQJisKqO1erXShATa3blNIJftYT 7Uo93ZM/wFVacmbiIMOYR/xgsA/Sb2ACDsRB6ZLUWpvSr8fiHLd4JVZilJgwlgrH8kqK ShDA== X-Forwarded-Encrypted: i=1; AL+hErGaW1qjEfpwfgT+qDUd/M1hWUhpnk0QvrHYlcJSWk/ONqc6neYA/+29T8saP5Cm/PB9DtUiK3HI21o=@nongnu.org X-Gm-Message-State: AB4q+uFboYgzHFBbMpHccGmsR9yTcnGutgRaNbEL+nO5dStzUEWYv3bp R5HsY2hQ5NwE8Y1Tok4hpNr0FNqMLt9xvnlemmWtwEuonjNhkeW833+ljlRoeis/QT0= X-Gm-Gg: AZFdTZeCHS3fUBKP08uh2TKO6DMd/kz8WcAKu3ygBuBC2EBSP8aj2+dWQELJ6OUrMMe 1GLn+bys91dLJWfDozU8h4KTh4Y9hfJuBJjui7CF8U/38NqXYD1zDpfUp7fAKEL1Gmr6Ed2U/qY rZgSNYbVzI0V1csS6HcoNt+qqKYETCOLLCR/5Lf/oIARHlOEHQTzymnLH9WEnHgwip7cqNia7qd XQdhsS/gLvShyaVvsh+XWD2vGtl80VPvF3MpGoUZiinr1Ep1b3U7wvqwfMcTu6drK6f+CWLCNFw PY99q064N16TmkBPENK5flS8zxz5HLfxwTAHAfpvS+Ko1eaVWNUe9zCYpxmrIFgfEbNY49KnMV5 kprMNbBroK8obq/2xk41gJNHvuu0RXyoqywnfsiJmHKFnvPa/G4e9pDlIt5of73mDmBdR9gbaTX R+QK9+1I5IBD+TkNB8vClUs7qToyWvtP2QR8ceS+eenvCQRYUasSiecFY74Y/s3cPlcsU7gIiit 4t3730FoX+rCnwhCWUR8HQ7Ehbo0uC1aE7b1EUvn1C0RGchWSf38lUsqroL2LuTOwc+IdRS9ngx lnViMfauNXZQZusx6xM/P1KhscvUnnTItY0djiDYCmwZCB4KPOUraS69kmvXoOf7SWyki/ZToja hsswpJ3c7c3oY6xSZETZBWBfvgMztXMHnkw== X-Received: by 2002:adf:e002:0:20b0:4a7:2673:ad2e with SMTP id ffacd0b85a97d-4d1e291ed84mr2852535f8f.1.1796390391807; Fri, 04 Dec 2026 05:19:51 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d1738cfb80sm5342097f8f.36.2026.12.04.05.19.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 05:19:51 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Jason Wang , Stefan Hajnoczi , Fam Zheng , Manos Pitsidianakis , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Samuel Thibault , Paolo Bonzini , Thomas Huth , qemu-rust@nongnu.org Subject: [PATCH 4/6] util/qemu_timer: Add timer_new_ns_guarded() Date: Fri, 4 Dec 2026 13:19:44 +0000 Message-ID: <20261204131946.2175006-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261204131946.2175006-1-peter.maydell@linaro.org> References: <20261204131946.2175006-1-peter.maydell@linaro.org> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42b.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-rust@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: QEMU Rust-related patches and discussion List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-rust-bounces+qemu-rust=archiver.kernel.org@nongnu.org X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Add a timer_new_ns_guarded() function which is the same as timer_new_ns() but takes a MemReentrancyGuard. There are a lot of different sub-flavours of timer_new() and timer_init() wrappers which could have _guarded() versions added; rather than adding half a dozen functions which have no callers, start with just the one we want for the two devices we plan to make use it. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell --- include/qemu/timer.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/include/qemu/timer.h b/include/qemu/timer.h index 1287682de61..85504e2bc53 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -562,6 +562,33 @@ static inline QEMUTimer *timer_new_ns(QEMUClockType type, QEMUTimerCB *cb, return timer_new(type, SCALE_NS, cb, opaque); } +/** + * timer_new_ns_guarded: + * @type: the clock type to associate with the timer + * @cb: the callback to call when the timer expires + * @opaque: the opaque pointer to pass to the callback + * @reentrancy_guard: A guard set when entering @cb to prevent + * device-rentrancy issues + * + * Create a new timer with nanosecond scale on the default timer list + * associated with the clock, and a reentrancy guard. + * See timer_new_full for details. + * + * The timer returned must be freed using timer_free(). + * + * The guard is optional, but if you aren't specifying it then + * you can just use timer_new_ns() instead. + * + * Returns: a pointer to the newly created timer + */ +static inline QEMUTimer *timer_new_ns_guarded(QEMUClockType type, + QEMUTimerCB *cb, + void *opaque, + MemReentrancyGuard *guard) +{ + return timer_new_full(NULL, type, SCALE_NS, 0, cb, opaque, guard); +} + /** * timer_new_us: * @type: the clock type to associate with the timer -- 2.43.0