From nobody Sun Sep 28 15:29:08 2025 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=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1758290417; cv=none; d=zohomail.com; s=zohoarc; b=FzI0ODmuBJXYSlXifgBEyvfyra/gVuYxKVnD0SLpQvw5SFpfm8pn2U8iUa3d9yQZMg/+T7nDBYxt//G/Q0pPq57KLyYk6gtJ9QZv3b737InmzDxxmEKHwD6c6Sa1hoSDsWVBWiSws6fXPpAJJHVQRH/0p3IW6rH2H1ESax16NWo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758290417; h=Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=kGsGOlGVOojXDdph1nJk5GiqPu7d3wjciWIrM04nBVo=; b=GVRyD1ScsOyCNLNDTPAyvdzH7zbKxHWXG7Sao9BKz7GrdRAKXjQ2AmnRKMnJMOmPXnJ9iUrgT2qSPLs4Kz7myBMHJRSeOrj3p6fXypvoWQvqbLZc/x7VwqbUUp/F+2M01DZT7QVrpGvxOs3IiB5z0sBHwS8+eGKcM01ETLnbH1g= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758290417678452.4592954745152; Fri, 19 Sep 2025 07:00:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uzbdp-0005VS-6J; Fri, 19 Sep 2025 09:59:15 -0400 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 1uzbdT-0005S4-Kx for qemu-devel@nongnu.org; Fri, 19 Sep 2025 09:58:53 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uzbdL-0003Bz-2a for qemu-devel@nongnu.org; Fri, 19 Sep 2025 09:58:49 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 58JDuMKP017630; Fri, 19 Sep 2025 13:58:33 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 497g0kdpq2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Sep 2025 13:58:32 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 58JBqv8B028831; Fri, 19 Sep 2025 13:58:32 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 494y2gjpw1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Sep 2025 13:58:32 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 58JDwVLW025678; Fri, 19 Sep 2025 13:58:31 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 494y2gjpvb-1; Fri, 19 Sep 2025 13:58:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :date:from:message-id:subject:to; s=corp-2025-04-25; bh=kGsGOlGV OojXDdph1nJk5GiqPu7d3wjciWIrM04nBVo=; b=d+6MaLLL2FnLiiUJ/11FSRZR UfgXFrwuukMZgTmaWQ+ElVmSeTPuzRDj7M1dHxE/7uxRgIYWqaXSzYje/DvYMbnE yPVQ2OlNpEYCoC6/Z1Z270lD0xQbLHtu3XZDZxQxqdJ+/972bw6mbbdkitzjsqcA 8MrtvvgKruGyG8vKc5ekSb235k15ux0/Uzd+FLRWGMPZJO88yoZIxRTT9zpdx3bX DGBTFwLmc9qSf5+6brHcFTIkyMJ3DLpOVeq6ThEtR7amPmW6JzzPHzOw6iUcFMl4 3K11wW/KR5eU3/DP4pYU3bw29ZUWk3WY4sPOX6XDCx37s37j2hiNfj26C8YdbA== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Steve Sistare Subject: [PATCH] tests/qtest: optimize qtest_get_machines Date: Fri, 19 Sep 2025 06:58:30 -0700 Message-Id: <1758290310-349623-1-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1117,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-09-19_01,2025-09-19_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 phishscore=0 bulkscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2508110000 definitions=main-2509190130 X-Authority-Analysis: v=2.4 cv=b9Oy4sGx c=1 sm=1 tr=0 ts=68cd6188 cx=c_pps a=OOZaFjgC48PWsiFpTAqLcw==:117 a=OOZaFjgC48PWsiFpTAqLcw==:17 a=yJojWOMRYYMA:10 a=yPCof4ZbAAAA:8 a=7je7RYxUaSp8zG-zYl4A:9 X-Proofpoint-GUID: QQsjYtS29HKNIRHOhe-qlIk62AInWtR8 X-Proofpoint-ORIG-GUID: QQsjYtS29HKNIRHOhe-qlIk62AInWtR8 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwOTE2MDIwMyBTYWx0ZWRfXynmCPwyjHzea z0JnV/e5WK7cOKO1Bj0KrJrC+3k+6kySIquiPih466zrfrHOgDCh89EeBEqErlKkAqYz+lwqz2K oZN1blobtNPM+BXjsF3E9VK0TX+knelUwqzirbX6CwC1gIX/8+NP07kxew0Shk2WA5QVdGKsa5k pq0Sgk3+gC3niN5T6yYTdikNzyKnGJ5/Z0QADFQ9SOainUasDulaV1nnSlK6OjXGcPqoiewFsW4 6xyWh0NiZFF1nK+Iu8QMVOCCAddWqdPVXjvbnQUZpjwX+eQpxu9MpkehaM6Na/Q2a/HMczIha2b sFjTauySXhoF+omXSosXJ9+/dnpxV7wuT35wVuMZIfsJSznseEhKMBpnJVotvbB915BvkVDODDW kM1KB9jk 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=205.220.165.32; envelope-from=steven.sistare@oracle.com; helo=mx0a-00069f02.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, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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: 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 @oracle.com) X-ZM-MESSAGEID: 1758290419996116600 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" qtest_get_machines returns the machines supported by the QEMU binary described by an environment variable and caches the result. If the next call to qtest_get_machines passes the same variable name, the cached result is returned, but if the name changes, the caching is defeated. To make caching more effective, remember the path of the QEMU binary instead. Different env vars, eg QTEST_QEMU_BINARY_SRC and QTEST_QEMU_BINARY_DST, usually resolve to the same path. Before the optimization, the test /x86_64/migration/precopy/unix/plain exec's QEMU and calls query-machines 3 times. After optimization, that only happens once. This does not significantly speed up the tests, but it reduces QTEST_LOG output, and launches fewer QEMU instances, making it easier to debug problems. Signed-off-by: Steve Sistare Reviewed-by: Fabiano Rosas --- tests/qtest/libqtest.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 94526b7..f3d4e08 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -1630,7 +1630,8 @@ static void qtest_free_machine_list(struct MachInfo *= machines) static struct MachInfo *qtest_get_machines(const char *var) { static struct MachInfo *machines; - static char *qemu_var; + static char *qemu_bin; + const char *new_qemu_bin; QDict *response, *minfo; QList *list; const QListEntry *p; @@ -1639,9 +1640,10 @@ static struct MachInfo *qtest_get_machines(const cha= r *var) QTestState *qts; int idx; =20 - if (g_strcmp0(qemu_var, var)) { - g_free(qemu_var); - qemu_var =3D g_strdup(var); + new_qemu_bin =3D qtest_qemu_binary(var); + if (g_strcmp0(qemu_bin, new_qemu_bin)) { + g_free(qemu_bin); + qemu_bin =3D g_strdup(new_qemu_bin); =20 /* new qemu, clear the cache */ qtest_free_machine_list(machines); @@ -1654,7 +1656,7 @@ static struct MachInfo *qtest_get_machines(const char= *var) =20 silence_spawn_log =3D !g_test_verbose(); =20 - qts =3D qtest_init_ext(qemu_var, "-machine none", NULL, true); + qts =3D qtest_init_ext(var, "-machine none", NULL, true); response =3D qtest_qmp(qts, "{ 'execute': 'query-machines' }"); g_assert(response); list =3D qdict_get_qlist(response, "return"); --=20 1.8.3.1