From nobody Mon Feb 9 07:06:21 2026 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=1635511194; cv=none; d=zohomail.com; s=zohoarc; b=H8oFJHThKeplqFU2Swm37/PgXwp5+JDfDnVJg98nuc7Ql4u0vQxPwlBaqpA1pY5oVrlRpgyPQxEEwTERUFlp8hsdrMBaCOPmTI6v1TXNC0eAJs4KWstGng6zglK0ZH4pyAlS689M+4PxoYOtZSLkHxdLsnc7EPLd7IgZ4EOjpfU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635511194; 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=HOSC10W9TuERLjHwnwh4MvwekJ0CrpE+BVOfphXutbY=; b=LACVaNqdq4pyYt9nQCOTblW27wbLzglVC3U5dueSjclkTvosb+r6/ut3HMhqZC66ArMUQ8ILFS3UQAUs4IqY+Jal2y0rtZaWaXUFB2mHM484PZfQn8LOIXEsO8NyiPQ35/ck7VlH9nJq78Hb4ctCBrqGAPa7ICLW91xravc28aE= 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) 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 1635511194145178.77284245179794; Fri, 29 Oct 2021 05:39:54 -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-319-aDozVh-AMlyLpk39rSCRzQ-1; Fri, 29 Oct 2021 08:39:51 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 928718030AF; Fri, 29 Oct 2021 12:39:45 +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 75B3060854; Fri, 29 Oct 2021 12:39:45 +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 11C584EA39; Fri, 29 Oct 2021 12:39:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19TCddV5005808 for ; Fri, 29 Oct 2021 08:39:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 22DF62B0B8; Fri, 29 Oct 2021 12:39:39 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 77CEF60854 for ; Fri, 29 Oct 2021 12:39:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635511193; 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=HOSC10W9TuERLjHwnwh4MvwekJ0CrpE+BVOfphXutbY=; b=btA8JADY2rRz1vi/EfuDqyRD0D60hGT7/Gj6CsO4SGAfc9xPkTqqdE1sC6cM2PVLH4CXPR QpXdhozKQ5Y1dS+vcwQ5dEI9I6D1FfgFFXUR/ZwcKzDjiuCaly5MkXiUJYCejIrt11CNq7 ICdsRtuhsM3t2VQSoRZ0daf8+3o7i0k= X-MC-Unique: aDozVh-AMlyLpk39rSCRzQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 4/8] virQEMUQAPISchemaTraverseEnum: Allow query of enume type features Date: Fri, 29 Oct 2021 14:39:21 +0200 Message-Id: <44b803da0e0c840297a319801f833e83f28f9e42.1635511106.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.13 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) X-ZM-MESSAGEID: 1635511194966100003 Content-Type: text/plain; charset="utf-8" QEMU-6.2 added feature flags for enum types. Add support for querying them into our QMP schema query language. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_qapi.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_qapi.c b/src/qemu/qemu_qapi.c index 790f7c0fee..426db8d30d 100644 --- a/src/qemu/qemu_qapi.c +++ b/src/qemu/qemu_qapi.c @@ -242,6 +242,7 @@ virQEMUQAPISchemaTraverseEnum(virJSONValue *cur, struct virQEMUQAPISchemaTraverseContext *ctx= t) { const char *query =3D virQEMUQAPISchemaTraverseContextNextQuery(ctxt); + const char *featurequery =3D NULL; virJSONValue *values; virJSONValue *members; size_t i; @@ -249,8 +250,16 @@ virQEMUQAPISchemaTraverseEnum(virJSONValue *cur, if (query[0] !=3D '^') return 0; - if (virQEMUQAPISchemaTraverseContextHasNextQuery(ctxt)) - return -3; + if (virQEMUQAPISchemaTraverseContextHasNextQuery(ctxt)) { + /* we might have a query for a feature flag of an enum value */ + featurequery =3D virQEMUQAPISchemaTraverseContextNextQuery(ctxt); + + if (*featurequery !=3D '$' || + virQEMUQAPISchemaTraverseContextHasNextQuery(ctxt)) + return -3; + + featurequery++; + } query++; @@ -263,13 +272,21 @@ virQEMUQAPISchemaTraverseEnum(virJSONValue *cur, if (!member || !(name =3D virJSONValueObjectGetString(member, = "name"))) return -2; - if (STREQ(name, query)) + if (STREQ(name, query)) { + if (featurequery) + return virQEMUQAPISchemaTraverseHasObjectFeature(featu= requery, member); + return 1; + } } return 0; } + /* old-style "values" array doesn't have feature flags so any query is= necessarily false */ + if (featurequery) + return 0; + if (!(values =3D virJSONValueObjectGetArray(cur, "values"))) return -2; @@ -439,7 +456,8 @@ virQEMUQAPISchemaTraverse(const char *baseName, * * The above types can be chained arbitrarily using slashes to construct a= ny * path into the schema tree, booleans must be always the last component a= s they - * don't refer to a type. + * don't refer to a type. An exception is querying feature of an enum value + * (.../^enumval/$featurename) which is allowed. * * Returns 1 if @query was found in @schema filling @entry if non-NULL, 0 = if * @query was not found in @schema and -1 on other errors along with an ap= propriate --=20 2.31.1