From nobody Fri May 10 03:51:29 2024 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=1632145812; cv=none; d=zohomail.com; s=zohoarc; b=nGYbFDth6PmRmHjXHUzVFskA1lCqB96l7Em9qDSR69YX9lq/pzDUeciowrroxsFSaWWsA1d5Vop8/8Vsjvs//vtIBuefE2UIFKpOW16hIIH2hPXxMIZ/RHP/kNPunWC0aJQ0AqyZGM6xJjSSIJ8woHoprHoeUag6UY2GR65mzR8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632145812; 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=9tQhYzyCta2lJc6rL1QdlCx531ERouoFpunoOk935MQ=; b=DCGBcpPzkfl3B+Vdkwwm6aRklMJs2pM1Urh6rt5js3Pjx5dNeYtjaag8sIk2GGqfxOPB3gf4OOai13fyXyEi84brLlNBAHjlB6MTpPbnf1CivXUlX00nHM+LRNNh3XujPXN4fuDpj6HdcS2oVobzWycyalkN+wR/U44KMgkyPm0= 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 1632145812040542.4795692904269; Mon, 20 Sep 2021 06:50:12 -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-16-XLpwwdjtODe6kC66Zk__ug-1; Mon, 20 Sep 2021 09:50:09 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EA757101AFB4; Mon, 20 Sep 2021 13:49:58 +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 C96475C1BB; Mon, 20 Sep 2021 13:49:58 +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 94D9A4EA38; Mon, 20 Sep 2021 13:49:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18KDnohB009265 for ; Mon, 20 Sep 2021 09:49:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 609886D98F; Mon, 20 Sep 2021 13:49:50 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF2961346F for ; Mon, 20 Sep 2021 13:49:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632145811; 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=9tQhYzyCta2lJc6rL1QdlCx531ERouoFpunoOk935MQ=; b=aJMxAQ7qocjRH/tKSX4hKqU2jZi30TsPAoBaQC/JeeTLfEZuErFhBC5HAsA7Z9vDd7d/lw rrxfXic1qFEOcYH7EVLiQuCIM2AhajWfmJG8EP9/dCVbYG5AQ4XWl4BV53uhms/Yai+FYt bMTcXlMDkebxeHvbe5MCmNU1EPscIQc= X-MC-Unique: XLpwwdjtODe6kC66Zk__ug-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [RFC PATCH 1/7] virQEMUQAPISchemaTraverseEnum: Move helper variables into loop Date: Mon, 20 Sep 2021 15:49:32 +0200 Message-Id: <80fcb06a57a7640bad9524ac32952125cda47c0d.1632145487.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.16 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: 1632145813289100005 Content-Type: text/plain; charset="utf-8" Move them closer to where they are actually used. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_qapi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_qapi.c b/src/qemu/qemu_qapi.c index 36b184b226..165ecf1180 100644 --- a/src/qemu/qemu_qapi.c +++ b/src/qemu/qemu_qapi.c @@ -243,8 +243,6 @@ virQEMUQAPISchemaTraverseEnum(virJSONValue *cur, { const char *query =3D virQEMUQAPISchemaTraverseContextNextQuery(ctxt); virJSONValue *values; - virJSONValue *enumval; - const char *value; size_t i; if (query[0] !=3D '^') @@ -259,6 +257,9 @@ virQEMUQAPISchemaTraverseEnum(virJSONValue *cur, return -2; for (i =3D 0; i < virJSONValueArraySize(values); i++) { + virJSONValue *enumval; + const char *value; + if (!(enumval =3D virJSONValueArrayGet(values, i)) || !(value =3D virJSONValueGetString(enumval))) continue; --=20 2.31.1 From nobody Fri May 10 03:51:29 2024 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=1632145801; cv=none; d=zohomail.com; s=zohoarc; b=nLil3ivAXNW1VZHQP2z6NjqvL7i445BYc/jvBCHXjv2vhzDAlbpQeEfpSZk3VI/Oio4WlIQEXvOzTMtiob0Xvrg+p/XW/PxXxIFVBZ4GCXaysb4nM4dvrzTkcJ9PlfqsKIN2N9zKmzAvGViUpMFqInf7/f/JOF+wRWvMoKahjlQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632145801; 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=IXCuE9/cAoFaF+/KfqOQK1nZ1wO+yALSJ6rneHruwVQ=; b=PTT8RMHB8z8bcVfMnOJUk6Ak3wWQQ/oeZdd8R0q2ZqAr/GjViyhW3/URBVpv2zZUlYWAfZ/DSQev/2l6J2GlIjRhW3Smfj20Q3COnYhBW77vy6Yf/LrSOMGYOpgR6jhsbipCpdMbtTO8CBvvBgAfAceHfSO14U5OYYMAmqpW5ME= 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 163214580186144.029610770617865; Mon, 20 Sep 2021 06:50:01 -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-122-1HONAVUqNhyJ3L4siCA6Mg-1; Mon, 20 Sep 2021 09:49:58 -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 E03678145EF; Mon, 20 Sep 2021 13:49:53 +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 8F64A1017CF1; Mon, 20 Sep 2021 13:49: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 3DBB44E9F4; Mon, 20 Sep 2021 13:49:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18KDnpCF009272 for ; Mon, 20 Sep 2021 09:49:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 78EA16D992; Mon, 20 Sep 2021 13:49:51 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE5B71346F for ; Mon, 20 Sep 2021 13:49:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632145800; 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=IXCuE9/cAoFaF+/KfqOQK1nZ1wO+yALSJ6rneHruwVQ=; b=DvPEa7JCkjhXyNvYQlPY0mie4wdHPW3wHdXnzpFvqRsg9bRwoJg8eLwGPaa33pUtd6ZMBV Wli5pf8XEmewbh673E9u6cEU9IR3LbSz3OmvZ37zGr+PNjoeQBcWT6ZRXKYym9rEteyoaQ bmNrXMBRH5X6lJWw1+dFWSVzaUCan68= X-MC-Unique: 1HONAVUqNhyJ3L4siCA6Mg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [RFC PATCH 2/7] virQEMUQAPISchemaTraverseEnum: Use the modern 'members' array Date: Mon, 20 Sep 2021 15:49:33 +0200 Message-Id: <1bebc39301cc9e558e96a9ffb1edbeeded38a06b.1632145487.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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 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: 1632145803604100003 Content-Type: text/plain; charset="utf-8" Starting from QEMU-6.2 enum members are reported as an array of objects under new name "values" so that extra data can be reported for each member. Modify the code so that we prefer 'members' and skip 'values' completely if we've used 'members'. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_qapi.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/qemu/qemu_qapi.c b/src/qemu/qemu_qapi.c index 165ecf1180..790f7c0fee 100644 --- a/src/qemu/qemu_qapi.c +++ b/src/qemu/qemu_qapi.c @@ -243,6 +243,7 @@ virQEMUQAPISchemaTraverseEnum(virJSONValue *cur, { const char *query =3D virQEMUQAPISchemaTraverseContextNextQuery(ctxt); virJSONValue *values; + virJSONValue *members; size_t i; if (query[0] !=3D '^') @@ -253,6 +254,22 @@ virQEMUQAPISchemaTraverseEnum(virJSONValue *cur, query++; + /* qemu-6.2 added a "members" array superseding "values" */ + if ((members =3D virJSONValueObjectGetArray(cur, "members"))) { + for (i =3D 0; i < virJSONValueArraySize(members); i++) { + virJSONValue *member =3D virJSONValueArrayGet(members, i); + const char *name; + + if (!member || !(name =3D virJSONValueObjectGetString(member, = "name"))) + return -2; + + if (STREQ(name, query)) + return 1; + } + + return 0; + } + if (!(values =3D virJSONValueObjectGetArray(cur, "values"))) return -2; --=20 2.31.1 From nobody Fri May 10 03:51:29 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=1632145811; cv=none; d=zohomail.com; s=zohoarc; b=XOY0Kgf29uAAD2mLvpF/1q6wR15L/P3V0zwbekv3RLDUVNXDo0LPIL4znkbHOnvpEJ0gX6/SSXaa2NWr2c9+D5YJzc1CxfoMFrRbhogO28yGxQtEUZGKf1Fx59XE9kKNJ0girCL2Wx++tAHDC45e2aNHcgQ/DcoaS2iQPUSAMkU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632145811; 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=mCfb+UPFMnvMD52O/b9NWT2WMcnAGlMydFHu7Q0tX6A=; b=W24lx0y5ZV71PTF52um2QCjUOVnKYXuMoWughO/ZNA53yMfGlZj9F/EBkwTRZdxeIzR4l3Q/MiNgzuOd78mLUmkExat+AZ2CVXTloJ5MdvFIvaDQzawaKFcobt5U+Hiz2KGVr/xthFohXgBEkz7coSW8B3uTPaehGPHoqNAPft8= 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 1632145811511746.5816694087904; Mon, 20 Sep 2021 06:50:11 -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-323-Ncxs36cdPtmzHiKdy397Yg-1; Mon, 20 Sep 2021 09:50:09 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 21F721922036; Mon, 20 Sep 2021 13:49:59 +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 F2CA71F42E; Mon, 20 Sep 2021 13:49:58 +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 C3E431806D00; Mon, 20 Sep 2021 13:49:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18KDnqtX009282 for ; Mon, 20 Sep 2021 09:49:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 88D776A257; Mon, 20 Sep 2021 13:49:52 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id E8F501346F for ; Mon, 20 Sep 2021 13:49:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632145810; 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=mCfb+UPFMnvMD52O/b9NWT2WMcnAGlMydFHu7Q0tX6A=; b=cS0DTqLMuwluWc1iLwwDdleaSSUwo5LUkX/sX7U1qWUVjTMlk3PmWRg0lKboHa4cjN1i/p A2vZdl92mBpA2F4kIhRCp8IZL1DXN7bozOqb3Jr9y18ybHLvDVUbEX62gKczPTsQ3ER7TA Bt4aIk9zg8++35UEQWpCsruHoy99vE0= X-MC-Unique: Ncxs36cdPtmzHiKdy397Yg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [RFC PATCH 3/7] virQEMUQAPISchemaTraverseEnum: Allow query of enume type features Date: Mon, 20 Sep 2021 15:49:34 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.23 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: 1632145813024100001 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 From nobody Fri May 10 03:51:29 2024 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=1632145803; cv=none; d=zohomail.com; s=zohoarc; b=kNNk0LV0n/58Gw+WGzs3lwwMbChduEjO6XCjQuwUN2DoLz1+fIiMS3/sS35mJrtc2EsAxCp1eChfQS+IzQJ2jir8f3/3zWT/9N+xoagSc7RKwbAk56+8XGTIC47ResrvFPtcUokXs55xxoxDh1k7xU2nORJuz82jNgPLgaKaImg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632145803; 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=kUDOcC66IkrcWrTP88tCICw0lTOYNj2fG5wzId05Yec=; b=ikmjA3NqYr1gFPeRDJ9t6eMQgbRfs+eD/22PNtECfKwfjJQyGk44bUD59kwv2G73fgGWo1y5RO+5fgKVXftbhI1J8NYyYUiKwAkeDPwRQGCfRbgmgS1KBH/K/1j33FuOb/owvADxm5deiD2glc7vvpTPrkogI5ToJa6ggBQbjRo= 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 16321458031461022.1766228347084; Mon, 20 Sep 2021 06:50:03 -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-202-ci5A5DQeNzi_9W_Qy14PGg-1; Mon, 20 Sep 2021 09:50:00 -0400 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 B53A8101AFAB; Mon, 20 Sep 2021 13:49:55 +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 94F715D9D5; Mon, 20 Sep 2021 13:49:55 +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 588121805986; Mon, 20 Sep 2021 13:49:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18KDnrbA009293 for ; Mon, 20 Sep 2021 09:49:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9E61F6D988; Mon, 20 Sep 2021 13:49:53 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id F10141346F for ; Mon, 20 Sep 2021 13:49:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632145802; 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=kUDOcC66IkrcWrTP88tCICw0lTOYNj2fG5wzId05Yec=; b=FN+bdwCxsFRdL/ODsP5LkQRePj4zhKbQc62cBEgpwM0MFbD9UesJvazA0r3e8hHT5vbpjK MS68njTF2ldFcrx6AVZuBTsBfr9+JfpxjPfuQmx15v6YxeXoUCuwmKteQJZtE8BT/vfdVW LPPYoqh6mbdUawxQLhPHhiZz5BEKAV0= X-MC-Unique: ci5A5DQeNzi_9W_Qy14PGg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [RFC PATCH 4/7] testQEMUSchemaValidateEnum: Refactor logic to simplify switching to new QMP schema format Date: Mon, 20 Sep 2021 15:49:35 +0200 Message-Id: <3e377c7e272f55c629554782989d9f659d8f5b93.1632145487.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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) X-ZM-MESSAGEID: 1632145803749100005 Content-Type: text/plain; charset="utf-8" QEMU-6.2 is reporting enum values in the new 'members' array which we'll be switching to. Rewrite the logic so that adding the new checker is more straightforward. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tests/testutilsqemuschema.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/tests/testutilsqemuschema.c b/tests/testutilsqemuschema.c index f6347231a8..e75345b582 100644 --- a/tests/testutilsqemuschema.c +++ b/tests/testutilsqemuschema.c @@ -319,7 +319,6 @@ testQEMUSchemaValidateEnum(virJSONValue *obj, { const char *objstr; virJSONValue *values =3D NULL; - virJSONValue *value; size_t i; if (virJSONValueGetType(obj) !=3D VIR_JSON_TYPE_STRING) { @@ -329,24 +328,24 @@ testQEMUSchemaValidateEnum(virJSONValue *obj, objstr =3D virJSONValueGetString(obj); - if (!(values =3D virJSONValueObjectGetArray(root, "values"))) { - virBufferAsprintf(ctxt->debug, "ERROR: missing enum values in sche= ma '%s'", - NULLSTR(virJSONValueObjectGetString(root, "name"= ))); - return -2; - } - - for (i =3D 0; i < virJSONValueArraySize(values); i++) { - value =3D virJSONValueArrayGet(values, i); + if ((values =3D virJSONValueObjectGetArray(root, "values"))) { + for (i =3D 0; i < virJSONValueArraySize(values); i++) { + virJSONValue *value =3D virJSONValueArrayGet(values, i); - if (STREQ_NULLABLE(objstr, virJSONValueGetString(value))) { - virBufferAsprintf(ctxt->debug, "'%s' OK", NULLSTR(objstr)); - return 0; + if (STREQ_NULLABLE(objstr, virJSONValueGetString(value))) { + virBufferAsprintf(ctxt->debug, "'%s' OK", NULLSTR(objstr)); + return 0; + } } + + virBufferAsprintf(ctxt->debug, "ERROR: enum value '%s' is not in s= chema", + NULLSTR(objstr)); + return -1; } - virBufferAsprintf(ctxt->debug, "ERROR: enum value '%s' is not in schem= a", - NULLSTR(objstr)); - return -1; + virBufferAsprintf(ctxt->debug, "ERROR: missing enum values in schema '= %s'", + NULLSTR(virJSONValueObjectGetString(root, "name"))); + return -2; } --=20 2.31.1 From nobody Fri May 10 03:51:29 2024 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=1632145811; cv=none; d=zohomail.com; s=zohoarc; b=STD1vtbuSd8dySyD7SvAyDMCJ7bnaHoKjt433L4lswtZCa6z0a8EhckYQB9eNA2nLRIJ8NcFaBkcsP6hmwLj7lCVSMNs47zUSMEVS1UKp2G2JwIXlSyFCVdTp8ggjtiZnAiNr1RCrMzqZT/6RPUiEZY/kuWaYsyasqdmmLqosB0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632145811; 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=Cp72JGhTOPs4YUqJJmhViGHXtM0h5pRqfTscJ8SFrOo=; b=Z4PSw4QatboTAbj77b26gMKiOyoGqgMB763CINa+p1EG6lpv20mbnuVgidnMLuDCiQUkaXx9wvbhwXfIrL70yw3QaJmHBa7RRFYKs5NDwAJdO6iXtRIjfJEkfODEbZmgRA4fJfYRcn/+c0fU8qk0luUFgcm6k52Iy/KctuSm2qE= 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 1632145811638231.3811385298976; Mon, 20 Sep 2021 06:50:11 -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-240-_Pf-2hYsM2SnsWbQOVabew-1; Mon, 20 Sep 2021 09:50:08 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DC674A40CA; Mon, 20 Sep 2021 13:50:01 +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 BAA4269FAD; Mon, 20 Sep 2021 13:50:01 +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 7F1A24EA3A; Mon, 20 Sep 2021 13:50:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18KDnsHi009302 for ; Mon, 20 Sep 2021 09:49:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id B014E1346F; Mon, 20 Sep 2021 13:49:54 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1AF856D98B for ; Mon, 20 Sep 2021 13:49:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632145810; 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=Cp72JGhTOPs4YUqJJmhViGHXtM0h5pRqfTscJ8SFrOo=; b=WGl5jYMcrtk/layPa//N7UADDS7AVJ/mScDWvdqFNF50vmw5n06D4k+uFJMJ+iK7TSbeTl 8WptfwtcvQLleWM8IaF462NvmsldcFPOQun6jh86m2v/W0ZMsFxpvntfTM1zdgxU953ss4 GjKOrWpWc8eEMW4qOb+J5j6VW6JmlTM= X-MC-Unique: _Pf-2hYsM2SnsWbQOVabew-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [RFC PATCH 5/7] testQEMUSchemaValidateEnum: Use new 'members' for 'enum' meta type Date: Mon, 20 Sep 2021 15:49:36 +0200 Message-Id: <0504b2499c40457ce28e88e23e7746495c2d78f8.1632145487.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.11 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: 1632145813039100002 Content-Type: text/plain; charset="utf-8" Switch to the new more featured way to report enum members which will also allow us to detect use of deprecated members. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tests/testutilsqemuschema.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/testutilsqemuschema.c b/tests/testutilsqemuschema.c index e75345b582..7398c73ccc 100644 --- a/tests/testutilsqemuschema.c +++ b/tests/testutilsqemuschema.c @@ -319,6 +319,7 @@ testQEMUSchemaValidateEnum(virJSONValue *obj, { const char *objstr; virJSONValue *values =3D NULL; + virJSONValue *members =3D NULL; size_t i; if (virJSONValueGetType(obj) !=3D VIR_JSON_TYPE_STRING) { @@ -328,6 +329,22 @@ testQEMUSchemaValidateEnum(virJSONValue *obj, objstr =3D virJSONValueGetString(obj); + /* qemu-6.2 added a "members" array superseding "values" */ + if ((members =3D virJSONValueObjectGetArray(root, "members"))) { + for (i =3D 0; i < virJSONValueArraySize(members); i++) { + virJSONValue *member =3D virJSONValueArrayGet(members, i); + + if (STREQ_NULLABLE(objstr, virJSONValueObjectGetString(member,= "name"))) { + virBufferAsprintf(ctxt->debug, "'%s' OK", NULLSTR(objstr)); + return 0; + } + } + + virBufferAsprintf(ctxt->debug, "ERROR: enum value '%s' is not in s= chema", + NULLSTR(objstr)); + return -1; + } + if ((values =3D virJSONValueObjectGetArray(root, "values"))) { for (i =3D 0; i < virJSONValueArraySize(values); i++) { virJSONValue *value =3D virJSONValueArrayGet(values, i); --=20 2.31.1 From nobody Fri May 10 03:51:29 2024 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=1632145815; cv=none; d=zohomail.com; s=zohoarc; b=eOfBEIqWd/dW9M87uKmkoMrS/f5Y4ie9KDy+/MP87ITMI1dlyCwINdSxbbM9S7qLTVC9tpVnpkyrhS0q4CkbQ+FBcn/HF3Kl4cbiXbsmU60Za6jJWPRKaGvI9XLkKakv7Fkn6TI3z9Veb8XwzbqhC85iuxy4f48jRuZs0VotlVs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632145815; 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=iqooL7El3nDKfwFnxrQKNicbL7FrZ0dRjYlFoPc66DE=; b=ZzL+moGUPZsYoseVjHiVlCosxJZROrzWsFotKMwv+tVczW0kgjBodw5SHpkKx0+vZf2SsmpP+8fCQNi3Lk8KJl+CJL0b4iUHcIXtbatgWeKVfnq1B5ZFFst7T16tKMhn2de4CL5DbEM4wWBheztqi3PqW92Fvuf+vvVbeBfWbPE= 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 1632145815894229.59283755623846; Mon, 20 Sep 2021 06:50:15 -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-324-bwXqj456NuWfuQP1MpVcbA-1; Mon, 20 Sep 2021 09:50:13 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 71A59100D686; Mon, 20 Sep 2021 13:50:06 +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 48A2C1F456; Mon, 20 Sep 2021 13:50:06 +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 10E151806D04; Mon, 20 Sep 2021 13:50:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18KDo1mu009323 for ; Mon, 20 Sep 2021 09:50:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9AE3669FAD; Mon, 20 Sep 2021 13:50:01 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id F19F56D990 for ; Mon, 20 Sep 2021 13:49:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632145814; 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=iqooL7El3nDKfwFnxrQKNicbL7FrZ0dRjYlFoPc66DE=; b=I3T6b8OYegUGOByDe1a9v9uyNrz4YpxTrQijiTjuEQibZQ0rwAon+2U3VyI9gyRtfSB+4B kgHz/IIrz4d4pVcPVM6275eh8ixaZCdspzMz8KuP0gEq5Rsb8WPUPuQdQFszvPvgypnO8/ OLmE04OVX52l0cHLvqYGyxyXJJZ2l84= X-MC-Unique: bwXqj456NuWfuQP1MpVcbA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [RFC PATCH 6/7] testQEMUSchemaValidateDeprecated: Move to the top Date: Mon, 20 Sep 2021 15:49:37 +0200 Message-Id: <084e870d73424c3048b961b9d001c875039e7750.1632145487.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.23 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: 1632145817150100001 Content-Type: text/plain; charset="utf-8" Move the function to the top of the file so other functions placed towards the top will be able to reuse it. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tests/testutilsqemuschema.c | 82 ++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/tests/testutilsqemuschema.c b/tests/testutilsqemuschema.c index 7398c73ccc..38dd0e14bc 100644 --- a/tests/testutilsqemuschema.c +++ b/tests/testutilsqemuschema.c @@ -28,6 +28,47 @@ struct testQEMUSchemaValidateCtxt { }; +static int +testQEMUSchemaValidateDeprecated(virJSONValue *root, + const char *name, + struct testQEMUSchemaValidateCtxt *ctxt) +{ + virJSONValue *features =3D virJSONValueObjectGetArray(root, "features"= ); + size_t nfeatures; + size_t i; + + if (!features) + return 0; + + nfeatures =3D virJSONValueArraySize(features); + + for (i =3D 0; i < nfeatures; i++) { + virJSONValue *cur =3D virJSONValueArrayGet(features, i); + const char *curstr; + + if (!cur || + !(curstr =3D virJSONValueGetString(cur))) { + virBufferAsprintf(ctxt->debug, "ERROR: features of '%s' are ma= lformed", name); + return -2; + } + + if (STREQ(curstr, "deprecated")) { + if (ctxt->allowDeprecated) { + virBufferAsprintf(ctxt->debug, "WARNING: '%s' is deprecate= d", name); + if (virTestGetVerbose()) + g_fprintf(stderr, "\nWARNING: '%s' is deprecated\n", n= ame); + return 0; + } else { + virBufferAsprintf(ctxt->debug, "ERROR: '%s' is deprecated"= , name); + return -1; + } + } + } + + return 0; +} + + static int testQEMUSchemaValidateRecurse(virJSONValue *obj, virJSONValue *root, @@ -461,47 +502,6 @@ testQEMUSchemaValidateAlternate(virJSONValue *obj, } -static int -testQEMUSchemaValidateDeprecated(virJSONValue *root, - const char *name, - struct testQEMUSchemaValidateCtxt *ctxt) -{ - virJSONValue *features =3D virJSONValueObjectGetArray(root, "features"= ); - size_t nfeatures; - size_t i; - - if (!features) - return 0; - - nfeatures =3D virJSONValueArraySize(features); - - for (i =3D 0; i < nfeatures; i++) { - virJSONValue *cur =3D virJSONValueArrayGet(features, i); - const char *curstr; - - if (!cur || - !(curstr =3D virJSONValueGetString(cur))) { - virBufferAsprintf(ctxt->debug, "ERROR: features of '%s' are ma= lformed", name); - return -2; - } - - if (STREQ(curstr, "deprecated")) { - if (ctxt->allowDeprecated) { - virBufferAsprintf(ctxt->debug, "WARNING: '%s' is deprecate= d", name); - if (virTestGetVerbose()) - g_fprintf(stderr, "\nWARNING: '%s' is deprecated\n", n= ame); - return 0; - } else { - virBufferAsprintf(ctxt->debug, "ERROR: '%s' is deprecated"= , name); - return -1; - } - } - } - - return 0; -} - - static int testQEMUSchemaValidateRecurse(virJSONValue *obj, virJSONValue *root, --=20 2.31.1 From nobody Fri May 10 03:51:29 2024 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=1632145838; cv=none; d=zohomail.com; s=zohoarc; b=RKXyGp+CFOIv/tOcFE50Ku4aS9IlM2IyPC4hrtDZkEbd57nv2jfgRLnPab9HpDKE4T1ZbWDt2/8rX9qlSvuWfuG7x1XKWJQ5jFGk6LZYrMJxwS2Y2DwPt2/w4IBQPc73qgq1S50rnL0YZwXl2VUGLHUAtGcfo1tsb8S7cd+c0T8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632145838; 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=hRqElu1ZeUS7NWm8RIjtNQ90CMDn42zp2+KD3JcTC3s=; b=Ao7zhNmiqP4w8A9KecJBrVQh7e3U4OE57+O1P+z5gMdyr1a7lpaom0ByPCWqA+pEs70c+bFBmtk1hAQ/sOFldqpCNSDC82Exo4NOg+aAXQA6mKceu/D8j0RNkWLQdjOqQ4js7Wwh0dYn7oFoI/KKYMqQif5eC37Z8eythaPSIUU= 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 1632145838057746.6147944436495; Mon, 20 Sep 2021 06:50:38 -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-594-hZm727tQN8qL1hVrjjpJLg-1; Mon, 20 Sep 2021 09:50:35 -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 925EFA40C1; Mon, 20 Sep 2021 13:50:30 +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 7622F10246ED; Mon, 20 Sep 2021 13:50:30 +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 474A51806D04; Mon, 20 Sep 2021 13:50:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18KDoSSq009585 for ; Mon, 20 Sep 2021 09:50:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 93FE218B5E; Mon, 20 Sep 2021 13:50:28 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id F2FA96D98C for ; Mon, 20 Sep 2021 13:50:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632145837; 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=hRqElu1ZeUS7NWm8RIjtNQ90CMDn42zp2+KD3JcTC3s=; b=eIPWuEKJpA1hJdEWt60Umt1HQAekujp8oOQL258kKJcA8j70z/H5yyPNcGnCBDgtwPxFHY HnnUyqxQVyq7ID8G8qjVCZ6aVgJsOXtlqq6v+CarwZlT9vajATI6MpP7fJBceoCTVlNRE+ EV6hUtd+SsQ9TqGoMeKSFr0djBbKU+g= X-MC-Unique: hZm727tQN8qL1hVrjjpJLg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [RFC PATCH 7/7] testQEMUSchemaValidateEnum: Validate deprecated members Date: Mon, 20 Sep 2021 15:49:38 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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 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: 1632145838618100001 Content-Type: text/plain; charset="utf-8" Starting from QEMU-6.2 enum members can be deprecated. Add support to the validator. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tests/testutilsqemuschema.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/testutilsqemuschema.c b/tests/testutilsqemuschema.c index 38dd0e14bc..b4b5eb1ed6 100644 --- a/tests/testutilsqemuschema.c +++ b/tests/testutilsqemuschema.c @@ -376,6 +376,12 @@ testQEMUSchemaValidateEnum(virJSONValue *obj, virJSONValue *member =3D virJSONValueArrayGet(members, i); if (STREQ_NULLABLE(objstr, virJSONValueObjectGetString(member,= "name"))) { + int rc; + + /* the new 'members' array allows us to check deprecations= */ + if ((rc =3D testQEMUSchemaValidateDeprecated(member, objst= r, ctxt)) < 0) + return rc; + virBufferAsprintf(ctxt->debug, "'%s' OK", NULLSTR(objstr)); return 0; } --=20 2.31.1