From nobody Sat May 4 11:47:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613750104; cv=none; d=zohomail.com; s=zohoarc; b=APokzKEzOGRXU9FpNsiJmeRKSudu9V99H12Cd5KpYG/iVuwUmX19SI7/BdaUgN/ZXITJJds3w+tgndrn9aJOAFweyfMSbVrdV+0j5FGeTsXOcKZn9wWOVHBc7tYTTUczxAPxMsY3e4vtHyZCO/l1/e+9C+mGe58IqIf1bpSUb1U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613750104; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0JliDZ3ls2bkrNSVr9/bLLPFjYc7JAu0/9JzduJQrSI=; b=S6UI3BqZDI0QpKtenmNdzN3E1bk+Ht1iWNnhg7ieOZ5+tZeVJKG8xP9WzjuIZAVG5CDnyR6Z5zHM5DX4hk6A/Yd4gFxBjhBJeRA2a19Atj17DMJq3dez8d6BMCsJm4OWSznCUzZ5cmXyf97ROtoP8CBByXoRLAPRXnzzzDGIK3o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1613750103830104.38373312346516; Fri, 19 Feb 2021 07:55:03 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-544-2SeWUn72NzOmGe8UtnsChw-1; Fri, 19 Feb 2021 10:54:58 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 517F0192FDA2; Fri, 19 Feb 2021 15:54:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0921F60BE5; Fri, 19 Feb 2021 15:54:53 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A4FE218095C7; Fri, 19 Feb 2021 15:54:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11JFrS1m007594 for ; Fri, 19 Feb 2021 10:53:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id E83201971D; Fri, 19 Feb 2021 15:53:28 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4DDD81970D for ; Fri, 19 Feb 2021 15:53:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613750101; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=0JliDZ3ls2bkrNSVr9/bLLPFjYc7JAu0/9JzduJQrSI=; b=br5n0TfYqSU+loJ93tT/lz/qIplj/kLCmRpzkWPfpG0bP3vXKEfMmEqQnAQvHVb9Jdr/eh SdZf61SYIaet3X6ip2JkMyF8VYnFeYG0RiMtCNnZLSB8X9vjnof9iNo1cuWy2wmrrPYsvG hAPKW8RCkJ+/ZDTXgJEWSzuyr2CbOVo= X-MC-Unique: 2SeWUn72NzOmGe8UtnsChw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/4] qemuxml2argvtest: Cache QAPI schema between tests Date: Fri, 19 Feb 2021 16:53:18 +0100 Message-Id: <8f5418f2981d4f240967197df5bc2ea47161544d.1613749935.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" It's quite wasteful to reparse the QAPI schema for each _CAPS_ test. Add a simple cache filled lazily by encountered schemas. The time saving on my box is quite significant: real 0m3.318s user 0m3.203s sys 0m0.107s vs real 0m2.223s user 0m2.134s sys 0m0.084s Signed-off-by: Peter Krempa --- tests/qemuxml2argvtest.c | 17 ++++++++++++++--- tests/testutilsqemu.h | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index db438c5466..647187404c 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -523,13 +523,22 @@ testCompareXMLToArgvValidateSchema(virQEMUDriverPtr d= rv, qemuDomainObjPrivatePtr priv =3D NULL; size_t nargs =3D 0; size_t i; - g_autoptr(GHashTable) schema =3D NULL; + GHashTable *schema =3D NULL; g_autoptr(virCommand) cmd =3D NULL; unsigned int parseFlags =3D info->parseFlags; bool netdevQAPIfied =3D false; - if (info->schemafile) - schema =3D testQEMUSchemaLoad(info->schemafile); + if (info->schemafile) { + /* lookup and insert into cache if not found */ + if (!g_hash_table_lookup_extended(info->qapiSchemaCache, + info->schemafile, + NULL, (void **) &schema)) { + schema =3D testQEMUSchemaLoad(info->schemafile); + g_hash_table_insert(info->qapiSchemaCache, + g_strdup(info->schemafile), + schema); + } + } /* comment out with line comment to enable schema checking for non _CA= PS tests if (!schema) @@ -779,6 +788,7 @@ mymain(void) int ret =3D 0; g_autofree char *fakerootdir =3D NULL; g_autoptr(GHashTable) capslatest =3D NULL; + g_autoptr(GHashTable) qapiSchemaCache =3D virHashNew((GDestroyNotify) = virHashFree); fakerootdir =3D g_strdup(FAKEROOTDIRTEMPLATE); @@ -872,6 +882,7 @@ mymain(void) static struct testQemuInfo info =3D { \ .name =3D _name, \ }; \ + info.qapiSchemaCache =3D qapiSchemaCache; \ if (testQemuInfoSetArgs(&info, capslatest, \ __VA_ARGS__, ARG_END) < 0) \ return EXIT_FAILURE; \ diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h index 0c6f0ea378..86ba69e96b 100644 --- a/tests/testutilsqemu.h +++ b/tests/testutilsqemu.h @@ -66,6 +66,7 @@ struct testQemuInfo { unsigned int parseFlags; virArch arch; char *schemafile; + GHashTable *qapiSchemaCache; }; virCapsPtr testQemuCapsInit(void); --=20 2.29.2 From nobody Sat May 4 11:47:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613750040; cv=none; d=zohomail.com; s=zohoarc; b=jZsvkD20Z4mVfcYyYDPUrpnZzpnHSgi4tJ8gIomPHK2edWjfmW3W1a1WFK8BllXkBjprrgDKoxmh+q0QOMXJxmBE4AufkstSEyF4n3pj9b3tlgl5sb/jGmf3dP5CKKcvB/yl/l+YeBOg0rcxl7EN8tItltYZNA9QQd5GKP+hSUs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613750040; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4be2RpRcgtfQdYPrTksKCvVvP/F2vA5G9NDkdPWQzW0=; b=Pdeuk55AI/ffAp8Pbd68G1Qw8xXM4J7ZSVW1muwsc8/imbbzdi+0O4/rrGyOA+0MnrmQiDVmEb+FoXlFaPfzdz7M6XFFhsKN+e6slbzAc/Rv+iuIoU3u4GwLdnlQ14Y069DWoy1JsJrGFSuTQEU4Tqsz10lJxbbYkFbpg01v4vo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1613750040070990.7773363493262; Fri, 19 Feb 2021 07:54:00 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-549-BYLm5T7ZNwGUSxeu5rdHpw-1; Fri, 19 Feb 2021 10:53:56 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CDDBBC7404; Fri, 19 Feb 2021 15:53:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 78CAF60BFA; Fri, 19 Feb 2021 15:53:50 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E5A4018095CB; Fri, 19 Feb 2021 15:53:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11JFrUXN007603 for ; Fri, 19 Feb 2021 10:53:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id 075E31971D; Fri, 19 Feb 2021 15:53:30 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 645951970D for ; Fri, 19 Feb 2021 15:53:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613750039; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=4be2RpRcgtfQdYPrTksKCvVvP/F2vA5G9NDkdPWQzW0=; b=SJDMGTqUD772RWACSz/6X3ZgqMtk4cbQoLyNFICBRiiLGszol9i9iZ/87OJAOu8P9AvwNU KchuYKg2LnOjPOvjxSJuUfZZ7ckCguoAUf2xA9a+pPqBS9VU6U0eDDTQHNA8SmyYPEhS+Y kVrTRXiH4yUTmEmr/9rBow/FfQmjnGI= X-MC-Unique: BYLm5T7ZNwGUSxeu5rdHpw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/4] testCompareXMLToArgvValidateSchema: Improve and fix helper for testing everything Date: Fri, 19 Feb 2021 16:53:19 +0100 Message-Id: <7669306eb68d5c35b877c107c95ee2a337d222ac.1613749935.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The schema validator has a comment which allows checking all xml2argv input files for schema validity by forcing the latest schema onto files which don't have any schema. Fix it so that it works properly with the caching introduced in previous commit. Signed-off-by: Peter Krempa --- tests/qemuxml2argvtest.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 647187404c..2d538bee9c 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -528,6 +528,11 @@ testCompareXMLToArgvValidateSchema(virQEMUDriverPtr dr= v, unsigned int parseFlags =3D info->parseFlags; bool netdevQAPIfied =3D false; + /* comment out with line comment to enable schema checking for non _CA= PS tests + if (!info->schemafile) + info->schemafile =3D testQemuGetLatestCapsForArch(virArchToString= (info->arch), "replies"); + // */ + if (info->schemafile) { /* lookup and insert into cache if not found */ if (!g_hash_table_lookup_extended(info->qapiSchemaCache, @@ -540,11 +545,6 @@ testCompareXMLToArgvValidateSchema(virQEMUDriverPtr dr= v, } } - /* comment out with line comment to enable schema checking for non _CA= PS tests - if (!schema) - schema =3D testQEMUSchemaLoadLatest(virArchToString(info->arch)); - // */ - if (!schema) return 0; --=20 2.29.2 From nobody Sat May 4 11:47:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613750107; cv=none; d=zohomail.com; s=zohoarc; b=YjXQvWqLCjSjbQ7o5v4fvZgoldZW6YUZeiOsrnq++72bduVPHCtjBbvT0fQUYv+DMFYj/0/12vGomkO/nlU57dM/HLS8e7zq4aYUPSzZt+JBy9F7iIhiS1gvPTz3RKEcZLLSk1US+OB1yDbJ4HdDsk8eOmOo8Au2sVJ+ilBRX+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613750107; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uHaQPG1ZwNPnW1VdqQCA116T5dbqOwERO8qpsN+GjO8=; b=Z1LAnm1/k9j4KUBj3w7ktPkWYJ9d5F2Aab2BRCuUDmbdPkgc23oEL5upJBuKBZTTeeBWIYsK4AtENWLipS6D7Ps0klFM5DevW2PXLrRDfI0Z+5v6ILBVcRuacihkGYh/UzUaJm3VH09QS1MVT9Pl2Wee4RJWxefWIFWcfgm0XGk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1613750106856941.0605354725935; Fri, 19 Feb 2021 07:55:06 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-198-XXEcBIp5NBesf2YekXUF5A-1; Fri, 19 Feb 2021 10:55:03 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BFD351020C23; Fri, 19 Feb 2021 15:54:57 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 997325D9C6; Fri, 19 Feb 2021 15:54:57 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6079B4EE7F; Fri, 19 Feb 2021 15:54:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11JFrVJu007611 for ; Fri, 19 Feb 2021 10:53:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id 177D61971D; Fri, 19 Feb 2021 15:53:31 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 70AD71970D for ; Fri, 19 Feb 2021 15:53:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613750105; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=uHaQPG1ZwNPnW1VdqQCA116T5dbqOwERO8qpsN+GjO8=; b=cQq0onYR77pl5xpwYAgE6wrdlcz/gVOfI3naNnRP/NN8hc4p5VMSo2qWCBQCx6igCpyE0p uPbyQ1uFoPujX6ugLIAwNX6CU3P2bSLMYqQbd2/DQTNbRA6qpcJqs8AIFGfNcPzPUdN9YM dCfAN1EOmi+VQ6IO5+OGOkBPyF9hOUw= X-MC-Unique: XXEcBIp5NBesf2YekXUF5A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/4] testQemuInfoSetArgs: Use curly braces in else section Date: Fri, 19 Feb 2021 16:53:20 +0100 Message-Id: <3bdd1efd957c9311c4b0c460fc18241df0d7866e.1613749935.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa --- tests/testutilsqemu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index c2cf3be9ac..a96c9d487a 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -779,8 +779,10 @@ testQemuInfoSetArgs(struct testQemuInfo *info, if (STREQ(capsver, "latest")) { capsfile =3D g_strdup(virHashLookup(capslatest, capsarch)); stripmachinealiases =3D true; - } else capsfile =3D g_strdup_printf("%s/caps_%s.%s.xml", - TEST_QEMU_CAPS_PATH, capsver, ca= psarch); + } else { + capsfile =3D g_strdup_printf("%s/caps_%s.%s.xml", + TEST_QEMU_CAPS_PATH, capsver, capsa= rch); + } if (!(qemuCaps =3D qemuTestParseCapabilitiesArch(info->arch, capsf= ile))) goto cleanup; --=20 2.29.2 From nobody Sat May 4 11:47:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1613750043648163.00737599579543; Fri, 19 Feb 2021 07:54:03 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-392-vLduj5SDOByZkLQa9AF1cg-1; Fri, 19 Feb 2021 10:53:59 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B8761C740D; Fri, 19 Feb 2021 15:53:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 955F35D9D2; Fri, 19 Feb 2021 15:53:54 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5620418095CE; Fri, 19 Feb 2021 15:53:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11JFrWTf007621 for ; Fri, 19 Feb 2021 10:53:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id 196CD1971D; Fri, 19 Feb 2021 15:53:32 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 77AFA1970D for ; Fri, 19 Feb 2021 15:53:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613750042; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=2FAjQ7BX8N6FESEscNXqjEPj+xTu5ifW8yGVygQtA3U=; b=H756ISnP5YuN1jf9+yxiMQeYoKDvWlkPHKtB1h8hUOO+7re4Dzi73wJvTehjpc6Y/1fw9o 7EYd7uDIA1XaDSG9eJl1ny03mJcmaKHSSLW8szRkgUWzmyJ2Orq0p/l0FUUVy8ZlrOinrL fGmahiCVH8EMfDmahjbfC+QFaWLIRT0= X-MC-Unique: vLduj5SDOByZkLQa9AF1cg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/4] qemu*xml2*test: Cache capabilities between tests Date: Fri, 19 Feb 2021 16:53:21 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Invoking the XML parser every time is quite expensive. Since we have a deep copy function for 'virQEMUCapsPtr' object, we can cache the parsed results lazily. This brings significant speedup to qemuxml2argvtest: real 0m2.234s user 0m2.140s sys 0m0.089s vs. real 0m1.161s user 0m1.087s sys 0m0.072s qemuxml2xmltest benefits too: real 0m0.879s user 0m0.801s sys 0m0.071s vs. real 0m0.466s user 0m0.424s sys 0m0.040s Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma --- tests/qemustatusxml2xmltest.c | 3 ++- tests/qemuxml2argvtest.c | 3 ++- tests/qemuxml2xmltest.c | 3 ++- tests/testutilsqemu.c | 18 +++++++++++++++--- tests/testutilsqemu.h | 1 + 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/tests/qemustatusxml2xmltest.c b/tests/qemustatusxml2xmltest.c index 67a070c986..2b2c409cba 100644 --- a/tests/qemustatusxml2xmltest.c +++ b/tests/qemustatusxml2xmltest.c @@ -73,6 +73,7 @@ mymain(void) g_autofree char *fakerootdir =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; g_autoptr(GHashTable) capslatest =3D NULL; + g_autoptr(GHashTable) capscache =3D virHashNew(virObjectFreeHashData); g_autoptr(virConnect) conn =3D NULL; capslatest =3D testQemuGetLatestCaps(); @@ -109,7 +110,7 @@ mymain(void) static struct testQemuInfo info =3D { \ .name =3D _name, \ }; \ - if (testQemuInfoSetArgs(&info, capslatest, \ + if (testQemuInfoSetArgs(&info, capscache, capslatest, \ ARG_QEMU_CAPS, QEMU_CAPS_LAST, \ ARG_END) < 0 || \ qemuTestCapsCacheInsert(driver.qemuCapsCache, info.qemuCaps) <= 0) { \ diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 2d538bee9c..d6d707cd24 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -789,6 +789,7 @@ mymain(void) g_autofree char *fakerootdir =3D NULL; g_autoptr(GHashTable) capslatest =3D NULL; g_autoptr(GHashTable) qapiSchemaCache =3D virHashNew((GDestroyNotify) = virHashFree); + g_autoptr(GHashTable) capscache =3D virHashNew(virObjectFreeHashData); fakerootdir =3D g_strdup(FAKEROOTDIRTEMPLATE); @@ -883,7 +884,7 @@ mymain(void) .name =3D _name, \ }; \ info.qapiSchemaCache =3D qapiSchemaCache; \ - if (testQemuInfoSetArgs(&info, capslatest, \ + if (testQemuInfoSetArgs(&info, capscache, capslatest, \ __VA_ARGS__, ARG_END) < 0) \ return EXIT_FAILURE; \ testInfoSetPaths(&info, _suffix); \ diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 5cd945f28f..01ac5886f2 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -85,6 +85,7 @@ mymain(void) g_autofree char *fakerootdir =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; g_autoptr(GHashTable) capslatest =3D NULL; + g_autoptr(GHashTable) capscache =3D virHashNew(virObjectFreeHashData); g_autoptr(virConnect) conn =3D NULL; capslatest =3D testQemuGetLatestCaps(); @@ -130,7 +131,7 @@ mymain(void) static struct testQemuInfo info =3D { \ .name =3D _name, \ }; \ - if (testQemuInfoSetArgs(&info, capslatest, \ + if (testQemuInfoSetArgs(&info, capscache, capslatest, \ __VA_ARGS__, \ ARG_END) < 0 || \ qemuTestCapsCacheInsert(driver.qemuCapsCache, info.qemuCaps) <= 0) { \ diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index a96c9d487a..1dcf5caf6a 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -681,6 +681,7 @@ testQemuCapsIterate(const char *suffix, int testQemuInfoSetArgs(struct testQemuInfo *info, + GHashTable *capscache, GHashTable *capslatest, ...) { va_list argptr; @@ -773,6 +774,7 @@ testQemuInfoSetArgs(struct testQemuInfo *info, if (!qemuCaps && capsarch && capsver) { bool stripmachinealiases =3D false; + virQEMUCapsPtr cachecaps =3D NULL; info->arch =3D virArchFromString(capsarch); @@ -784,11 +786,21 @@ testQemuInfoSetArgs(struct testQemuInfo *info, TEST_QEMU_CAPS_PATH, capsver, capsa= rch); } - if (!(qemuCaps =3D qemuTestParseCapabilitiesArch(info->arch, capsf= ile))) + if (!g_hash_table_lookup_extended(capscache, capsfile, NULL, (void= **) &cachecaps)) { + if (!(qemuCaps =3D qemuTestParseCapabilitiesArch(info->arch, c= apsfile))) + goto cleanup; + + if (stripmachinealiases) + virQEMUCapsStripMachineAliases(qemuCaps); + + cachecaps =3D qemuCaps; + + g_hash_table_insert(capscache, g_strdup(capsfile), g_steal_poi= nter(&qemuCaps)); + } + + if (!(qemuCaps =3D virQEMUCapsNewCopy(cachecaps))) goto cleanup; - if (stripmachinealiases) - virQEMUCapsStripMachineAliases(qemuCaps); info->flags |=3D FLAG_REAL_CAPS; /* provide path to the replies file for schema testing */ diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h index 86ba69e96b..e1b386f234 100644 --- a/tests/testutilsqemu.h +++ b/tests/testutilsqemu.h @@ -110,6 +110,7 @@ int testQemuCapsIterate(const char *suffix, void *opaque); int testQemuInfoSetArgs(struct testQemuInfo *info, + GHashTable *capscache, GHashTable *capslatest, ...); void testQemuInfoClear(struct testQemuInfo *info); --=20 2.29.2