From nobody Mon Feb 9 06:26:35 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1688478034; cv=none; d=zohomail.com; s=zohoarc; b=HO5QiF43ZZ6mPul8DSCvNGtj/1gDdn9N0RpNBWMuWVMEQoNx0hOrPXOTdVOZU5+3sjv7oHJvs+g66Pq/4kZDW3kAUY77LXP6WcPrYidr9DmewyV2aVW9lTkXkpx6PDLVe9TzVkQyI/Hv70tAfgJCdFGuy8hrXic2ICXWKBSgSDk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688478034; 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=KD8HYdZICXIiwFC5nNeri0INJQI+6r+KaftclFFCUoM=; b=Rul9T+wR4RbcUGKD9vpPpDnN/UDXo8YJ/9zQK+xw9Z2pUHo0yR2GXuWVxr93Q7xMWEpJdIxqXiKD0L5p6gHmxV+ljp3HywKFQFJkVYuOO0qCzMk8g7zYCh8IOD9YOR/Cw9o3v1I3xFxW58QwVDvc2ha+tevNCa2vQbkKMjVrt6I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1688478034447414.45954128234825; Tue, 4 Jul 2023 06:40:34 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-6-_7jHaPs4OFmgoRBdjyeqPg-1; Tue, 04 Jul 2023 09:40:30 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E811C10504BE; Tue, 4 Jul 2023 13:40:26 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D68EB40C2073; Tue, 4 Jul 2023 13:40:26 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C9CBE19465A0; Tue, 4 Jul 2023 13:40:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 64AE61946588 for ; Tue, 4 Jul 2023 13:40:25 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4578F4021526; Tue, 4 Jul 2023 13:40:25 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF0794021523 for ; Tue, 4 Jul 2023 13:40:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688478033; 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=KD8HYdZICXIiwFC5nNeri0INJQI+6r+KaftclFFCUoM=; b=IFfMxUIKB3J6g0xYezxoAHVjUnvPchj61sZl+KVWFJfdyIg99/sIIFLDeHdy9dUfj45Gkr c/wcHUFKKK/D86gC0Uph1Glf3g8l04O4uo0lDFa/KfnbflFs3iHE8DdVLCDaZ1KSaCanTY +XuUfHutNel1V2NMpqKPJRyIJaF7X3c= X-MC-Unique: _7jHaPs4OFmgoRBdjyeqPg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/10] testutilsqemu: Introduce 'testQemuInsertRealCaps' helper Date: Tue, 4 Jul 2023 15:40:14 +0200 Message-ID: <1eb1dea962ecd4d4ec2a00e689015356f33b1edf.1688477951.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1688478036598100008 Content-Type: text/plain; charset="utf-8" 'testQemuInsertRealCaps' looks up and inserts real capabilities into the capability 'file cache' for testing purposes. Effectively this helper replaces following steps: 1) testQemuGetRealCaps 2) virFileCacheClear 3) qemuTestCapsCacheInsert This helper doesn't copy the capabilities that are borrowed from it's internal cache thus they must not be modified afterwards in contrast to the above steps. The use of this helper is in simple tests which require some form of capabilities to parse a definition but don't care about doctoring them in any way. Signed-off-by: Peter Krempa --- tests/testutilsqemu.c | 45 +++++++++++++++++++++++++++++++++++++++++++ tests/testutilsqemu.h | 10 ++++++++++ 2 files changed, 55 insertions(+) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 0a42e59c59..e0b58b1d5d 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -976,6 +976,51 @@ testQemuGetRealCaps(const char *arch, } +/** + * testQemuInsertRealCaps: + * + * @arch: architecture to fetch caps for + * @version: qemu version to fetch caps for ("latest" for fetching the lat= est version from @capsLatestFiles) + * @variant: capabilities variant to fetch caps for + * @capsLatestFiles: hash table containing latest version of capabilities = for the @arch+@variant tuple + * @capsCache: hash table filled with the cache of capabilities + * @schemaCache: hash table for caching QMP schemas (may be NULL, see belo= w) + * @schema: Filled with the QMP schema (hash table) (may be NULL, see belo= w) + * + * Fetches and inserts into the test capability cache the appropriate virQ= EMUCaps + * for the @arch+@version+@variant tuple. Note that the data inserted into + * the cache is borrowed from the cache thus must not be further modified. + * + * If @schemaCache and @schema are non-NULL, @schema is filled with with a + * pointer (borrowed from the cache) to the hash table representing the QE= MU QMP + * schema used for validation of the monitor traffic. + */ +int +testQemuInsertRealCaps(virFileCache *cache, + const char *arch, + const char *version, + const char *variant, + GHashTable *capsLatestFiles, + GHashTable *capsCache, + GHashTable *schemaCache, + GHashTable **schema) +{ + virQEMUCaps *cachedcaps; + + virFileCacheClear(cache); + + if (!(cachedcaps =3D testQemuGetRealCapsInternal(arch, version, varian= t, + capsLatestFiles, capsCac= he, + schemaCache, schema))) + return -1; + + if (qemuTestCapsCacheInsertData(cache, virQEMUCapsGetBinary(cachedcaps= ), cachedcaps) < 0) + return -1; + + return 0; +} + + int testQemuInfoInitArgs(struct testQemuInfo *info) { diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h index 1e6611daa3..e0d116336e 100644 --- a/tests/testutilsqemu.h +++ b/tests/testutilsqemu.h @@ -160,4 +160,14 @@ testQemuGetRealCaps(const char *arch, GHashTable *capsCache, GHashTable *schemaCache, GHashTable **schema); + +int +testQemuInsertRealCaps(virFileCache *cache, + const char *arch, + const char *version, + const char *variant, + GHashTable *capsLatestFiles, + GHashTable *capsCache, + GHashTable *schemaCache, + GHashTable **schema); #endif --=20 2.41.0