From nobody Mon Nov 23 04:26:37 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1793308002; cv=none; d=zohomail.com; s=zohoarc; b=bIaVPIeW75aRBvDXKXHCw13NAOXCzC2sx6wbQ4yMbZlrmU75/pHYlBdaF7lKMBQbmgWSHMmB9sZCBZhyK93+xp2pxWQD0IZyvxDcb06hRs4llfLzBQOTZDhSu4YRfs+fVM1Kp1mqZm+y0WzPIE2oK1FWHLX3JTpeyck+CCsqJ7c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793308002; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Onj0xrMaSx5UePtgc3yUbxdHw2czuvDcvMEkLV2txpA=; b=lUPSyKNXf17M7GTUwC5GHPEaqb+OVek/NeAx3PJboQcxlb1gczo2ix7+Fsa6RsJZb9Q2xCX+oJdgzFvgSuJd4Flddc/j1c7JkCEt9FshI/OGdtDoLzP8kaSBd34XqfVzFu12gdgbG+Rt4mH1JxdjPbg0l0DyHBkVMSRGwA+4eNQ= 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 1793308002056521.0169055991126; Thu, 29 Oct 2026 14:06:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMXJr-0002Hc-4z; Thu, 29 Oct 2026 17:05:55 -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 1xMXJl-0002GX-Gy for qemu-devel@nongnu.org; Thu, 29 Oct 2026 17:05:49 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xMXJj-0001HS-Dj for qemu-devel@nongnu.org; Thu, 29 Oct 2026 17:05:49 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 944A01FC2A; Thu, 29 Oct 2026 21:05:44 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B42371342D; Thu, 29 Oct 2026 21:05:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id E1LmGia142qaYAAAD6G6ig:T2 (envelope-from ); Thu, 29 Oct 2026 21:05:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1793307945; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Onj0xrMaSx5UePtgc3yUbxdHw2czuvDcvMEkLV2txpA=; b=Jq0XgBdkdkm91n+tmKG7S0aWT6yCfcn3Ce1rotgeZn2Yv+iob1PtMz+G9JM1IKavvHKN7F /Ak1AgE1/DHewrFaRnOUpx95mGvGihGEJUzOKxY+zFYlHfhvt84dtQtNUwX0U14BWxUKCn qe7Brg4mRV+2xJXXO/djcf6l+ANywoQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1793307945; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Onj0xrMaSx5UePtgc3yUbxdHw2czuvDcvMEkLV2txpA=; b=eM4hAFKiPe5Y7A2MD0vI0yuvR96hzCD+axfYYshuj84t+FfDBzEhbJHtk0jfFdYIVToTDM gvUvbkaa1O9qNKAg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1793307944; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Onj0xrMaSx5UePtgc3yUbxdHw2czuvDcvMEkLV2txpA=; b=tCkBZYhjlbaIY9yHTDBNfneTVFPEGW+RE95UsjEge6r++uPRnAq1NZRuk09iwgcc3WFyv2 YFVhtuTmZxxPOT2vSYOXRzCnBv0eDyQuCh5e9C6PNxv5XT+E+KtDLV1Y1mhHjr/MVfDqE3 w9jaWujBO+7RBk7bhNLNDZRxYGN3oAU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1793307944; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Onj0xrMaSx5UePtgc3yUbxdHw2czuvDcvMEkLV2txpA=; b=iCEk9/+3k3tOtd4IcioHd1kI2rvPNnEfUk/rop1SmclIO29aIvghun5fJiQS2IiJ4QtiYG 3CscFJzyoeUTmkAw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Maydell Subject: [PULL 1/5] system/qtest: Avoid fixed-size irq_levels array for IRQ intercept Date: Thu, 29 Oct 2026 18:05:32 -0300 Message-ID: <20261029210536.2260016-2-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261029210536.2260016-1-farosas@suse.de> References: <20261029210536.2260016-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-11.80 / 50.00]; SUSE_INTERNAL_BYPASS(-9.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.995]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; URIBL_BLOCKED(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email,linaro.org:email]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -11.80 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=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1793308005541154100 Content-Type: text/plain; charset="utf-8" From: Peter Maydell The current implementation of the irq_intercept_out and irq_intercept_in commands uses a fixed-size static irq_levels[] array to track the state of the intercepted IRQ lines. This is sized at MAX_IRQ =3D=3D 256, which is smaller than some real device models use (for instance the GICv2 on the virt board has 384 inputs). A test that tried to intercept the inputs to such a device and then assert an interrupt over 255 would overrun the array. Reimplement the IRQ interception so that it allocates an array of the required size rather than using a static one. Signed-off-by: Peter Maydell Reviewed-by: Fabiano Rosas Signed-off-by: Fabiano Rosas --- system/qtest.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/system/qtest.c b/system/qtest.c index 47c954838dd..a3de815ce65 100644 --- a/system/qtest.c +++ b/system/qtest.c @@ -57,12 +57,18 @@ static DeviceState *irq_intercept_dev; static FILE *qtest_log_fp; static QTest *qtest; static GString *inbuf; -static int irq_levels[MAX_IRQ]; static GTimer *timer; static bool qtest_opened; static void (*qtest_server_send)(void*, const char*); static void *qtest_server_send_opaque; =20 +typedef struct IrqInterceptState { + int *irq_levels; + int num_irqs; +} IrqInterceptState; + +IrqInterceptState irq_intercept_state; + #define FMT_timeval "%.06f" =20 /** @@ -327,9 +333,10 @@ void qtest_sendf(CharFrontend *chr, const char *fmt, .= ..) =20 static void qtest_irq_handler(void *opaque, int n, int level) { - if (irq_levels[n] !=3D level) { + assert(n >=3D 0 && n < irq_intercept_state.num_irqs); + if (irq_intercept_state.irq_levels[n] !=3D level) { CharFrontend *chr =3D &qtest->qtest_chr; - irq_levels[n] =3D level; + irq_intercept_state.irq_levels[n] =3D level; qtest_sendf(chr, "IRQ %s %d\n", level ? "raise" : "lower", n); } @@ -353,6 +360,13 @@ static void qtest_install_gpio_out_intercept(DeviceSta= te *dev, const char *name, *disconnected =3D qdev_intercept_gpio_out(dev, icpt, name, n); } =20 +static void qtest_init_irq_intercept(int num_irqs) +{ + g_free(irq_intercept_state.irq_levels); + irq_intercept_state.irq_levels =3D g_new0(int, num_irqs); + irq_intercept_state.num_irqs =3D num_irqs; +} + static void qtest_process_command(CharFrontend *chr, gchar **words) { const gchar *command; @@ -413,12 +427,14 @@ static void qtest_process_command(CharFrontend *chr, = gchar **words) /* NULL is valid and matchable, for "unnamed GPIO" */ if (g_strcmp0(ngl->name, words[2]) =3D=3D 0) { int i; + qtest_init_irq_intercept(ngl->num_out); for (i =3D 0; i < ngl->num_out; ++i) { qtest_install_gpio_out_intercept(dev, ngl->name, i= ); } interception_succeeded =3D true; } } else { + qtest_init_irq_intercept(ngl->num_in); qemu_irq_set_observer(ngl->in, qtest_irq_handler, ngl->num_in); interception_succeeded =3D true; @@ -861,8 +877,10 @@ static void qtest_event(void *opaque, QEMUChrEvent eve= nt) * used. Injects an extra reset even when it's not used, and * that can mess up tests, e.g. -boot once. */ - for (i =3D 0; i < ARRAY_SIZE(irq_levels); i++) { - irq_levels[i] =3D 0; + if (irq_intercept_state.irq_levels) { + for (i =3D 0; i < irq_intercept_state.num_irqs; i++) { + irq_intercept_state.irq_levels[i] =3D 0; + } } =20 g_clear_pointer(&timer, g_timer_destroy); --=20 2.53.0 From nobody Mon Nov 23 04:26:37 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1793308005; cv=none; d=zohomail.com; s=zohoarc; b=mQeA+Mr7IcSHNmMDIqYLMDyuNZ4Upe/XPwBwwOWaRXguOoid1R+gvYEOHnd54JjjhtDNBNxtkPUc/qSI1aLz7spw0v5Hw7g08sUHCj6sb9GwPoWCwZwcKME8pGwk67LRIBMqK3g1IlOez295XVfpTUjC2AX3BMX3dKxiWoa3JZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793308005; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GFKsKG/+7eMbnSeIrUNwtWUFTYprAdIP0JDz9oY7qec=; b=LJ6h+4UfygtNOilH2UyUl+Ck6esH7JFZSQKgFTi3xcBZdNYYJj4kX8TU3sgpHJJgEj0NmRWLRe/9D6CnAan9gCnapQUjWex1PN5Lo6L4PGypAzcqDfhhUdejdGo+nFzlS2yATO8CP0NhqoB5hcZOBImqz0BY2BakdTRoEi2XuPc= 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 1793308005078419.9036824385307; Thu, 29 Oct 2026 14:06:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMXJm-0002H3-IF; Thu, 29 Oct 2026 17:05:50 -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 1xMXJk-0002GN-OO for qemu-devel@nongnu.org; Thu, 29 Oct 2026 17:05:48 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xMXJi-0001HQ-W4 for qemu-devel@nongnu.org; Thu, 29 Oct 2026 17:05:48 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A6498222AD; Thu, 29 Oct 2026 21:05:45 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id CBB5F1342F; Thu, 29 Oct 2026 21:05:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id E1LmGia142qaYAAAD6G6ig:T3 (envelope-from ); Thu, 29 Oct 2026 21:05:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1793307945; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GFKsKG/+7eMbnSeIrUNwtWUFTYprAdIP0JDz9oY7qec=; b=IKFmCP15nKX3FcoPqQKiHak9bbtGNmXmGQi0AJ9F822BydjCSvpOlEj8Pcw7h4QS91isSj vOcYnO1lv+wo0T8F8x+7DKx0MtJpcyLOKwbaecpJjdQUAA36ZBvPgp7+T0k5f7+m19+jL3 i46Ta0bmTDxsx8Z1UJ3xDeypPmjRJ5w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1793307945; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GFKsKG/+7eMbnSeIrUNwtWUFTYprAdIP0JDz9oY7qec=; b=eU2dOiXRLivZC0HQ89r9IjNkpLJqp24bNmGw4H2dIpm6xp36maRj3UCiESokBiAuT88lPt +x05yg7QAdrpPADg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1793307945; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GFKsKG/+7eMbnSeIrUNwtWUFTYprAdIP0JDz9oY7qec=; b=IKFmCP15nKX3FcoPqQKiHak9bbtGNmXmGQi0AJ9F822BydjCSvpOlEj8Pcw7h4QS91isSj vOcYnO1lv+wo0T8F8x+7DKx0MtJpcyLOKwbaecpJjdQUAA36ZBvPgp7+T0k5f7+m19+jL3 i46Ta0bmTDxsx8Z1UJ3xDeypPmjRJ5w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1793307945; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GFKsKG/+7eMbnSeIrUNwtWUFTYprAdIP0JDz9oY7qec=; b=eU2dOiXRLivZC0HQ89r9IjNkpLJqp24bNmGw4H2dIpm6xp36maRj3UCiESokBiAuT88lPt +x05yg7QAdrpPADg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Maydell Subject: [PULL 2/5] system/qtest: Check ngl->name for irq_intercept_in Date: Thu, 29 Oct 2026 18:05:33 -0300 Message-ID: <20261029210536.2260016-3-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261029210536.2260016-1-farosas@suse.de> References: <20261029210536.2260016-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-11.80 / 50.00]; SUSE_INTERNAL_BYPASS(-9.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.996]; MIME_GOOD(-0.10)[text/plain]; DBL_BLOCKED_OPENRESOLVER(0.00)[linaro.org:email,suse.de:email,imap1.dmz-prg2.suse.org:helo]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; RCVD_COUNT_TWO(0.00)[2]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_DN_SOME(0.00)[]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -11.80 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=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de 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_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 @suse.de) X-ZM-MESSAGEID: 1793308006527158500 Content-Type: text/plain; charset="utf-8" From: Peter Maydell Currently we check the name of the NamedGPIOList when doing irq_intercept_out, but not for irq_intercept_in. Even though we don't currently support irq_intercept_in on named GPIO lines, we still need to check the name, because otherwise we will install the observer on every set of GPIO inputs the device has, rather than only for the unnamed GPIO inputs. This doesn't currently affect any test cases, because of all the tests which use irq_intercept_in only tests/qtest-l2vic-test.c uses it on a device that creates named GPIO inputs. That device has both unnamed GPIO inputs and a named GPIO input "reset". The effect is that a change in the "reset" line state looks like a change in interrupt input line 0; but since the test doesn't cause "reset" to change this doesn't happen and there are no observable effects of the bug. Check the ngl->name against the specified one for both input and output interception. (Currently this will be equivalent to a check against NULL for input intercepts.) As we're now checking for an exact name match unconditionally, we can break out of the loop as soon as we've found it. Signed-off-by: Peter Maydell Reviewed-by: Fabiano Rosas Signed-off-by: Fabiano Rosas --- system/qtest.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/system/qtest.c b/system/qtest.c index a3de815ce65..5ff3f9f27d8 100644 --- a/system/qtest.c +++ b/system/qtest.c @@ -422,23 +422,24 @@ static void qtest_process_command(CharFrontend *chr, = gchar **words) } =20 QLIST_FOREACH(ngl, &dev->gpios, node) { - /* We don't support inbound interception of named GPIOs yet */ + /* NULL is valid and matchable, for "unnamed GPIO" */ + if (g_strcmp0(ngl->name, words[2]) !=3D 0) { + continue; + } + if (is_outbound) { - /* NULL is valid and matchable, for "unnamed GPIO" */ - if (g_strcmp0(ngl->name, words[2]) =3D=3D 0) { - int i; - qtest_init_irq_intercept(ngl->num_out); - for (i =3D 0; i < ngl->num_out; ++i) { - qtest_install_gpio_out_intercept(dev, ngl->name, i= ); - } - interception_succeeded =3D true; + int i; + qtest_init_irq_intercept(ngl->num_out); + for (i =3D 0; i < ngl->num_out; ++i) { + qtest_install_gpio_out_intercept(dev, ngl->name, i); } } else { qtest_init_irq_intercept(ngl->num_in); qemu_irq_set_observer(ngl->in, qtest_irq_handler, ngl->num_in); - interception_succeeded =3D true; } + interception_succeeded =3D true; + break; } =20 if (interception_succeeded) { --=20 2.53.0 From nobody Mon Nov 23 04:26:37 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1793308023; cv=none; d=zohomail.com; s=zohoarc; b=fh1ZBsskxi5JqlTlvd7Fv6t5hB+GUm7Xqlh2D3NMX9MgT0E6gpRLhVwTPcFeCttAbpvrTlHO8HdzqL+LiQFS03DVlzC9qCIS58iTu1Z1MmM1glqaCY7co6bnzD2Pv2vDOf34esA8CrS6PfXJtXXoPQqOjxoxhKNT68ont9XuIJc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793308023; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4JbjEtdL2DRurR7EuZaGpokUmGwuBEaTEySNRVLKGns=; b=Kq+jfZjwHH0Zv9J6GXlAghgXmGnAwMVhZ4WZnm6dflRtfh6j1H7wxyJxVe5enqJV8ywB6otdhJ7mWK40Fx6wVYBoreolszBieR+YxZgnQng+j0TXegIL+BiUfz+RmLiC7yzIdxIGmNGMwpCOi8D8lXgqi4r7JYR+8A5B5/r/rRs= 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 1793308023421510.12073179290496; Thu, 29 Oct 2026 14:07:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMXJt-0002Hw-8E; Thu, 29 Oct 2026 17:05:57 -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 1xMXJm-0002Gf-0p for qemu-devel@nongnu.org; Thu, 29 Oct 2026 17:05:50 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xMXJj-0001HZ-Tu for qemu-devel@nongnu.org; Thu, 29 Oct 2026 17:05:49 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id BA3F6222AC; Thu, 29 Oct 2026 21:05:46 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id E317D13419; Thu, 29 Oct 2026 21:05:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id E1LmGia142qaYAAAD6G6ig:T4 (envelope-from ); Thu, 29 Oct 2026 21:05:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1793307946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4JbjEtdL2DRurR7EuZaGpokUmGwuBEaTEySNRVLKGns=; b=2CugT2Y1634uR24AunW3EPWJnvyNfdiy9+6J8HTseoOKJkGJ7mwoylMflXvV0d8dJS0oI1 eZT/VhLoDMZA5qVuS5G2R/DgIefAyYquSoxLYXL3EQXIMmPe1ilqFlDWtJk2lWKbfoOYlc aqkzt0i8XInwzzfCathq1EkNf8KhbbY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1793307946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4JbjEtdL2DRurR7EuZaGpokUmGwuBEaTEySNRVLKGns=; b=XvNyJY9QcderL4KSHet8Rm3A3npoL7CIOxB3vM7VYAKYx1q2WqZ9fDXF3jpF3z+/iWRF3E e44vb6Jge/u0cIAA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=2CugT2Y1; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=XvNyJY9Q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1793307946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4JbjEtdL2DRurR7EuZaGpokUmGwuBEaTEySNRVLKGns=; b=2CugT2Y1634uR24AunW3EPWJnvyNfdiy9+6J8HTseoOKJkGJ7mwoylMflXvV0d8dJS0oI1 eZT/VhLoDMZA5qVuS5G2R/DgIefAyYquSoxLYXL3EQXIMmPe1ilqFlDWtJk2lWKbfoOYlc aqkzt0i8XInwzzfCathq1EkNf8KhbbY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1793307946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4JbjEtdL2DRurR7EuZaGpokUmGwuBEaTEySNRVLKGns=; b=XvNyJY9QcderL4KSHet8Rm3A3npoL7CIOxB3vM7VYAKYx1q2WqZ9fDXF3jpF3z+/iWRF3E e44vb6Jge/u0cIAA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Maydell Subject: [PULL 3/5] tests/qtest/libqtest: Use a GArray for QTestState::irq_level[] Date: Thu, 29 Oct 2026 18:05:34 -0300 Message-ID: <20261029210536.2260016-4-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261029210536.2260016-1-farosas@suse.de> References: <20261029210536.2260016-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: BA3F6222AC X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spamd-Result: default: False [-12.01 / 50.00]; SUSE_INTERNAL_BYPASS(-9.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; URIBL_BLOCKED(0.00)[imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.de:dkim,suse.de:email]; RCPT_COUNT_TWO(0.00)[2]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from,2a07:de40:b281:106:10:150:64:167:received]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:rdns, imap1.dmz-prg2.suse.org:helo, suse.de:dkim, suse.de:email, linaro.org:email] X-Spam-Score: -12.01 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=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de 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_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 @suse.de) X-ZM-MESSAGEID: 1793308024865158500 Content-Type: text/plain; charset="utf-8" From: Peter Maydell Currently we use a fixed irq_level[] array of 256 elements in QTestState to implement capturing the IRQ level reported by the QEMU under test so we can return it in qtest_get_irq(). This is smaller than is actually used by some devices, and if a test tries to intercept more IRQs than this and one is reported to libqtest then we'll fail an assertion in qtest_rsp_args(). Switch to a GArray, which automatically resizes as required. Signed-off-by: Peter Maydell Reviewed-by: Fabiano Rosas Signed-off-by: Fabiano Rosas --- tests/qtest/libqtest.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 9e7a2d43a18..22b0dc193c9 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -42,8 +42,6 @@ #include "qobject/qstring.h" #include "qobject/qbool.h" =20 -#define MAX_IRQ 256 - #define ACCEPT_TIMEOUT_MS 250 #define ACCEPT_RETRIES (4 * 50) =20 @@ -88,7 +86,7 @@ struct QTestState #endif int expected_status; bool big_endian; - bool irq_level[MAX_IRQ]; + GArray *irq_level; GString *rx; QTestTransportOps ops; GList *pending_events; @@ -501,7 +499,7 @@ static QTestState *qtest_init_internal(const char *qemu= _bin, void *opaque) { QTestState *s; - int sock, qmpsock, i; + int sock, qmpsock; g_autofree gchar *socket_path =3D qtest_socket_path("sock"); g_autofree gchar *qmp_socket_path =3D qtest_socket_path("qmp"); g_autofree gchar *args =3D qtest_qemu_args(extra_args); @@ -525,9 +523,7 @@ static QTestState *qtest_init_internal(const char *qemu= _bin, qtest_client_set_tx_handler(s, qtest_client_socket_send); =20 s->rx =3D g_string_new(""); - for (i =3D 0; i < MAX_IRQ; i++) { - s->irq_level[i] =3D false; - } + s->irq_level =3D g_array_new(false, true, sizeof(bool)); =20 s->fd =3D -1; s->qmp_fd =3D -1; @@ -693,6 +689,7 @@ void qtest_quit(QTestState *s) close(s->fd); close(s->qmp_fd); g_string_free(s->rx, true); + g_array_unref(s->irq_level); =20 for (GList *it =3D s->pending_events; it !=3D NULL; it =3D it->next) { qobject_unref((QDict *)it->data); @@ -778,12 +775,14 @@ redo: ret =3D qemu_strtol(words[2], NULL, 0, &irq); g_assert(!ret); g_assert_cmpint(irq, >=3D, 0); - g_assert_cmpint(irq, <, MAX_IRQ); =20 + if (s->irq_level->len <=3D irq) { + g_array_set_size(s->irq_level, irq + 1); + } if (strcmp(words[1], "raise") =3D=3D 0) { - s->irq_level[irq] =3D true; + g_array_index(s->irq_level, bool, irq) =3D true; } else { - s->irq_level[irq] =3D false; + g_array_index(s->irq_level, bool, irq) =3D false; } =20 g_strfreev(words); @@ -1192,7 +1191,10 @@ bool qtest_get_irq(QTestState *s, int num) /* dummy operation in order to make sure irq is up to date */ qtest_inb(s, 0); =20 - return s->irq_level[num]; + if (s->irq_level->len <=3D num) { + return false; + } + return g_array_index(s->irq_level, bool, num); } =20 void qtest_module_load(QTestState *s, const char *prefix, const char *libn= ame) @@ -2100,9 +2102,7 @@ QTestState *qtest_inproc_init(QTestState **s, bool lo= g, const char* arch, qts->pending_events =3D NULL; *s =3D qts; /* Expose qts early on, since the query endianness relies = on it */ qts->wstatus =3D 0; - for (int i =3D 0; i < MAX_IRQ; i++) { - qts->irq_level[i] =3D false; - } + qts->irq_level =3D g_array_new(false, true, sizeof(bool)); =20 qtest_client_set_rx_handler(qts, qtest_client_inproc_recv_line); =20 --=20 2.53.0 From nobody Mon Nov 23 04:26:37 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1793308018; cv=none; d=zohomail.com; s=zohoarc; b=cJ2rytEVjkxKcs1Ud/ZXswSkOS6d9e1dVV15dHzRGk0wNmxOIsVhkR4sxaB+K1mOY7hv/CdgcqxzZzwnq9BtSD4p1Np+JJJEnbpc9nvgkcrulNUT7XdaDAj8Zcy7WODL28F8MdoBUd7UWlDwH1kXQdwcPzb8qjVAX9tY9zNoThg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793308018; h=Content-Type: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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8eECAd2qviXuH4H5ifNDEV7YwGp86dHyjOuJa/+/PzI=; b=Zw1rY89V1UpvajWl9YMZfVi1SLrVem6VXuXGRqHe6TbUkF80eHxW+NPJyk6hOR3xZjr0Bjf1SU40lozSwF7RMIMJ7oJwIJQmJNp35uJ/4+C/tmM6wmhLGaC2IAVbil4TpVb6zAo2iLT6TtwVSm/5nw/yCvaImCAfXlHjvlUPNNQ= 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 179330801833072.57693579615841; Thu, 29 Oct 2026 14:06:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMXJy-0002In-Vk; Thu, 29 Oct 2026 17:06:03 -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 1xMXJw-0002II-W9 for qemu-devel@nongnu.org; Thu, 29 Oct 2026 17:06:01 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xMXJl-0001Hn-KI for qemu-devel@nongnu.org; Thu, 29 Oct 2026 17:05:51 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 0AAFC222AE; Thu, 29 Oct 2026 21:05:48 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 05EA313419; Thu, 29 Oct 2026 21:05:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id E1LmGia142qaYAAAD6G6ig:T5 (envelope-from ); Thu, 29 Oct 2026 21:05:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1793307948; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8eECAd2qviXuH4H5ifNDEV7YwGp86dHyjOuJa/+/PzI=; b=JNq2evIaoshpxrDu28MSsoLuVbedcyAJ6AdyO3QR/Fh0XkJZsc1W7EbA+Mkps3pBIo94Ae Sxj8Xg8qME1OoRldHSV6jntsvZj42HjSe+CK0t55+YA9HotfhPNjLIqW0M9O2c6Eq8znGz MEMc8j1dRGmN2Dmgw9fZfBiviScflwQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1793307948; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8eECAd2qviXuH4H5ifNDEV7YwGp86dHyjOuJa/+/PzI=; b=5Prvlb0csEZGFLGqFpd5jP9EoYv3qUtOROMVwu0QU23XHZn9B7zo5316Z6kAxDsNnHfB0U yV+tg1daiVr1bOCg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1793307948; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8eECAd2qviXuH4H5ifNDEV7YwGp86dHyjOuJa/+/PzI=; b=JNq2evIaoshpxrDu28MSsoLuVbedcyAJ6AdyO3QR/Fh0XkJZsc1W7EbA+Mkps3pBIo94Ae Sxj8Xg8qME1OoRldHSV6jntsvZj42HjSe+CK0t55+YA9HotfhPNjLIqW0M9O2c6Eq8znGz MEMc8j1dRGmN2Dmgw9fZfBiviScflwQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1793307948; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8eECAd2qviXuH4H5ifNDEV7YwGp86dHyjOuJa/+/PzI=; b=5Prvlb0csEZGFLGqFpd5jP9EoYv3qUtOROMVwu0QU23XHZn9B7zo5316Z6kAxDsNnHfB0U yV+tg1daiVr1bOCg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster Subject: [PULL 4/5] qtest: multiple fixes to socket_accept() Date: Thu, 29 Oct 2026 18:05:35 -0300 Message-ID: <20261029210536.2260016-5-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261029210536.2260016-1-farosas@suse.de> References: <20261029210536.2260016-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-12.30 / 50.00]; SUSE_INTERNAL_BYPASS(-9.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email] X-Spam-Score: -12.30 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=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) X-ZM-MESSAGEID: 1793308021014154100 From: Daniel P. Berrang=C3=A9 If the very first iteration of the loop breaks early due to the dead QEMU process, 'ret' is never initialized. Furthermore the listener socket is not closed on success and there is no error message printed if timing out after all iterations are complete. These problems were introduced by the recent refactoring to check QEMU is alive. CID 1688281 Reported-by: Markus Armbruster Fixes: c12ad5378739 ("qtest: fail fast when QEMU terminates early") Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Markus Armbruster Signed-off-by: Fabiano Rosas --- tests/qtest/libqtest.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 22b0dc193c9..dcce889ccc1 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -119,7 +119,7 @@ static int qtest_socket_accept(QTestState *s, int sock) { struct sockaddr_un addr; socklen_t addrlen; - int ret; + int ret =3D -1; size_t i; #ifndef _WIN32 struct timeval timeout =3D { .tv_sec =3D 0, @@ -145,14 +145,13 @@ static int qtest_socket_accept(QTestState *s, int soc= k) =20 addrlen =3D sizeof(addr); ret =3D accept(sock, (struct sockaddr *)&addr, &addrlen); - if (ret =3D=3D -1) { - if (errno =3D=3D EINTR || errno =3D=3D EAGAIN) { - continue; - } else { - fprintf(stderr, "%s failed: %s\n", __func__, strerror(errn= o)); - } + if (ret =3D=3D -1 && (errno =3D=3D EINTR || errno =3D=3D EAGAIN)) { + continue; } - return ret; + break; + } + if (ret =3D=3D -1) { + fprintf(stderr, "%s failed: %s\n", __func__, strerror(errno)); } =20 cleanup: --=20 2.53.0 From nobody Mon Nov 23 04:26:37 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1793308004; cv=none; d=zohomail.com; s=zohoarc; b=TWjM2ram7pYx0BGIdkkCpNOJ5ycsflah8Excrfw3wb2oNss8FarqAQkji0Qs5E4LSFMjX20BQNsA3312oqR0+Q12x7PHxnsxAFDOtb5OsH3zvZj1k7GTnpFgzCCx/tsxkEQ9LCC+PMiVXEROFcr7dF9Q7laK0EBtVPuveenVMwU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793308004; h=Content-Type: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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=J0fyxepkDPMymNPwuVzNVIQSKnUg3sx4xGjDmMq/8HQ=; b=Cu6QkRfm+TFAR0TdS69z6+HJu2DYiPABi/FbcirNd7gKbKt2o1Y9fHgxVQV/D/l6ig2gPWn7MO2XSixiPbGhTmjsI3SaFSmVMU+q4/U2m405us0vF3gsqzYrL1AWazOunK0rtfUNNxhdjv6norJgasnXBDyTvMYjnSd2DTTfIWY= 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 17933080042233.234663275023536; Thu, 29 Oct 2026 14:06:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMXJz-0002Ip-Pj; Thu, 29 Oct 2026 17:06:03 -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 1xMXJy-0002IQ-81 for qemu-devel@nongnu.org; Thu, 29 Oct 2026 17:06:02 -0400 Received: from smtp-out2.suse.de ([2a07:de40:b251:101:10:150:64:2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xMXJu-0001I4-8d for qemu-devel@nongnu.org; Thu, 29 Oct 2026 17:06:01 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4E63E1FC11; Thu, 29 Oct 2026 21:05:49 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 496CD13419; Thu, 29 Oct 2026 21:05:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id E1LmGia142qaYAAAD6G6ig:T6 (envelope-from ); Thu, 29 Oct 2026 21:05:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1793307949; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J0fyxepkDPMymNPwuVzNVIQSKnUg3sx4xGjDmMq/8HQ=; b=gv1XTnvIKWnM8xMMtut74j3dqJNI6rxjMA3MtA3d2vUK0hoIuv2nfRa/7R1mGAv8QjCmFz r3+yRrlCZJr734F6rHicX733f/rSsqhKAjNjSdtjSjLkJ717/IA3duwMSS1XyiJ8/RnQHL 0cCL57OWOHZNWV3d1qvw81zj96Gtk7w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1793307949; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J0fyxepkDPMymNPwuVzNVIQSKnUg3sx4xGjDmMq/8HQ=; b=/fNX0JHMtofw8eYUR3edryopDtdtvdkRKvmtJkOpNpxi7Gz5j8f++0SS/izhJXt6PXw4Vd XEqCzk+VD6bS2fCg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1793307949; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J0fyxepkDPMymNPwuVzNVIQSKnUg3sx4xGjDmMq/8HQ=; b=gv1XTnvIKWnM8xMMtut74j3dqJNI6rxjMA3MtA3d2vUK0hoIuv2nfRa/7R1mGAv8QjCmFz r3+yRrlCZJr734F6rHicX733f/rSsqhKAjNjSdtjSjLkJ717/IA3duwMSS1XyiJ8/RnQHL 0cCL57OWOHZNWV3d1qvw81zj96Gtk7w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1793307949; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J0fyxepkDPMymNPwuVzNVIQSKnUg3sx4xGjDmMq/8HQ=; b=/fNX0JHMtofw8eYUR3edryopDtdtvdkRKvmtJkOpNpxi7Gz5j8f++0SS/izhJXt6PXw4Vd XEqCzk+VD6bS2fCg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster Subject: [PULL 5/5] qtest: don't close listener socket in qtest_socket_accept Date: Thu, 29 Oct 2026 18:05:36 -0300 Message-ID: <20261029210536.2260016-6-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261029210536.2260016-1-farosas@suse.de> References: <20261029210536.2260016-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-12.30 / 50.00]; SUSE_INTERNAL_BYPASS(-9.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; URIBL_BLOCKED(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,imap1.dmz-prg2.suse.org:helo] X-Spam-Score: -12.30 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=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de 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_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 @suse.de) X-ZM-MESSAGEID: 1793308006780154100 From: Daniel P. Berrang=C3=A9 The listener FD passed into qtest_socket_accept should be considered owned by the caller, and thus is is inappropriate and unusual to close it in the method. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Markus Armbruster Signed-off-by: Fabiano Rosas --- tests/qtest/libqtest.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index dcce889ccc1..7f66c1bbb3b 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -132,7 +132,6 @@ static int qtest_socket_accept(QTestState *s, int sock) (void *)&timeout, sizeof(timeout))) { fprintf(stderr, "%s failed to set SO_RCVTIMEO: %s\n", __func__, strerror(errno)); - close(sock); return -1; } =20 @@ -140,7 +139,7 @@ static int qtest_socket_accept(QTestState *s, int sock) if (!qtest_probe_child(s)) { fprintf(stderr, "child process unexpectedly exited, skipping socket ac= cept\n"); - goto cleanup; + return -1; } =20 addrlen =3D sizeof(addr); @@ -154,9 +153,6 @@ static int qtest_socket_accept(QTestState *s, int sock) fprintf(stderr, "%s failed: %s\n", __func__, strerror(errno)); } =20 - cleanup: - close(sock); - return ret; } =20 @@ -562,6 +558,8 @@ void qtest_connect(QTestState *s) unlink(socket_path); unlink(qmp_socket_path); g_assert(s->fd >=3D 0 && s->qmp_fd >=3D 0); + close(s->sock); + close(s->qmpsock); s->sock =3D s->qmpsock =3D -1; /* ask endianness of the target */ s->big_endian =3D qtest_query_target_endianness(s); @@ -671,6 +669,7 @@ QTestState *qtest_init_with_serial(const char *extra_ar= gs, int *sock_fd) =20 *sock_fd =3D qtest_socket_accept(qts, sock_fd_init); =20 + close(sock_fd_init); unlink(sock_path); g_free(sock_path); rmdir(sock_dir); --=20 2.53.0