From nobody Mon Feb 9 06:50:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1589556617; cv=none; d=zohomail.com; s=zohoarc; b=HT538Cdlo2bC/p8R6PE5AkTiHza2NdE/OnK3xKIvaxxpRkpsOmOzdAmU9tdbxiO3JlJZYrrZmDMTfa/f8blRHeb10cHsVD7lgraYeKEM+yp8+xZAzACVHahcNS7UpltB4Q1zAmwsQMHseV/R3ofREE7e9HIncGCxL1VzojcpY8Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589556617; 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=Ok62GrsAj9e2Jm7Gt3wAC6BFLAXeu0NKyewYvGsL/5M=; b=ieAZEtfzVkohu2MW/g7e3JcYtT1yLJOtgPUdxg5TGM/4VB8OdcMfj+uILwCOo/J030+KThB2yhFoHL5Ocm1glucupMPYLBqgUY3VwiBz5E+2uxzE8LNa6iCh1OK41G3GpNXxRdKwNxQ+/4RTr8ICqbuukXQz0Frc+Q4k7vbvOi0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1589556617701285.1450293435488; Fri, 15 May 2020 08:30:17 -0700 (PDT) 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-285-_VL0FxIRM8yt9a8ZnFKiMA-1; Fri, 15 May 2020 11:29:34 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 75CFC1054F9B; Fri, 15 May 2020 15:29:28 +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 5086F100164D; Fri, 15 May 2020 15:29:28 +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 1DBAC1805312; Fri, 15 May 2020 15:29:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 04FFTOwq011461 for ; Fri, 15 May 2020 11:29:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4554A5D9F5; Fri, 15 May 2020 15:29:24 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id B0D865D9D7 for ; Fri, 15 May 2020 15:29:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589556615; 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=Ok62GrsAj9e2Jm7Gt3wAC6BFLAXeu0NKyewYvGsL/5M=; b=VpDvsbpJ/o4BOCFNeL15rCOzmXZblkUoa2B8gU/HUgowApaujrCl24XVVCFHrame1pxA2I 9oodw7GKrRgLpDjKF5ai5kolfZaTlzrwb6sArN0fg4pjk9IN+rdLbgvGzwF+dgYODAlWOP PG3ik8WQt4Pp6fL0TaTcnbEKNs1vsgQ= X-MC-Unique: _VL0FxIRM8yt9a8ZnFKiMA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 20/21] testutilsqemuschema: Allow loading non-latest schema Date: Fri, 15 May 2020 17:28:06 +0200 Message-Id: <964b76cacc0c2d29cc3065f5e66ac984555f562b.1589556042.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.84 on 10.5.11.22 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" Add testQEMUSchemaLoad and refactor internals so that we can load the QMP schema from an arbitrary caps replies file. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake --- tests/testutilsqemuschema.c | 64 ++++++++++++++++++++++++------------- tests/testutilsqemuschema.h | 3 ++ 2 files changed, 45 insertions(+), 22 deletions(-) diff --git a/tests/testutilsqemuschema.c b/tests/testutilsqemuschema.c index 060a5d7054..d9b55fd787 100644 --- a/tests/testutilsqemuschema.c +++ b/tests/testutilsqemuschema.c @@ -607,37 +607,23 @@ testQEMUSchemaValidateCommand(const char *command, } -/** - * testQEMUSchemaGetLatest: - * - * Returns the schema data as the qemu monitor would reply from the latest - * replies file used for qemucapabilitiestest for the x86_64 architecture. - */ -virJSONValuePtr -testQEMUSchemaGetLatest(const char* arch) +static virJSONValuePtr +testQEMUSchemaLoadReplies(const char *filename) { - g_autofree char *capsLatestFile =3D NULL; - g_autofree char *capsLatest =3D NULL; + g_autofree char *caps =3D NULL; char *schemaReply; char *end; g_autoptr(virJSONValue) reply =3D NULL; virJSONValuePtr schema =3D NULL; - if (!(capsLatestFile =3D testQemuGetLatestCapsForArch(arch, "replies")= )) { - VIR_TEST_VERBOSE("failed to find latest caps replies"); + if (virTestLoadFile(filename, &caps) < 0) return NULL; - } - VIR_TEST_DEBUG("replies file: '%s'", capsLatestFile); - - if (virTestLoadFile(capsLatestFile, &capsLatest) < 0) - return NULL; - - if (!(schemaReply =3D strstr(capsLatest, "\"execute\": \"query-qmp-sch= ema\"")) || + if (!(schemaReply =3D strstr(caps, "\"execute\": \"query-qmp-schema\""= )) || !(schemaReply =3D strstr(schemaReply, "\n\n")) || !(end =3D strstr(schemaReply + 2, "\n\n"))) { VIR_TEST_VERBOSE("failed to find reply to 'query-qmp-schema' in '%= s'", - capsLatestFile); + filename); return NULL; } @@ -646,13 +632,13 @@ testQEMUSchemaGetLatest(const char* arch) if (!(reply =3D virJSONValueFromString(schemaReply))) { VIR_TEST_VERBOSE("failed to parse 'query-qmp-schema' reply from '%= s'", - capsLatestFile); + filename); return NULL; } if (!(schema =3D virJSONValueObjectStealArray(reply, "return"))) { VIR_TEST_VERBOSE("missing qapi schema data in reply in '%s'", - capsLatestFile); + filename); return NULL; } @@ -660,6 +646,28 @@ testQEMUSchemaGetLatest(const char* arch) } +/** + * testQEMUSchemaGetLatest: + * + * Returns the schema data as the qemu monitor would reply from the latest + * replies file used for qemucapabilitiestest for the x86_64 architecture. + */ +virJSONValuePtr +testQEMUSchemaGetLatest(const char *arch) +{ + g_autofree char *capsLatestFile =3D NULL; + + if (!(capsLatestFile =3D testQemuGetLatestCapsForArch(arch, "replies")= )) { + VIR_TEST_VERBOSE("failed to find latest caps replies"); + return NULL; + } + + VIR_TEST_DEBUG("replies file: '%s'", capsLatestFile); + + return testQEMUSchemaLoadReplies(capsLatestFile); +} + + virHashTablePtr testQEMUSchemaLoadLatest(const char *arch) { @@ -670,3 +678,15 @@ testQEMUSchemaLoadLatest(const char *arch) return virQEMUQAPISchemaConvert(schema); } + + +virHashTablePtr +testQEMUSchemaLoad(const char *filename) +{ + virJSONValuePtr schema; + + if (!(schema =3D testQEMUSchemaLoadReplies(filename))) + return NULL; + + return virQEMUQAPISchemaConvert(schema); +} diff --git a/tests/testutilsqemuschema.h b/tests/testutilsqemuschema.h index acedb77677..c90a6b626d 100644 --- a/tests/testutilsqemuschema.h +++ b/tests/testutilsqemuschema.h @@ -42,3 +42,6 @@ testQEMUSchemaGetLatest(const char* arch); virHashTablePtr testQEMUSchemaLoadLatest(const char *arch); + +virHashTablePtr +testQEMUSchemaLoad(const char *filename); --=20 2.26.2