From nobody Mon Feb 9 01:47:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1560847133; cv=none; d=zoho.com; s=zohoarc; b=BJFdwjGqzojIVfaP8vZp0/RPpDYqM2EP4l2gedCbZANY6/WR0kCexmuWcN7Mbsf5vv83gBVxHQZib9h52KZ0K249SiGc6Ck6f87JqM2EowJBKH/MxNZ/KS/R5C2gVQb2LTPNZdrUeMGiOX510RiHzZFGXPUVo7/FyLLZ51lgbBg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560847133; 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:ARC-Authentication-Results; bh=pbnaBZ5wcXaGI2XdfhhQAZ43uPbUaCsAgbOWWiPkWR4=; b=kDvR1Ql+jDPSXJ25Gm/tQ0JQ/jOP1YRwqn4POWgsgsDFPHbiDCF/aoH5KXSznbw/1APQe/xbSboeuQrbYxKJlrFQFw0JT6+nawgHRRtPIZ3bEyjr/KsG7pVOqmT+Zz/3k0E5VB/pr8wm5u08emnV5apoDcuYnBbOHO3Hbq2GLH4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1560847133129405.10653161992366; Tue, 18 Jun 2019 01:38:53 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 633A03082A49; Tue, 18 Jun 2019 08:38:51 +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 294447E8ED; Tue, 18 Jun 2019 08:38:49 +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 BD70A206D2; Tue, 18 Jun 2019 08:38:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x5I8bXx5026027 for ; Tue, 18 Jun 2019 04:37:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4E64117131; Tue, 18 Jun 2019 08:37:33 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD14217129 for ; Tue, 18 Jun 2019 08:37:32 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 18 Jun 2019 10:37:25 +0200 Message-Id: <48d1e3f6956a01d4dde9169cc33fb73baa3e49fc.1560846912.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/3] qemu: qapi: Implement support for 'features' 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 18 Jun 2019 08:38:51 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Starting from version 4.1 qemu allows reporting 'features' for a given QAPI type object. This allows reporting support of fixes and additions which are otherwise invisible in the QAPI schema. Implement a possibility to query 'features' in the QAPI query strings. Signed-off-by: Peter Krempa --- src/qemu/qemu_qapi.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/qemu/qemu_qapi.c b/src/qemu/qemu_qapi.c index 4ed67b68bc..5e6dab4417 100644 --- a/src/qemu/qemu_qapi.c +++ b/src/qemu/qemu_qapi.c @@ -109,6 +109,38 @@ virQEMUQAPISchemaTraverse(const char *baseName, struct virQEMUQAPISchemaTraverseContext *ctxt); +/** + * @featurename: name of 'feature' field to select + * @elem: QAPI JSON entry for a type + * + * Looks for @featurename in the array of 'features' for given type passed= in + * via @elem. Returns the pointer to the JSON string representing @feature. + */ +static int +virQEMUQAPISchemaTraverseHasObjectFeature(const char *featurename, + virJSONValuePtr elem) +{ + virJSONValuePtr featuresarray; + virJSONValuePtr cur; + const char *curstr; + size_t i; + + if (!(featuresarray =3D virJSONValueObjectGetArray(elem, "features"))) + return 0; + + for (i =3D 0; i < virJSONValueArraySize(featuresarray); i++) { + if (!(cur =3D virJSONValueArrayGet(featuresarray, i)) || + !(curstr =3D virJSONValueGetString(cur))) + return -2; + + if (STREQ(featurename, curstr)) + return 1; + } + + return 0; +} + + static int virQEMUQAPISchemaTraverseObject(virJSONValuePtr cur, struct virQEMUQAPISchemaTraverseContext *c= txt) @@ -124,6 +156,13 @@ virQEMUQAPISchemaTraverseObject(virJSONValuePtr cur, if (modifier =3D=3D '^' || modifier =3D=3D '!') return 0; + if (modifier =3D=3D '$') { + if (virQEMUQAPISchemaTraverseContextHasNextQuery(ctxt)) + return -3; + + return virQEMUQAPISchemaTraverseHasObjectFeature(query, cur); + } + if (modifier =3D=3D '+') { obj =3D virQEMUQAPISchemaObjectGet("variants", query, "case", cur); } else { @@ -339,6 +378,8 @@ virQEMUQAPISchemaTraverse(const char *baseName, * '!basictype': returns true if previously selected type is of 'basicty= pe' * JSON type. Spported are 'null', 'string', 'number', 'va= lue', * 'int' and 'boolean. + * '$feature': returns true if the previously selected type supports 'fe= ature' + * ('feature' is in the 'features' array of given type) * * If the name of any (sub)attribute starts with non-alphabetical symbols = it * needs to be prefixed by a single space. --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list