From nobody Mon Feb 9 12:27:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1588186200; cv=none; d=zohomail.com; s=zohoarc; b=bOHc3St/WwzC3cO1h1kTgJjN5S8fRirjuhtUEVHdjej3p+CSWURUrttveVzDxIv1cftQU3zAMDq4K4pJ0XKkW9OocmMfCpw0JA3y5TbNBBg/tjOxDsVu6IxP8zCSi1X8UWe5+mkhQVxATPN5vRoi12kLvyD6MT92OdUH+YStN4Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588186200; 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=iZXXetlyJH3SCVoi18Hp58UoiXccf40HtNfGUiZ8QzU=; b=abTr44iLToYlbUnrvR3MicMsTUZq2efgC1qtaYN4T95Ip7GKyU+Jkh5iGYMCpeTRA/CSoJgwYXD/pSK2PzuOoEnJ3x0e0p6PQOqv/NptI0o6/wlyVyE4hMO+NjR2ezNQJ6U+DMTmnrS9MTFzyc2tXTaxO70tkogb8o1nGtjjC9g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1588186200108525.9049231861063; Wed, 29 Apr 2020 11:50:00 -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-487-XQpmlBt8PJusVGebZWOATw-1; Wed, 29 Apr 2020 14:49:57 -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 BAF5819200CE; Wed, 29 Apr 2020 18:49: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 948BB9323; Wed, 29 Apr 2020 18:49:51 +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 492C94CA95; Wed, 29 Apr 2020 18:49:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03TInU3V001568 for ; Wed, 29 Apr 2020 14:49:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 13D055C241; Wed, 29 Apr 2020 18:49:30 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 818135C1BE for ; Wed, 29 Apr 2020 18:49:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588186199; 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=iZXXetlyJH3SCVoi18Hp58UoiXccf40HtNfGUiZ8QzU=; b=GpSa32KSfZNBnkPeDNi3YuVF/i9H/M2EiF+xQn1uuqxA/7IGid91hVmXAHcGzQ8nTSw+cf 80OU2+9jBg8mdLZQWB/qEB2rrdSZS9398WZilfzqlbTFrMGFXUxrfwLd7Zx0d+3xoMFyzN zueSrVAq0bcxNB43J9XZKlbDvD60z4g= X-MC-Unique: XQpmlBt8PJusVGebZWOATw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/15] testQEMUSchemaValidate(Command): Allow skipping validation of deprecated fields Date: Wed, 29 Apr 2020 20:49:08 +0200 Message-Id: <118da9763a3a7c4a64bb0da81384f56ac0c009e4.1588185999.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 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" Some test cases are used to validate interactions with old qemu. We need to skip validation of deprecation with those once it will be added. In case of commands which were already replaced by code based on capabilities we can skip the full validation once the command is removed. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemublocktest.c | 14 +++++++------- tests/qemumonitorjsontest.c | 3 ++- tests/qemumonitortestutils.c | 5 ++++- tests/testutilsqemuschema.c | 17 +++++++++++++++-- tests/testutilsqemuschema.h | 3 +++ 5 files changed, 31 insertions(+), 11 deletions(-) diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 8001807552..604e71bba7 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -86,7 +86,7 @@ testBackingXMLjsonXML(const void *args) if (!data->legacy) { if (testQEMUSchemaValidate(backendprops, data->schemaroot, - data->schema, &debug) < 0) { + data->schema, false, &debug) < 0) { g_autofree char *debugmsg =3D virBufferContentAndReset(&debug); g_autofree char *debugprops =3D virJSONValueToString(backendpr= ops, true); @@ -168,7 +168,7 @@ testJSONtoJSON(const void *args) return -1; if (testQEMUSchemaValidate(jsonsrcout, data->schemaroot, - data->schema, &debug) < 0) { + data->schema, false, &debug) < 0) { g_autofree char *debugmsg =3D virBufferContentAndReset(&debug); VIR_TEST_VERBOSE("json does not conform to QAPI schema"); @@ -342,7 +342,7 @@ testQemuDiskXMLToPropsValidateSchema(const void *opaque) g_auto(virBuffer) debug =3D VIR_BUFFER_INITIALIZER; if (testQEMUSchemaValidate(data->images[i].formatprops, data->sche= maroot, - data->schema, &debug) < 0) { + data->schema, false, &debug) < 0) { g_autofree char *debugmsg =3D virBufferContentAndReset(&debug); g_autofree char *propsstr =3D virJSONValueToString(data->image= s[i].formatprops, true); VIR_TEST_VERBOSE("json does not conform to QAPI schema"); @@ -354,7 +354,7 @@ testQemuDiskXMLToPropsValidateSchema(const void *opaque) virBufferFreeAndReset(&debug); if (testQEMUSchemaValidate(data->images[i].storageprops, data->sch= emaroot, - data->schema, &debug) < 0) { + data->schema, false, &debug) < 0) { g_autofree char *debugmsg =3D virBufferContentAndReset(&debug); g_autofree char *propsstr =3D virJSONValueToString(data->image= s[i].storageprops, true); VIR_TEST_VERBOSE("json does not conform to QAPI schema"); @@ -366,7 +366,7 @@ testQemuDiskXMLToPropsValidateSchema(const void *opaque) virBufferFreeAndReset(&debug); if (testQEMUSchemaValidate(data->images[i].storagepropssrc, data->= schemaroot, - data->schema, &debug) < 0) { + data->schema, false, &debug) < 0) { g_autofree char *debugmsg =3D virBufferContentAndReset(&debug); g_autofree char *propsstr =3D virJSONValueToString(data->image= s[i].storagepropssrc, true); VIR_TEST_VERBOSE("json does not conform to QAPI schema"); @@ -544,7 +544,7 @@ testQemuImageCreate(const void *opaque) return -1; if (testQEMUSchemaValidate(formatprops, data->schemaroot, data->sc= hema, - &debug) < 0) { + false, &debug) < 0) { g_autofree char *debugmsg =3D virBufferContentAndReset(&debug); VIR_TEST_VERBOSE("blockdev-create format json does not conform= to QAPI schema"); VIR_TEST_DEBUG("json:\n%s\ndoes not match schema. Debug output= :\n %s", @@ -559,7 +559,7 @@ testQemuImageCreate(const void *opaque) return -1; if (testQEMUSchemaValidate(protocolprops, data->schemaroot, data->= schema, - &debug) < 0) { + false, &debug) < 0) { g_autofree char *debugmsg =3D virBufferContentAndReset(&debug); VIR_TEST_VERBOSE("blockdev-create protocol json does not confo= rm to QAPI schema"); VIR_TEST_DEBUG("json:\n%s\ndoes not match schema. Debug output= :\n %s", diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 60c816d1d1..fce88083b9 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2842,7 +2842,8 @@ testQAPISchemaValidate(const void *opaque) if (!(json =3D virJSONValueFromString(data->json))) goto cleanup; - if ((testQEMUSchemaValidate(json, schemaroot, data->schema, &debug) = =3D=3D 0) !=3D data->success) { + if ((testQEMUSchemaValidate(json, schemaroot, data->schema, false, + &debug) =3D=3D 0) !=3D data->success) { if (!data->success) VIR_TEST_VERBOSE("\nschema validation should have failed"); } else { diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 0d9427f1d1..6be7555dc0 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -554,7 +554,10 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonit= orTestPtr test, if (STREQ(cmdname, "device_add")) return 0; - if (testQEMUSchemaValidateCommand(cmdname, args, test->qapischema, &de= bug) < 0) { + if (testQEMUSchemaValidateCommand(cmdname, args, test->qapischema, + test->skipValidationDeprecated, + test->skipValidationRemoved, + &debug) < 0) { if (virTestGetDebug() =3D=3D 2) { g_autofree char *argstr =3D NULL; diff --git a/tests/testutilsqemuschema.c b/tests/testutilsqemuschema.c index b449171d15..f94a415b18 100644 --- a/tests/testutilsqemuschema.c +++ b/tests/testutilsqemuschema.c @@ -24,6 +24,7 @@ struct testQEMUSchemaValidateCtxt { virHashTablePtr schema; virBufferPtr debug; + bool allowDeprecated; }; @@ -488,10 +489,13 @@ int testQEMUSchemaValidate(virJSONValuePtr obj, virJSONValuePtr root, virHashTablePtr schema, + bool allowDeprecated, virBufferPtr debug) { struct testQEMUSchemaValidateCtxt ctxt =3D { .schema =3D schema, - .debug =3D debug }; + .debug =3D debug, + .allowDeprecated =3D allowD= eprecated }; + return testQEMUSchemaValidateRecurse(obj, root, &ctxt); } @@ -501,6 +505,9 @@ testQEMUSchemaValidate(virJSONValuePtr obj, * @command: command to validate * @arguments: arguments of @command to validate * @schema: hash table containing schema entries + * @allowDeprecated: don't fails schema validation if @command or one of @= arguments + * is deprecated + * @allowRemoved: skip validation fully if @command was not found * @debug: a virBuffer which will be filled with debug information if prov= ided * * Validates whether @command and it's @arguments conforms to the QAPI sch= ema @@ -508,16 +515,22 @@ testQEMUSchemaValidate(virJSONValuePtr obj, * -1 if it does not and -2 if there is a problem with the schema or with * internals. * + * @alllowRemoved should generally be used only if it's certain that there= 's a + * replacement of @command in place. + * * @debug is filled with information regarding the validation process */ int testQEMUSchemaValidateCommand(const char *command, virJSONValuePtr arguments, virHashTablePtr schema, + bool allowDeprecated, + bool allowRemoved G_GNUC_UNUSED, virBufferPtr debug) { struct testQEMUSchemaValidateCtxt ctxt =3D { .schema =3D schema, - .debug =3D debug }; + .debug =3D debug, + .allowDeprecated =3D allowD= eprecated }; g_autofree char *schemapatharguments =3D g_strdup_printf("%s/arg-type"= , command); g_autoptr(virJSONValue) emptyargs =3D NULL; virJSONValuePtr schemarootcommand; diff --git a/tests/testutilsqemuschema.h b/tests/testutilsqemuschema.h index e3a375b038..8b6803afda 100644 --- a/tests/testutilsqemuschema.h +++ b/tests/testutilsqemuschema.h @@ -26,12 +26,15 @@ int testQEMUSchemaValidate(virJSONValuePtr obj, virJSONValuePtr root, virHashTablePtr schema, + bool allowDeprecated, virBufferPtr debug); int testQEMUSchemaValidateCommand(const char *command, virJSONValuePtr arguments, virHashTablePtr schema, + bool allowDeprecated, + bool allowRemoved, virBufferPtr debug); virJSONValuePtr --=20 2.26.2