From nobody Fri May 3 02:16:29 2024 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=1588186190; cv=none; d=zohomail.com; s=zohoarc; b=CzuIb0ZLHP00WyaMNMJM+dUH6SInff0KQVoRJlVVDWvZyMxUzGlgoshPlQaiFR3yv62L9RzhPo6tTJkceIed3DYZS2nPKguL9f7dDEYlxUZaoAcu4O2NdEsvSOUxUp1ccSC34bShlnAPuLSt9BA5QDrN6T7ZYTNNYwlQQGk//ow= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588186190; 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=bYalocg6QFBi7G/yo59YhUNcWbJZPU4fXstgB3wldoI=; b=Y50ekW4oX+xbzMJael/N6OlRe+XkjEkQeC8i3/q4phU1y+Rd9NhMKz0IU/ufw/wabPnXNsaZ0Z8mL0B7nAt6JsCV2vi6QYm0kX1ovh4GQJWBrGSq+NX3deGbYblnykktuJWamjXh/V9nbzvr0/AKam5bJaEz8BSSYVrCaaA1jCk= 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 1588186190455566.9879246359587; Wed, 29 Apr 2020 11:49:50 -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-249-5g4owAdHMg-BOXCqjo-j4w-1; Wed, 29 Apr 2020 14:49:47 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2DB43107ACF2; Wed, 29 Apr 2020 18:49:41 +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 0698C5D70B; Wed, 29 Apr 2020 18:49:41 +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 BB1CC4CAA0; Wed, 29 Apr 2020 18:49:40 +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 03TInLXI001486 for ; Wed, 29 Apr 2020 14:49:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9FDA65C241; Wed, 29 Apr 2020 18:49:21 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 197935C1BE for ; Wed, 29 Apr 2020 18:49:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588186189; 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=bYalocg6QFBi7G/yo59YhUNcWbJZPU4fXstgB3wldoI=; b=aKJkGFgjDvFgjpyLHo2D+PxrNkzgz9rTBzZHGx6UJpDHKYBq3CoTwgQtBPL3QyIKz6QSEv 9KavSnfpjmLIcQexkzMNKArZbl13NsivIm8ICLED2z8gGhzfs2/YTd5w1GpcqYYPgq4hrc yjlEM7OkTv+ncm95jhaCJFwwytOZVwM= X-MC-Unique: 5g4owAdHMg-BOXCqjo-j4w-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/15] testQemuHotplugCpuPrepare: Allow unused monitor commands only on failure Date: Wed, 29 Apr 2020 20:49:01 +0200 Message-Id: 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.79 on 10.5.11.15 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" Only tests expected to fail should allow unused commads as the normal tests will consume all of them. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemuhotplugtest.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 9a215ab303..849e7e7636 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -409,6 +409,7 @@ testQemuHotplugCpuDataFree(struct testQemuHotplugCpuDat= a *data) static struct testQemuHotplugCpuData * testQemuHotplugCpuPrepare(const char *test, bool modern, + bool fail, virHashTablePtr qmpschema) { qemuDomainObjPrivatePtr priv =3D NULL; @@ -453,7 +454,8 @@ testQemuHotplugCpuPrepare(const char *test, &driver, data->vm, qm= pschema))) goto error; - qemuMonitorTestAllowUnusedCommands(data->mon); + if (fail) + qemuMonitorTestAllowUnusedCommands(data->mon); priv->mon =3D qemuMonitorTestGetMonitor(data->mon); virObjectUnlock(priv->mon); @@ -528,7 +530,7 @@ testQemuHotplugCpuGroup(const void *opaque) int rc; if (!(data =3D testQemuHotplugCpuPrepare(params->test, params->modern, - params->schema))) + params->fail, params->schema))) return -1; rc =3D qemuDomainSetVcpusInternal(&driver, data->vm, data->vm->def, @@ -565,7 +567,7 @@ testQemuHotplugCpuIndividual(const void *opaque) int rc; if (!(data =3D testQemuHotplugCpuPrepare(params->test, params->modern, - params->schema))) + params->fail, params->schema))) return -1; if (virBitmapParse(params->cpumap, &map, 128) < 0) --=20 2.26.2 From nobody Fri May 3 02:16:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 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=1588186193; cv=none; d=zohomail.com; s=zohoarc; b=Wi7/T2lWp2M/LRqVMYa2edDx2lwBikxA0seB7ChQsRvobDup+xEjEiOTWHBNvqsbg+A4P7iKMPfc6LBhqKYha1MnOq+hFNSfG+VCt34k5kX3fxyFoWle5tBu+ZlyVKIjJwvkOKqNldbWNW/3rPJ6169gy/BSIUarLchC4sJsffc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588186193; 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=Dxk/8KXgBFnOhk+PgC+VGguit7f50w6T4EQcZdTHCqk=; b=jh34hVCRz/LAbSItHDK+aD5FTl+3XwX3lFInDVG+phZrNVP0uB7EKKDP/wONTn/XIb5wlpy4r7M5Or1yj4sDypM51/foMqpYukGDrXzEmY6iWkk8ovB8dvyLSYxfkPo9p80SvN1h7qZQXSGhtBXOCwT/eMbv2AFxstU/TKY2A2Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1588186193510737.0712642932856; Wed, 29 Apr 2020 11:49:53 -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-10-y6nHK_BzMDiIz5hnMmszkA-1; Wed, 29 Apr 2020 14:49:49 -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 95E308018AC; Wed, 29 Apr 2020 18:49:44 +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 6F54C600E5; Wed, 29 Apr 2020 18:49:44 +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 211831809561; Wed, 29 Apr 2020 18:49:44 +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 03TInOp7001506 for ; Wed, 29 Apr 2020 14:49:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 636F25C1BE; Wed, 29 Apr 2020 18:49:24 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC8855C241 for ; Wed, 29 Apr 2020 18:49:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588186192; 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=Dxk/8KXgBFnOhk+PgC+VGguit7f50w6T4EQcZdTHCqk=; b=hJLNjvVlcqnivE0Z7gJUSj1iZe/ZBQrVxQODfaUAI8TsfcLUcpmZe377Lo6Fw435wQtGY5 GniEoMM5cMndt+TH5KUpzzAovZsibAxcPiiXE4ymPJJimQUXp8xEWd4hcR4I8svdfC+czc ekTAIYn4tU4eQgQnyHPnqJhjG3IO1U8= X-MC-Unique: y6nHK_BzMDiIz5hnMmszkA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/15] testutilsqemuschema: Introduce testQEMUSchemaValidateCommand Date: Wed, 29 Apr 2020 20:49:02 +0200 Message-Id: <824326dfd4bef77ef16a4eee50f9a699017a7fe2.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.79 on 10.5.11.11 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" The new helper splits out all steps necessary to validate a QMP command against the schema. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/testutilsqemuschema.c | 44 +++++++++++++++++++++++++++++++++++++ tests/testutilsqemuschema.h | 6 +++++ 2 files changed, 50 insertions(+) diff --git a/tests/testutilsqemuschema.c b/tests/testutilsqemuschema.c index 7b82ff27b2..60409a0f91 100644 --- a/tests/testutilsqemuschema.c +++ b/tests/testutilsqemuschema.c @@ -517,6 +517,50 @@ testQEMUSchemaValidate(virJSONValuePtr obj, } +/** + * testQEMUSchemaValidateCommand: + * @command: command to validate + * @arguments: arguments of @command to validate + * @schema: hash table containing schema entries + * @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 + * passed in via @schema. Returns 0, if the command and args matches @sche= ma, + * -1 if it does not and -2 if there is a problem with the schema or with + * internals. + * + * @debug is filled with information regarding the validation process + */ +int +testQEMUSchemaValidateCommand(const char *command, + virJSONValuePtr arguments, + virHashTablePtr schema, + virBufferPtr debug) +{ + g_autofree char *schemapatharguments =3D g_strdup_printf("%s/arg-type"= , command); + g_autoptr(virJSONValue) emptyargs =3D NULL; + virJSONValuePtr schemarootcommand; + virJSONValuePtr schemarootarguments; + + if (virQEMUQAPISchemaPathGet(command, schema, &schemarootcommand) < 0 = || + !schemarootcommand) { + virBufferAsprintf(debug, "ERROR: command '%s' not found in the sch= ema", command); + return -1; + } + + if (!arguments) + arguments =3D emptyargs =3D virJSONValueNewObject(); + + if (virQEMUQAPISchemaPathGet(schemapatharguments, schema, &schemaroota= rguments) < 0 || + !schemarootarguments) { + virBufferAsprintf(debug, "ERROR: failed to look up 'arg-type' of = '%s'", command); + return -1; + } + + return testQEMUSchemaValidateRecurse(arguments, schemarootarguments, s= chema, debug); +} + + /** * testQEMUSchemaGetLatest: * diff --git a/tests/testutilsqemuschema.h b/tests/testutilsqemuschema.h index 84ee9a9670..e3a375b038 100644 --- a/tests/testutilsqemuschema.h +++ b/tests/testutilsqemuschema.h @@ -28,6 +28,12 @@ testQEMUSchemaValidate(virJSONValuePtr obj, virHashTablePtr schema, virBufferPtr debug); +int +testQEMUSchemaValidateCommand(const char *command, + virJSONValuePtr arguments, + virHashTablePtr schema, + virBufferPtr debug); + virJSONValuePtr testQEMUSchemaGetLatest(const char* arch); --=20 2.26.2 From nobody Fri May 3 02:16:29 2024 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=1588186179; cv=none; d=zohomail.com; s=zohoarc; b=fD7pfrjzIBtO3oEhsdvtFxzFMPz+2dHPq9YUTGi9BPcLYUSMNVbp1nFVjDzPQnNHk5wPFyDe5A9oFbAz1d20+jut5eteQLbQF5CPhokl2EAeAd/Cdyhcx++4aSEO2+JmQfH99X8oDsQDZTXW92YQUkHjqcdYZ5liJWqjLWBrkno= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588186179; 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=W6dQ/jBzZ6TtvE7E6Zq8LVCC26YXUyul3Eh55XPmJXA=; b=X/vifUid2KgpvJZkHTpSvNpKHt+6DUkHDMMVoVaMg+SzfnPjfPyFhEdaOc6xL1hNvaH+0oln6VBREO+nlL8WQ8TLXWtM4+KuyfhABStogNA4KLAfvb//CIfvKBRfOvvrDHj3SdJWqQeEYu/MHF19ExK2rJjZJwoY5jUhzQErHb8= 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 1588186179494220.4533327636144; Wed, 29 Apr 2020 11:49:39 -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-157-gviGW7cBOTyld9XUUX8_Vw-1; Wed, 29 Apr 2020 14:49:34 -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 C28F8835B41; Wed, 29 Apr 2020 18:49: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 564F95C1BE; Wed, 29 Apr 2020 18:49: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 6E3121809554; Wed, 29 Apr 2020 18:49:27 +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 03TInPur001515 for ; Wed, 29 Apr 2020 14:49:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4E2655C1BE; Wed, 29 Apr 2020 18:49:25 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA9455C241 for ; Wed, 29 Apr 2020 18:49:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588186178; 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=W6dQ/jBzZ6TtvE7E6Zq8LVCC26YXUyul3Eh55XPmJXA=; b=KqxXv2NVOibFnuw45vE2MGT5zdLGmK9Jj2RlL97MjXLRIIYzvOCdIoQC5HL9BFUsf1Vluw MpKc1Xpcq/a0Dt2v+txOV96qXrX6+lF5CUDVagnnvTc1jkqygDlx5+6fbd7QNJ9EXR1epz SBLwez3IhG97qSPMFzvBGSvD1xFRs6Y= X-MC-Unique: gviGW7cBOTyld9XUUX8_Vw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/15] qemuMonitorTestProcessCommandDefaultValidate: Use testQEMUSchemaValidateCommand Date: Wed, 29 Apr 2020 20:49:03 +0200 Message-Id: <14414cbd37c599c2e8198ccb2d4ea7cb28dbbc88.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.79 on 10.5.11.16 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" Remove the ad-hoc command validation in favor of the new helper. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemumonitortestutils.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 4ca29ab061..df780643dd 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -537,9 +537,6 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonito= rTestPtr test, virJSONValuePtr args) { g_auto(virBuffer) debug =3D VIR_BUFFER_INITIALIZER; - virJSONValuePtr schemaroot; - g_autoptr(virJSONValue) emptyargs =3D NULL; - g_autofree char *schemapath =3D NULL; if (!test->qapischema) return 0; @@ -555,20 +552,13 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMoni= torTestPtr test, if (STREQ(cmdname, "device_add")) return 0; - schemapath =3D g_strdup_printf("%s/arg-type", cmdname); - - if (virQEMUQAPISchemaPathGet(schemapath, test->qapischema, &schemaroot= ) < 0 || - !schemaroot) { - qemuMonitorTestError("command '%s' not found in QAPI schema", cmdn= ame); - return -1; - } + if (testQEMUSchemaValidateCommand(cmdname, args, test->qapischema, &de= bug) < 0) { + if (virTestGetDebug() =3D=3D 2) { + g_autofree char *argstr =3D NULL; - if (!args) - args =3D emptyargs =3D virJSONValueNewObject(); + if (args) + argstr =3D virJSONValueToString(args, true); - if (testQEMUSchemaValidate(args, schemaroot, test->qapischema, &debug)= < 0) { - if (virTestGetDebug() =3D=3D 2) { - g_autofree char *argstr =3D virJSONValueToString(args, true); fprintf(stderr, "\nfailed to validate arguments of '%s' against QAPI s= chema\n" "args:\n%s\nvalidator output:\n %s\n", --=20 2.26.2 From nobody Fri May 3 02:16:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.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 205.139.110.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=1588186190; cv=none; d=zohomail.com; s=zohoarc; b=l7IfDO05t6W+cpwmLQQQJKaM788+w4+/GiYDkV/SQZR0ucEbwGF4vgjRhoINRBYgE+xhiZQabpM6P4hXo2emIS76LwnubAvsYqCPz1OBnuL+nlaCUIoq+bjdBKoDjexzlqba1WXsJeM+1494dnplqnncerb4evvvk4McnhR7vJ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588186190; 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=eMOoTmEjedurLw5rTRECzNq9d6Y+4sXX7H/9QKHwaHk=; b=nWq4Rhq8BBuHceADiZEJdzlpS7jed0MhfNO56pgh7GDwdfMMlEpigupikCul95pu3cCoU03uR/0ecrIQChTzY5+dD45heCOh0EmWP3VLV61W1Kszry33vKxSUDH15GI8LpA0/Qz5co+ccm3oT5YeHgAaxgk7kvYY4A8OeYbPCQc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.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 [205.139.110.120]) by mx.zohomail.com with SMTPS id 1588186190514781.7413274790307; Wed, 29 Apr 2020 11:49:50 -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-388-XMtbtjOiPZ2ddYwMfzfvOA-1; Wed, 29 Apr 2020 14:49:46 -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 31F681800D4A; Wed, 29 Apr 2020 18:49:41 +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 07A2C600E5; Wed, 29 Apr 2020 18:49:41 +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 BAA541809542; Wed, 29 Apr 2020 18:49:40 +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 03TInQEk001525 for ; Wed, 29 Apr 2020 14:49:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3A6C75C241; Wed, 29 Apr 2020 18:49:26 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6CCE5C1BE for ; Wed, 29 Apr 2020 18:49:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588186189; 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=eMOoTmEjedurLw5rTRECzNq9d6Y+4sXX7H/9QKHwaHk=; b=YJwZnuOssFv4yFkUwZCU93DoThFVFhAIwVUan0A5WSVt1l5y8ToMnm5eY4T5x0vlAVTMh0 02VV1oXX2H6HHV2GZkbob/N8G9+3PbEYUkX+B32SbGmPcXTdzjpX9IyRYyjGJMKuWy0qeP ToB2ef06OBt0usMlmjFawE6bupQfuDc= X-MC-Unique: XMtbtjOiPZ2ddYwMfzfvOA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/15] qemuMonitorTestProcessCommandDefaultValidate: Clean up return value use Date: Wed, 29 Apr 2020 20:49:04 +0200 Message-Id: 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.79 on 10.5.11.11 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" We no longer return the error via the monitor, so the function no longer returns '1'. Remove the mention from comment and fix callers to stop looking for the return value of '1'. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemumonitortestutils.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index df780643dd..3dc4b674f3 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -529,8 +529,7 @@ qemuMonitorTestHandlerDataFree(void *opaque) } -/* Returns -1 on error, 0 if validation was successful/not necessary, 1 if - * the validation has failed, and the reply was properly constructed */ +/* Returns -1 on error, 0 if validation was successful/not necessary */ static int qemuMonitorTestProcessCommandDefaultValidate(qemuMonitorTestPtr test, const char *cmdname, @@ -585,7 +584,6 @@ qemuMonitorTestProcessCommandDefault(qemuMonitorTestPtr= test, g_autoptr(virJSONValue) val =3D NULL; virJSONValuePtr cmdargs =3D NULL; const char *cmdname; - int rc; if (!(val =3D virJSONValueFromString(cmdstr))) return -1; @@ -596,10 +594,8 @@ qemuMonitorTestProcessCommandDefault(qemuMonitorTestPt= r test, } cmdargs =3D virJSONValueObjectGet(val, "arguments"); - if ((rc =3D qemuMonitorTestProcessCommandDefaultValidate(test, cmdname= , cmdargs)) < 0) + if (qemuMonitorTestProcessCommandDefaultValidate(test, cmdname, cmdarg= s) < 0) return -1; - if (rc =3D=3D 1) - return 0; if (data->command_name && STRNEQ(data->command_name, cmdname)) { qemuMonitorTestErrorInvalidCommand(data->command_name, cmdname); @@ -641,7 +637,6 @@ qemuMonitorTestProcessCommandVerbatim(qemuMonitorTestPt= r test, virJSONValuePtr cmdargs; const char *cmdname; int ret =3D -1; - int rc; /* JSON strings will be reformatted to simplify checking */ if (!(json =3D virJSONValueFromString(cmdstr)) || @@ -653,12 +648,8 @@ qemuMonitorTestProcessCommandVerbatim(qemuMonitorTestP= tr test, /* in this case we do a best-effort schema check if we can find the co= mmand */ if ((cmdname =3D virJSONValueObjectGetString(json, "execute"))) { cmdargs =3D virJSONValueObjectGet(json, "arguments"); - - if ((rc =3D qemuMonitorTestProcessCommandDefaultValidate(test, cmd= name, cmdargs)) < 0) + if (qemuMonitorTestProcessCommandDefaultValidate(test, cmdname, cm= dargs) < 0) return -1; - - if (rc =3D=3D 1) - return 0; } if (STREQ(data->command_name, cmdstr)) { --=20 2.26.2 From nobody Fri May 3 02:16:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 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=1588186194; cv=none; d=zohomail.com; s=zohoarc; b=VbvsD3IORBhTPiJfvKuambOGGxb0MhzstjMF63vMCCNAnRNb8DX4Rjn7D5aPKmFP+OH0zuTX27ajmL1z32mlHWpH0NjVC1ofj5862FlpKYcaU1gsl9VQpn0+xMPn/A2ysrAenrJRuTxPyrj+VMmpRqSDdxioGwFoVP0p1DKuKqU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588186194; 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=3dXmcZVouVqZy36E4vuQmg19nSZRLvtglYy/I2Y/ErM=; b=Z8yba5l5GKp0YyqTyUcZCpuvZKtINhSM1FVRE7G9aKr6J8MieUOStxTeL0zzVsYhVrnePaCsTZzRzmKEDLjVTIEKV5aSzMxXxhMKDPuFNKGPPKS/+Uhu+6STtTnld9DCcBoJ42U+rLfh7lDsTX4eYrUYXZ74tMQIDHD6OXFP1Gs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1588186194293916.9410110086314; Wed, 29 Apr 2020 11:49: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-378-v2sc5qnuOzaLmeV0XuXzcA-1; Wed, 29 Apr 2020 14:49:50 -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 B3D4D100CCCE; Wed, 29 Apr 2020 18:49:44 +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 855745C254; Wed, 29 Apr 2020 18:49:44 +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 3DCCF1809557; Wed, 29 Apr 2020 18:49:44 +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 03TInRS5001531 for ; Wed, 29 Apr 2020 14:49:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2593F5C241; Wed, 29 Apr 2020 18:49:27 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 94C145C1BE for ; Wed, 29 Apr 2020 18:49:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588186192; 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=3dXmcZVouVqZy36E4vuQmg19nSZRLvtglYy/I2Y/ErM=; b=EbnK1x/+UdQodhyAclWMd460M9/f+cv9GLmC6Rut5eQySJnZqrQV496i0fRJCc89xbVdwo 8/KwlaRw/XxxloVm2yHlyPeNwu+yrFxnEkFJkJCE66C3EukrjBaj5UnKbDZmBf6oFo8Hcs g4UWO7snp7uJ/IUwa4cSffR8ymhL/40= X-MC-Unique: v2sc5qnuOzaLmeV0XuXzcA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/15] qemumonitortestutils: Introduce qemuMonitorTestSkipDeprecatedValidation Date: Wed, 29 Apr 2020 20:49:05 +0200 Message-Id: <0d70252bc006d9a2e8f226a87f97b55f769e2410.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.79 on 10.5.11.16 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" Upcoming patches will add validation which rejects objects with the 'deprecated' feature in the QMP schema. To support tests which deal with legacy properties in case when a command or argument is marked as deprecated or removed by qemu qemuMonitorTestSkipDeprecatedValidation will allow configuring the tests to ignore such errors. In case of commands/features which are not yet replaced, the 'allowRemoved' bool should not be set to provide a hard notification once qemu drops the command. Note that at this point 'allowRemoved' only includes whole commands, but not specific properties. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemumonitortestutils.c | 28 ++++++++++++++++++++++++++++ tests/qemumonitortestutils.h | 2 ++ 2 files changed, 30 insertions(+) diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 3dc4b674f3..0d9427f1d1 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -59,6 +59,9 @@ struct _qemuMonitorTest { bool allowUnusedCommands; + bool skipValidationDeprecated; + bool skipValidationRemoved; + char *incoming; size_t incomingLength; size_t incomingCapacity; @@ -1298,6 +1301,31 @@ qemuMonitorTestAllowUnusedCommands(qemuMonitorTestPt= r test) } +/** + * qemuMonitorTestSkipDeprecatedValidation: + * @test: test monitor object + * @allowRemoved: don't produce errors if command was removed from QMP sch= ema + * + * By default if the QMP schema is provided all test items/commands are + * validated against the schema. This function allows to override the vali= dation + * and additionally if @allowRemoved is true and if such a command is no l= onger + * present in the QMP, only a warning is printed. + * + * '@allowRemoved' must be used only if a suitable replacement is already = in + * use and the code tests legacy interactions. + * + * Note that currently '@allowRemoved' influences only removed commands. I= f an + * argument is removed it will still fail validation. + */ +void +qemuMonitorTestSkipDeprecatedValidation(qemuMonitorTestPtr test, + bool allowRemoved) +{ + test->skipValidationDeprecated =3D true; + test->skipValidationRemoved =3D allowRemoved; +} + + static int qemuMonitorTestFullAddItem(qemuMonitorTestPtr test, const char *filename, diff --git a/tests/qemumonitortestutils.h b/tests/qemumonitortestutils.h index f45e850000..1073ef4100 100644 --- a/tests/qemumonitortestutils.h +++ b/tests/qemumonitortestutils.h @@ -51,6 +51,8 @@ void *qemuMonitorTestItemGetPrivateData(qemuMonitorTestIt= emPtr item); int qemuMonitorTestAddErrorResponse(qemuMonitorTestPtr test, const char *e= rrmsg, ...); void qemuMonitorTestAllowUnusedCommands(qemuMonitorTestPtr test); +void qemuMonitorTestSkipDeprecatedValidation(qemuMonitorTestPtr test, + bool allowRemoved); int qemuMonitorTestAddItem(qemuMonitorTestPtr test, const char *command_name, --=20 2.26.2 From nobody Fri May 3 02:16:29 2024 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=1588186199; cv=none; d=zohomail.com; s=zohoarc; b=MhLYywHOtmdOvvKFaQEtCEeObKFpX8gEmPX151l0KKeobXGL9S8ben2oUO30/QvY9JlxeQgfpNmpwPHjY6cqPYsBx3HiEq5FagFbKn/bpy+v06vPSB8pR2TBmvJkFvVMqCb+5x3dvPKfqflc+Ce13mnibK+OC4ESTeAe6EtIKSY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588186199; 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=JLkitdA5FI+v1TckQ7HDTnFLWqwop/yiDeDDV/cdu90=; b=LTbBxktMFg91oadPtrnllQelzd7QW+GjpUdy+HzsO1CrjXEWyVcT1L+UZbylJltBnPcAFNB8iJjlHxQP/nEnxXhdtBOEAF9zFAbtnQ0/Y4o6ToI9TYlU7c4OooY4ewFk6775+ybZJ/2UyJWtsN/bZBetNFKXc0cYajaZmPKHAAY= 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 1588186199829475.708092328121; Wed, 29 Apr 2020 11:49:59 -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-55-HEOnLPnTM5-w3qis8TB65w-1; Wed, 29 Apr 2020 14:49:56 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3117580572E; Wed, 29 Apr 2020 18:49:48 +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 094735D78D; Wed, 29 Apr 2020 18:49:48 +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 B4D631806B0D; Wed, 29 Apr 2020 18:49:47 +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 03TInS10001542 for ; Wed, 29 Apr 2020 14:49:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 14B7C5C241; Wed, 29 Apr 2020 18:49:28 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7EA635C1BE for ; Wed, 29 Apr 2020 18:49:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588186198; 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=JLkitdA5FI+v1TckQ7HDTnFLWqwop/yiDeDDV/cdu90=; b=EwAr0zhqwF8Xv/JgwKfPRTajJ+48fmatgrG1wT4ftX0TMmyfDZJBA4b+lqzaep7xSDaJ5o RoKrK5DmkAGRXKH1xDoBlbY5jUwoWEpRZUsy0G91Cm4kEviB7ufpDj7tEpTi3XZNcbKKzt yKemejqH60ZYaJc3pl0bUdWlQyaF+3c= X-MC-Unique: HEOnLPnTM5-w3qis8TB65w-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/15] testutilsqemuschema: Use automatic variable clearing where possible Date: Wed, 29 Apr 2020 20:49:06 +0200 Message-Id: <7d7a6c9434931a2f052a46a03798cde569124cf7.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.79 on 10.5.11.15 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" Refactor all cleanup to avoid manual clearing, unnecessary labels and return value variables. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/testutilsqemuschema.c | 81 +++++++++++++------------------------ 1 file changed, 29 insertions(+), 52 deletions(-) diff --git a/tests/testutilsqemuschema.c b/tests/testutilsqemuschema.c index 60409a0f91..a43cbe2f91 100644 --- a/tests/testutilsqemuschema.c +++ b/tests/testutilsqemuschema.c @@ -123,36 +123,33 @@ testQEMUSchemaValidateObjectMember(const char *key, void *opaque) { struct testQEMUSchemaValidateObjectMemberData *data =3D opaque; - virJSONValuePtr keymember =3D NULL; + g_autoptr(virJSONValue) keymember =3D NULL; const char *keytype; virJSONValuePtr keyschema =3D NULL; - int ret =3D -1; + int rc; virBufferStrcat(data->debug, key, ": ", NULL); /* lookup 'member' entry for key */ if (!(keymember =3D testQEMUSchemaStealObjectMemberByName(key, data->r= ootmembers))) { - virBufferAddLit(data->debug, "ERROR: attribute not in schema"); - goto cleanup; + virBufferAddLit(data->debug, "ERROR: attribute not in schema\n"); + return -1; } /* lookup schema entry for keytype */ if (!(keytype =3D virJSONValueObjectGetString(keymember, "type")) || !(keyschema =3D virHashLookup(data->schema, keytype))) { - virBufferAsprintf(data->debug, "ERROR: can't find schema for type = '%s'", + virBufferAsprintf(data->debug, "ERROR: can't find schema for type = '%s'\n", NULLSTR(keytype)); - ret =3D -2; - goto cleanup; + return -2; } /* recurse */ - ret =3D testQEMUSchemaValidateRecurse(value, keyschema, data->schema, + rc =3D testQEMUSchemaValidateRecurse(value, keyschema, data->schema, data->debug); - cleanup: virBufferAddLit(data->debug, "\n"); - virJSONValueFree(keymember); - return ret; + return rc; } @@ -188,13 +185,12 @@ testQEMUSchemaValidateObjectMergeVariant(virJSONValue= Ptr root, virBufferPtr debug) { size_t i; - virJSONValuePtr variants =3D NULL; + g_autoptr(virJSONValue) variants =3D NULL; virJSONValuePtr variant; virJSONValuePtr variantschema; virJSONValuePtr variantschemamembers; virJSONValuePtr rootmembers; const char *varianttype =3D NULL; - int ret =3D -1; if (!(variants =3D virJSONValueObjectStealArray(root, "variants"))) { virBufferAddLit(debug, "ERROR: missing 'variants' in schema\n"); @@ -214,8 +210,7 @@ testQEMUSchemaValidateObjectMergeVariant(virJSONValuePt= r root, if (!varianttype) { virBufferAsprintf(debug, "ERROR: variant '%s' for discriminator '%= s' not found\n", variantname, variantfield); - goto cleanup; - + return -1; } if (!(variantschema =3D virHashLookup(schema, varianttype)) || @@ -223,8 +218,7 @@ testQEMUSchemaValidateObjectMergeVariant(virJSONValuePt= r root, virBufferAsprintf(debug, "ERROR: missing schema or schema members for var= iant '%s'(%s)\n", variantname, varianttype); - ret =3D -2; - goto cleanup; + return -2; } rootmembers =3D virJSONValueObjectGetArray(root, "members"); @@ -232,15 +226,10 @@ testQEMUSchemaValidateObjectMergeVariant(virJSONValue= Ptr root, if (virJSONValueArrayForeachSteal(variantschemamembers, testQEMUSchemaValidateObjectMergeVar= iantMember, rootmembers) < 0) { - ret =3D -2; - goto cleanup; + return -2; } - ret =3D 0; - - cleanup: - virJSONValueFree(variants); - return ret; + return 0; } @@ -269,10 +258,9 @@ testQEMUSchemaValidateObject(virJSONValuePtr obj, { struct testQEMUSchemaValidateObjectMemberData data =3D { NULL, schema, debug, false }; - virJSONValuePtr localroot =3D NULL; + g_autoptr(virJSONValue) localroot =3D NULL; const char *variantfield; const char *variantname; - int ret =3D -1; if (virJSONValueGetType(obj) !=3D VIR_JSON_TYPE_OBJECT) { virBufferAddLit(debug, "ERROR: not an object"); @@ -283,23 +271,21 @@ testQEMUSchemaValidateObject(virJSONValuePtr obj, virBufferAdjustIndent(debug, 3); /* copy schema */ - if (!(localroot =3D virJSONValueCopy(root))) { - ret =3D -2; - goto cleanup; - } + if (!(localroot =3D virJSONValueCopy(root))) + return -2; /* remove variant */ if ((variantfield =3D virJSONValueObjectGetString(localroot, "tag"))) { if (!(variantname =3D virJSONValueObjectGetString(obj, variantfiel= d))) { virBufferAsprintf(debug, "ERROR: missing variant discriminator= attribute '%s'\n", variantfield); - goto cleanup; + return -1; } if (testQEMUSchemaValidateObjectMergeVariant(localroot, variantfie= ld, variantname, schema, debug) < 0) - goto cleanup; + return -1; } @@ -308,26 +294,21 @@ testQEMUSchemaValidateObject(virJSONValuePtr obj, if (virJSONValueObjectForeachKeyValue(obj, testQEMUSchemaValidateObjectMemb= er, &data) < 0) - goto cleanup; + return -1; /* check missing mandatory values */ if (virJSONValueArrayForeachSteal(data.rootmembers, testQEMUSchemaValidateObjectMandator= yMember, &data) < 0) { - ret =3D -2; - goto cleanup; + return -2; } if (data.missingMandatory) - goto cleanup; + return -1; virBufferAdjustIndent(debug, -3); virBufferAddLit(debug, "} OK"); - ret =3D 0; - - cleanup: - virJSONValueFree(localroot); - return ret; + return 0; } @@ -570,11 +551,11 @@ testQEMUSchemaValidateCommand(const char *command, virJSONValuePtr testQEMUSchemaGetLatest(const char* arch) { - char *capsLatestFile =3D NULL; - char *capsLatest =3D NULL; + g_autofree char *capsLatestFile =3D NULL; + g_autofree char *capsLatest =3D NULL; char *schemaReply; char *end; - virJSONValuePtr reply =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValuePtr schema =3D NULL; if (!(capsLatestFile =3D testQemuGetLatestCapsForArch(arch, "replies")= )) { @@ -585,14 +566,14 @@ testQEMUSchemaGetLatest(const char* arch) VIR_TEST_DEBUG("replies file: '%s'", capsLatestFile); if (virTestLoadFile(capsLatestFile, &capsLatest) < 0) - goto cleanup; + return NULL; if (!(schemaReply =3D strstr(capsLatest, "\"execute\": \"query-qmp-sch= ema\"")) || !(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); - goto cleanup; + return NULL; } schemaReply +=3D 2; @@ -601,19 +582,15 @@ testQEMUSchemaGetLatest(const char* arch) if (!(reply =3D virJSONValueFromString(schemaReply))) { VIR_TEST_VERBOSE("failed to parse 'query-qmp-schema' reply from '%= s'", capsLatestFile); - goto cleanup; + return NULL; } if (!(schema =3D virJSONValueObjectStealArray(reply, "return"))) { VIR_TEST_VERBOSE("missing qapi schema data in reply in '%s'", capsLatestFile); - goto cleanup; + return NULL; } - cleanup: - VIR_FREE(capsLatestFile); - VIR_FREE(capsLatest); - virJSONValueFree(reply); return schema; } --=20 2.26.2 From nobody Fri May 3 02:16:29 2024 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=1588186199; cv=none; d=zohomail.com; s=zohoarc; b=C8+ei5OQRop5+g/qMeFHzxgl6BtAChDXkAkT68NNJz6s9uzymN1Qd53TJb7Ex/cpxbiA3oT1jPvyLfg6W2MaibBFqPjhsFSetZotJVSnspCCl1m/tsHuOc8Ga7RVtXFStNe3tih5ClJWSWxMASuSfIR2avMHHV038pY2Dv//+lU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588186199; 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=m8HXJstIge62ytkJq+U7Lq+J8r/KiOOO256BR5HjFrA=; b=FSHQSIMJBCGUjdO2jD1EPgwJuMPyyhmYdO3EHRyAg92ZVgvN9mFuTIQXnkqCdjD/LrtNmAtvZxH249NR6IF9C1YBt4KFj3rtN8wLmsVSXNRVxBwuWC0vcD0oBKKeNR9vmApUKjLYdThuPudqUi0hVc3rXjm3E1T5/mholaOSToA= 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 1588186199957978.9638234644133; Wed, 29 Apr 2020 11:49:59 -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-425-6FtuiByqOvymTQf2edsdAw-1; Wed, 29 Apr 2020 14:49:56 -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 31A8E1800D4A; Wed, 29 Apr 2020 18:49:48 +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 0A63C66064; Wed, 29 Apr 2020 18:49:48 +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 B5117180CB27; Wed, 29 Apr 2020 18:49:47 +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 03TInTaa001555 for ; Wed, 29 Apr 2020 14:49:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 272CB5C1BE; Wed, 29 Apr 2020 18:49:29 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BAB15C241 for ; Wed, 29 Apr 2020 18:49:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588186198; 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=m8HXJstIge62ytkJq+U7Lq+J8r/KiOOO256BR5HjFrA=; b=itmgpH5F3Uvy3qTGbpC/tixt+EYv7dE13+EFJv11qquBUo2xatrQP7LzyPkW8bTup4ngAe Ml1llvUOipF3pVSnvp9yVvgmWC/5S51fAKmliHcVkAbZtcwZWpKazzMUl1MEXc22PPwI/c bI2KFF3zqosD3sjvCLLmiI411ww5Kug= X-MC-Unique: 6FtuiByqOvymTQf2edsdAw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/15] testutilsqemuschema: Pass in 'schema' and 'debug' variables to workers in a struct Date: Wed, 29 Apr 2020 20:49:07 +0200 Message-Id: <36e9312f6fd3d5f19ab7cdd5c8df75c48f4393fa.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.79 on 10.5.11.13 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" Refactor the code so that we pass in the repeated 'schema' and 'debug' arguments via a new struct testQEMUSchemaValidateCtxt. This will simplify adding new parameters in the future. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/testutilsqemuschema.c | 152 ++++++++++++++++++------------------ 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/tests/testutilsqemuschema.c b/tests/testutilsqemuschema.c index a43cbe2f91..b449171d15 100644 --- a/tests/testutilsqemuschema.c +++ b/tests/testutilsqemuschema.c @@ -21,16 +21,21 @@ #include "testutilsqemuschema.h" #include "qemu/qemu_qapi.h" +struct testQEMUSchemaValidateCtxt { + virHashTablePtr schema; + virBufferPtr debug; +}; + + static int testQEMUSchemaValidateRecurse(virJSONValuePtr obj, virJSONValuePtr root, - virHashTablePtr schema, - virBufferPtr debug); + struct testQEMUSchemaValidateCtxt *ctxt); static int testQEMUSchemaValidateBuiltin(virJSONValuePtr obj, virJSONValuePtr root, - virBufferPtr debug) + struct testQEMUSchemaValidateCtxt *ctxt) { const char *t =3D virJSONValueObjectGetString(root, "json-type"); const char *s =3D NULL; @@ -81,17 +86,16 @@ testQEMUSchemaValidateBuiltin(virJSONValuePtr obj, cleanup: if (ret =3D=3D 0) - virBufferAsprintf(debug, "'%s': OK", s); + virBufferAsprintf(ctxt->debug, "'%s': OK", s); else - virBufferAsprintf(debug, "ERROR: expected type '%s', actual type %= d", + virBufferAsprintf(ctxt->debug, "ERROR: expected type '%s', actual = type %d", t, virJSONValueGetType(obj)); return ret; } struct testQEMUSchemaValidateObjectMemberData { virJSONValuePtr rootmembers; - virHashTablePtr schema; - virBufferPtr debug; + struct testQEMUSchemaValidateCtxt *ctxt; bool missingMandatory; }; @@ -128,27 +132,26 @@ testQEMUSchemaValidateObjectMember(const char *key, virJSONValuePtr keyschema =3D NULL; int rc; - virBufferStrcat(data->debug, key, ": ", NULL); + virBufferStrcat(data->ctxt->debug, key, ": ", NULL); /* lookup 'member' entry for key */ if (!(keymember =3D testQEMUSchemaStealObjectMemberByName(key, data->r= ootmembers))) { - virBufferAddLit(data->debug, "ERROR: attribute not in schema\n"); + virBufferAddLit(data->ctxt->debug, "ERROR: attribute not in schema= \n"); return -1; } /* lookup schema entry for keytype */ if (!(keytype =3D virJSONValueObjectGetString(keymember, "type")) || - !(keyschema =3D virHashLookup(data->schema, keytype))) { - virBufferAsprintf(data->debug, "ERROR: can't find schema for type = '%s'\n", + !(keyschema =3D virHashLookup(data->ctxt->schema, keytype))) { + virBufferAsprintf(data->ctxt->debug, "ERROR: can't find schema for= type '%s'\n", NULLSTR(keytype)); return -2; } /* recurse */ - rc =3D testQEMUSchemaValidateRecurse(value, keyschema, data->schema, - data->debug); + rc =3D testQEMUSchemaValidateRecurse(value, keyschema, data->ctxt); - virBufferAddLit(data->debug, "\n"); + virBufferAddLit(data->ctxt->debug, "\n"); return rc; } @@ -181,8 +184,7 @@ static int testQEMUSchemaValidateObjectMergeVariant(virJSONValuePtr root, const char *variantfield, const char *variantname, - virHashTablePtr schema, - virBufferPtr debug) + struct testQEMUSchemaValidateCtxt= *ctxt) { size_t i; g_autoptr(virJSONValue) variants =3D NULL; @@ -193,7 +195,7 @@ testQEMUSchemaValidateObjectMergeVariant(virJSONValuePt= r root, const char *varianttype =3D NULL; if (!(variants =3D virJSONValueObjectStealArray(root, "variants"))) { - virBufferAddLit(debug, "ERROR: missing 'variants' in schema\n"); + virBufferAddLit(ctxt->debug, "ERROR: missing 'variants' in schema\= n"); return -2; } @@ -208,14 +210,14 @@ testQEMUSchemaValidateObjectMergeVariant(virJSONValue= Ptr root, } if (!varianttype) { - virBufferAsprintf(debug, "ERROR: variant '%s' for discriminator '%= s' not found\n", + virBufferAsprintf(ctxt->debug, "ERROR: variant '%s' for discrimina= tor '%s' not found\n", variantname, variantfield); return -1; } - if (!(variantschema =3D virHashLookup(schema, varianttype)) || + if (!(variantschema =3D virHashLookup(ctxt->schema, varianttype)) || !(variantschemamembers =3D virJSONValueObjectGetArray(variantschem= a, "members"))) { - virBufferAsprintf(debug, + virBufferAsprintf(ctxt->debug, "ERROR: missing schema or schema members for var= iant '%s'(%s)\n", variantname, varianttype); return -2; @@ -241,7 +243,7 @@ testQEMUSchemaValidateObjectMandatoryMember(size_t pos = G_GNUC_UNUSED, struct testQEMUSchemaValidateObjectMemberData *data =3D opaque; if (virJSONValueObjectHasKey(item, "default") !=3D 1) { - virBufferAsprintf(data->debug, "ERROR: missing mandatory attribute= '%s'\n", + virBufferAsprintf(data->ctxt->debug, "ERROR: missing mandatory att= ribute '%s'\n", NULLSTR(virJSONValueObjectGetString(item, "name"= ))); data->missingMandatory =3D true; } @@ -253,22 +255,20 @@ testQEMUSchemaValidateObjectMandatoryMember(size_t po= s G_GNUC_UNUSED, static int testQEMUSchemaValidateObject(virJSONValuePtr obj, virJSONValuePtr root, - virHashTablePtr schema, - virBufferPtr debug) + struct testQEMUSchemaValidateCtxt *ctxt) { - struct testQEMUSchemaValidateObjectMemberData data =3D { NULL, schema, - debug, false }; + struct testQEMUSchemaValidateObjectMemberData data =3D { NULL, ctxt, f= alse }; g_autoptr(virJSONValue) localroot =3D NULL; const char *variantfield; const char *variantname; if (virJSONValueGetType(obj) !=3D VIR_JSON_TYPE_OBJECT) { - virBufferAddLit(debug, "ERROR: not an object"); + virBufferAddLit(ctxt->debug, "ERROR: not an object"); return -1; } - virBufferAddLit(debug, "{\n"); - virBufferAdjustIndent(debug, 3); + virBufferAddLit(ctxt->debug, "{\n"); + virBufferAdjustIndent(ctxt->debug, 3); /* copy schema */ if (!(localroot =3D virJSONValueCopy(root))) @@ -277,14 +277,13 @@ testQEMUSchemaValidateObject(virJSONValuePtr obj, /* remove variant */ if ((variantfield =3D virJSONValueObjectGetString(localroot, "tag"))) { if (!(variantname =3D virJSONValueObjectGetString(obj, variantfiel= d))) { - virBufferAsprintf(debug, "ERROR: missing variant discriminator= attribute '%s'\n", + virBufferAsprintf(ctxt->debug, "ERROR: missing variant discrim= inator attribute '%s'\n", variantfield); return -1; } if (testQEMUSchemaValidateObjectMergeVariant(localroot, variantfie= ld, - variantname, - schema, debug) < 0) + variantname, ctxt) < = 0) return -1; } @@ -306,8 +305,8 @@ testQEMUSchemaValidateObject(virJSONValuePtr obj, if (data.missingMandatory) return -1; - virBufferAdjustIndent(debug, -3); - virBufferAddLit(debug, "} OK"); + virBufferAdjustIndent(ctxt->debug, -3); + virBufferAddLit(ctxt->debug, "} OK"); return 0; } @@ -315,7 +314,7 @@ testQEMUSchemaValidateObject(virJSONValuePtr obj, static int testQEMUSchemaValidateEnum(virJSONValuePtr obj, virJSONValuePtr root, - virBufferPtr debug) + struct testQEMUSchemaValidateCtxt *ctxt) { const char *objstr; virJSONValuePtr values =3D NULL; @@ -323,14 +322,14 @@ testQEMUSchemaValidateEnum(virJSONValuePtr obj, size_t i; if (virJSONValueGetType(obj) !=3D VIR_JSON_TYPE_STRING) { - virBufferAddLit(debug, "ERROR: not a string"); + virBufferAddLit(ctxt->debug, "ERROR: not a string"); return -1; } objstr =3D virJSONValueGetString(obj); if (!(values =3D virJSONValueObjectGetArray(root, "values"))) { - virBufferAsprintf(debug, "ERROR: missing enum values in schema '%s= '", + virBufferAsprintf(ctxt->debug, "ERROR: missing enum values in sche= ma '%s'", NULLSTR(virJSONValueObjectGetString(root, "name"= ))); return -2; } @@ -339,12 +338,12 @@ testQEMUSchemaValidateEnum(virJSONValuePtr obj, value =3D virJSONValueArrayGet(values, i); if (STREQ_NULLABLE(objstr, virJSONValueGetString(value))) { - virBufferAsprintf(debug, "'%s' OK", NULLSTR(objstr)); + virBufferAsprintf(ctxt->debug, "'%s' OK", NULLSTR(objstr)); return 0; } } - virBufferAsprintf(debug, "ERROR: enum value '%s' is not in schema", + virBufferAsprintf(ctxt->debug, "ERROR: enum value '%s' is not in schem= a", NULLSTR(objstr)); return -1; } @@ -353,8 +352,7 @@ testQEMUSchemaValidateEnum(virJSONValuePtr obj, static int testQEMUSchemaValidateArray(virJSONValuePtr objs, virJSONValuePtr root, - virHashTablePtr schema, - virBufferPtr debug) + struct testQEMUSchemaValidateCtxt *ctxt) { const char *elemtypename =3D virJSONValueObjectGetString(root, "elemen= t-type"); virJSONValuePtr elementschema; @@ -362,29 +360,29 @@ testQEMUSchemaValidateArray(virJSONValuePtr objs, size_t i; if (virJSONValueGetType(objs) !=3D VIR_JSON_TYPE_ARRAY) { - virBufferAddLit(debug, "ERROR: not an array\n"); + virBufferAddLit(ctxt->debug, "ERROR: not an array\n"); return -1; } if (!elemtypename || - !(elementschema =3D virHashLookup(schema, elemtypename))) { - virBufferAsprintf(debug, "ERROR: missing schema for array element = type '%s'", + !(elementschema =3D virHashLookup(ctxt->schema, elemtypename))) { + virBufferAsprintf(ctxt->debug, "ERROR: missing schema for array el= ement type '%s'", NULLSTR(elemtypename)); return -2; } - virBufferAddLit(debug, "[\n"); - virBufferAdjustIndent(debug, 3); + virBufferAddLit(ctxt->debug, "[\n"); + virBufferAdjustIndent(ctxt->debug, 3); for (i =3D 0; i < virJSONValueArraySize(objs); i++) { obj =3D virJSONValueArrayGet(objs, i); - if (testQEMUSchemaValidateRecurse(obj, elementschema, schema, debu= g) < 0) + if (testQEMUSchemaValidateRecurse(obj, elementschema, ctxt) < 0) return -1; - virBufferAddLit(debug, ",\n"); + virBufferAddLit(ctxt->debug, ",\n"); } - virBufferAddLit(debug, "] OK"); - virBufferAdjustIndent(debug, -3); + virBufferAddLit(ctxt->debug, "] OK"); + virBufferAdjustIndent(ctxt->debug, -3); return 0; } @@ -392,8 +390,7 @@ testQEMUSchemaValidateArray(virJSONValuePtr objs, static int testQEMUSchemaValidateAlternate(virJSONValuePtr obj, virJSONValuePtr root, - virHashTablePtr schema, - virBufferPtr debug) + struct testQEMUSchemaValidateCtxt *ctxt) { virJSONValuePtr members; virJSONValuePtr member; @@ -405,44 +402,44 @@ testQEMUSchemaValidateAlternate(virJSONValuePtr obj, int rc; if (!(members =3D virJSONValueObjectGetArray(root, "members"))) { - virBufferAddLit(debug, "ERROR: missing 'members' for alternate sch= ema"); + virBufferAddLit(ctxt->debug, "ERROR: missing 'members' for alterna= te schema"); return -2; } - virBufferAddLit(debug, "(\n"); - virBufferAdjustIndent(debug, 3); - indent =3D virBufferGetIndent(debug); + virBufferAddLit(ctxt->debug, "(\n"); + virBufferAdjustIndent(ctxt->debug, 3); + indent =3D virBufferGetIndent(ctxt->debug); n =3D virJSONValueArraySize(members); for (i =3D 0; i < n; i++) { membertype =3D NULL; /* P !=3D NP */ - virBufferAsprintf(debug, "(alternate %zu/%zu)\n", i + 1, n); - virBufferAdjustIndent(debug, 3); + virBufferAsprintf(ctxt->debug, "(alternate %zu/%zu)\n", i + 1, n); + virBufferAdjustIndent(ctxt->debug, 3); if (!(member =3D virJSONValueArrayGet(members, i)) || !(membertype =3D virJSONValueObjectGetString(member, "type")) = || - !(memberschema =3D virHashLookup(schema, membertype))) { - virBufferAsprintf(debug, "ERROR: missing schema for alternate = type '%s'", + !(memberschema =3D virHashLookup(ctxt->schema, membertype))) { + virBufferAsprintf(ctxt->debug, "ERROR: missing schema for alte= rnate type '%s'", NULLSTR(membertype)); return -2; } - rc =3D testQEMUSchemaValidateRecurse(obj, memberschema, schema, de= bug); + rc =3D testQEMUSchemaValidateRecurse(obj, memberschema, ctxt); - virBufferAddLit(debug, "\n"); - virBufferSetIndent(debug, indent); - virBufferAsprintf(debug, "(/alternate %zu/%zu)\n", i + 1, n); + virBufferAddLit(ctxt->debug, "\n"); + virBufferSetIndent(ctxt->debug, indent); + virBufferAsprintf(ctxt->debug, "(/alternate %zu/%zu)\n", i + 1, n); if (rc =3D=3D 0) { - virBufferAdjustIndent(debug, -3); - virBufferAddLit(debug, ") OK"); + virBufferAdjustIndent(ctxt->debug, -3); + virBufferAddLit(ctxt->debug, ") OK"); return 0; } } - virBufferAddLit(debug, "ERROR: no alternate type was matched"); + virBufferAddLit(ctxt->debug, "ERROR: no alternate type was matched"); return -1; } @@ -450,25 +447,24 @@ testQEMUSchemaValidateAlternate(virJSONValuePtr obj, static int testQEMUSchemaValidateRecurse(virJSONValuePtr obj, virJSONValuePtr root, - virHashTablePtr schema, - virBufferPtr debug) + struct testQEMUSchemaValidateCtxt *ctxt) { const char *n =3D virJSONValueObjectGetString(root, "name"); const char *t =3D virJSONValueObjectGetString(root, "meta-type"); if (STREQ_NULLABLE(t, "builtin")) { - return testQEMUSchemaValidateBuiltin(obj, root, debug); + return testQEMUSchemaValidateBuiltin(obj, root, ctxt); } else if (STREQ_NULLABLE(t, "object")) { - return testQEMUSchemaValidateObject(obj, root, schema, debug); + return testQEMUSchemaValidateObject(obj, root, ctxt); } else if (STREQ_NULLABLE(t, "enum")) { - return testQEMUSchemaValidateEnum(obj, root, debug); + return testQEMUSchemaValidateEnum(obj, root, ctxt); } else if (STREQ_NULLABLE(t, "array")) { - return testQEMUSchemaValidateArray(obj, root, schema, debug); + return testQEMUSchemaValidateArray(obj, root, ctxt); } else if (STREQ_NULLABLE(t, "alternate")) { - return testQEMUSchemaValidateAlternate(obj, root, schema, debug); + return testQEMUSchemaValidateAlternate(obj, root, ctxt); } - virBufferAsprintf(debug, + virBufferAsprintf(ctxt->debug, "qapi schema meta-type '%s' of type '%s' not handled= \n", NULLSTR(t), NULLSTR(n)); return -2; @@ -494,7 +490,9 @@ testQEMUSchemaValidate(virJSONValuePtr obj, virHashTablePtr schema, virBufferPtr debug) { - return testQEMUSchemaValidateRecurse(obj, root, schema, debug); + struct testQEMUSchemaValidateCtxt ctxt =3D { .schema =3D schema, + .debug =3D debug }; + return testQEMUSchemaValidateRecurse(obj, root, &ctxt); } @@ -518,6 +516,8 @@ testQEMUSchemaValidateCommand(const char *command, virHashTablePtr schema, virBufferPtr debug) { + struct testQEMUSchemaValidateCtxt ctxt =3D { .schema =3D schema, + .debug =3D debug }; g_autofree char *schemapatharguments =3D g_strdup_printf("%s/arg-type"= , command); g_autoptr(virJSONValue) emptyargs =3D NULL; virJSONValuePtr schemarootcommand; @@ -538,7 +538,7 @@ testQEMUSchemaValidateCommand(const char *command, return -1; } - return testQEMUSchemaValidateRecurse(arguments, schemarootarguments, s= chema, debug); + return testQEMUSchemaValidateRecurse(arguments, schemarootarguments, &= ctxt); } --=20 2.26.2 From nobody Fri May 3 02:16:29 2024 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 From nobody Fri May 3 02:16:29 2024 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=1588186273; cv=none; d=zohomail.com; s=zohoarc; b=AsN4OZYF15mQ7uH2EXxnkrxV4wZwIOkRNQm256lYtO0dyHL5uT8EnDwfbeFQDkuv3lSe9Q0xfbfqd3DtCxbedsvCujkM09X7GGZyffb/znevBr9u1q/yC3VFkk8RpJjVyIbK4zoWuQ+lAV+nn9V0v8/zdLVPOIvXaH1UTtFGduQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588186273; 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=OlTEW8DpZ33xTSK4FAQopnhN/8BI1uPeAAOLXyyEm8E=; b=F5cswNNsiLmYgZTLg+yYP+l9UdPHwyhNbT78pJ4YON11GSdCaOPkwNkKbtaD7bRH5+12gVZQFqStCvpxPB7Y6SpHRPVL4kFEqUYUGSAnHHgFXf1Ew2w0iwnUXMThJelXk+iLfsP+Z2cQJS/u1EjAACViX5QnlsGJUhOut1ylf1Y= 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 1588186273147276.2131914968413; Wed, 29 Apr 2020 11:51:13 -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-359-eMc3Q9fxOtCKGhbzKGj6Iw-1; Wed, 29 Apr 2020 14:50:01 -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 C58208064DF; Wed, 29 Apr 2020 18: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 A049C605CD; Wed, 29 Apr 2020 18: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 605FD180530B; Wed, 29 Apr 2020 18:49:55 +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 03TInVpw001577 for ; Wed, 29 Apr 2020 14:49:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id F30365C241; 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 6A9E85C1BE for ; Wed, 29 Apr 2020 18:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588186271; 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=OlTEW8DpZ33xTSK4FAQopnhN/8BI1uPeAAOLXyyEm8E=; b=VweNRyU8+uAi1EpoiXQTQvTbabyZsTqu5oGdjvqxs6zYuotLcyrdhgrkI+5K7YPqDA2hNU CWfTllfZBXV7CNgh5dZtRsWbHPz9lYIJF/Sn1BxYk5aPEjQew47QDChqaFRibDUPq8/TtL lRci9O9MsuHKky9zzW/Qe9zYjyUscTA= X-MC-Unique: eMc3Q9fxOtCKGhbzKGj6Iw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/15] testQemuHotplugCpuPrepare: Allow deprecated commands for non-modern cpu hotplug test Date: Wed, 29 Apr 2020 20:49:09 +0200 Message-Id: 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.79 on 10.5.11.11 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" We have a few cases validating that the code behaves correctly in pre-modern hotplug era. This is controled by the 'modern' flag for the test. Since 'cpu-add' command is now deprecated in qemu, there is a modern replacement for it, and the test output is checked against expected commands we can skip schema validation for the legacy command. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemuhotplugtest.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 849e7e7636..724f640aef 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -457,6 +457,9 @@ testQemuHotplugCpuPrepare(const char *test, if (fail) qemuMonitorTestAllowUnusedCommands(data->mon); + if (!data->modern) + qemuMonitorTestSkipDeprecatedValidation(data->mon, true); + priv->mon =3D qemuMonitorTestGetMonitor(data->mon); virObjectUnlock(priv->mon); --=20 2.26.2 From nobody Fri May 3 02:16:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.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 205.139.110.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=1588186201; cv=none; d=zohomail.com; s=zohoarc; b=cYhxy+dfRfrOa7a/RHuBEYoyjJxPUs1H6ElWyOSEEyB8pu0Fk9GP79ZRYQUI47wpQcytV+ExE3BU/fGtdHsnfMEILMjfQbQJDNx4fiEAj9b9Q43+VpaqjSqZd4JtIJU8/pEK15GTj0d023stM6IFxmt9hYpJzGlAqIudbDahZa0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588186201; 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=VFVdHRClWjyrWpM4jZI2PhReQy5kfPmjs17L0/q4VnQ=; b=iF6JBbRAWGWG/EAeRDwYDL9k1OoiFI8XRiTr345uKfZ/JmOWbQrbUfazRwh9AwV4ymvucqfPZtKorXN6+6D1Kg6ubZ8mmJrVs8OwgqbvSL4tBUKC2Pv1WO9mAh+jgAeMtlyMFIx7G+VWfM7558N+7sDt4KeNUQGnlYd0Ih6FTlY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.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 [205.139.110.120]) by mx.zohomail.com with SMTPS id 1588186201016468.4825303383368; Wed, 29 Apr 2020 11: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-2-zusR2IArPNWt_c5FSwrOkw-1; Wed, 29 Apr 2020 14:49:57 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9EFF264ADE; 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 75FDB5D790; 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 2EDFA4CAA7; 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 03TInVnp001583 for ; Wed, 29 Apr 2020 14:49:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id DB46E5C241; Wed, 29 Apr 2020 18:49:31 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 542AF5C1BE for ; Wed, 29 Apr 2020 18:49:31 +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=VFVdHRClWjyrWpM4jZI2PhReQy5kfPmjs17L0/q4VnQ=; b=D7Ieg6qHtBJ20u2LGoaXM3D3FbPMqAGwsmb8RZBJbAs7O8nOb95Qt/VOenHrot95h/Hlb7 357oQqDr4AvIvJ4h0t43ALtBKOkScrxF80Owm8sGw42fYn54QD903ilOEmVt+cyR7C4qMl fUVqHaA8ceQ6eiF2aflv8IW3XNMQODE= X-MC-Unique: zusR2IArPNWt_c5FSwrOkw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/15] qemumonitorjsontest: Add infrastructure for generated tests of deprecated commands Date: Wed, 29 Apr 2020 20:49:10 +0200 Message-Id: <5524f18f5064f83c0e3bb7ba0caeb2bce1dc8eb5.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.79 on 10.5.11.15 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" For sanity-chcecking of deprecated commands which are still used on some old code paths which used the simple generated test cases add a mechanism to mark them as deprecated so schema checking can be skipped. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemumonitorjsontest.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index fce88083b9..33bad45b96 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -46,6 +46,8 @@ struct _testQemuMonitorJSONSimpleFuncData { virDomainXMLOptionPtr xmlopt; const char *reply; virHashTablePtr schema; + bool allowDeprecated; + bool allowRemoved; }; typedef struct _testGenericData testGenericData; @@ -1278,6 +1280,9 @@ testQemuMonitorJSON ## funcName(const void *opaque) \ \ if (!(test =3D qemuMonitorTestNewSchema(xmlopt, data->schema))) \ return -1; \ + \ + if (data->allowDeprecated) \ + qemuMonitorTestSkipDeprecatedValidation(test, data->allowRemoved);= \ \ if (!reply) \ reply =3D "{\"return\":{}}"; \ @@ -3121,13 +3126,19 @@ mymain(void) if (virTestRun(# FNC, testQemuMonitorJSONSimpleFunc, &simpleFunc) < 0)= \ ret =3D -1 -#define DO_TEST_GEN(name, ...) \ +#define DO_TEST_GEN_FULL(name, dpr, rmvd, ...) \ simpleFunc =3D (testQemuMonitorJSONSimpleFuncData) {.xmlopt =3D driver= .xmlopt, \ + .allowDeprecated =3D= dpr, \ + .allowRemoved =3D rm= vd, \ .schema =3D qapiData= .schema \ __VA_ARGS__ }; \ if (virTestRun(# name, testQemuMonitorJSON ## name, &simpleFunc) < 0) \ ret =3D -1 +#define DO_TEST_GEN(name, ...) DO_TEST_GEN_FULL(name, false, false, __VA_A= RGS__) +#define DO_TEST_GEN_DEPRECATED(name, removed, ...) \ + DO_TEST_GEN_FULL(name, true, removed, __VA_ARGS__) + #define DO_TEST_CPU_DATA(name) \ do { \ struct testCPUData data =3D { name, driver.xmlopt, qapiData.schema= }; \ --=20 2.26.2 From nobody Fri May 3 02:16:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.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 205.139.110.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=1588186338; cv=none; d=zohomail.com; s=zohoarc; b=kPPlgahyhZ6z4U//rqMGSagdhz9Q6dbm0C2nyyNYDPttb2WjHP6mrsZoombJ5v8ti6ngxlzpkjIMGnXrWEX5vPVym8ivIDSnVFQRKIb1LDzwbrb7dUQ9huLl/+lzZsIgSGjS9B6VHlaVG/48Gw08Dc6nFtDqnhjRGorZ5bsoBuU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588186338; 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=KGLdscKo112qaEU0B5NoSm41U/s6pQ7BHk7jrOvx/fs=; b=MmKM1kyfgbXuF78ne9mKUx7fsBEBJcDunFHgAUbb195oltYpfV/QbUDs18ZfLb7xhMMjG52pWemEN/WwTvoC15y1Tv1E950p/cBfVTJF1UqYEoG59MER29nrt6Ljg2a1+NqhSynFril8BQMcB6qKyi4oZwdoYLHub+z+G9kAZWM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.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 [205.139.110.120]) by mx.zohomail.com with SMTPS id 1588186338994647.6656418930297; Wed, 29 Apr 2020 11:52:18 -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-486-nnvC75ZwPYWQBxSH1KXqJw-1; Wed, 29 Apr 2020 14:50:01 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 049EB19200C3; Wed, 29 Apr 2020 18:49:55 +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 D43B65D780; Wed, 29 Apr 2020 18:49:54 +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 965594E586; Wed, 29 Apr 2020 18:49:54 +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 03TInWr3001588 for ; Wed, 29 Apr 2020 14:49:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id C74825C241; Wed, 29 Apr 2020 18:49:32 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42E9F5C1BE for ; Wed, 29 Apr 2020 18:49:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588186337; 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=KGLdscKo112qaEU0B5NoSm41U/s6pQ7BHk7jrOvx/fs=; b=YMXWsUJJIAwfFukwpVkWDEy5+TTSNRLdt4CDrBfc3KEnvNzL09gbYCgZM1czKKP4OhgsXp H1BerURqzVnqJEd1LqUJhGCDPJdk2CLwMTKR00CpODAZkhPIT8RRRq4p/xca8af8Ob4QGt JGqUPpAwXh8D7MDK9tfmOX7ewsIDlFU= X-MC-Unique: nnvC75ZwPYWQBxSH1KXqJw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/15] testQemuMonitorJSONqemuMonitorJSONQueryCPUs: Split off test for query-cpus-fast Date: Wed, 29 Apr 2020 20:49:11 +0200 Message-Id: <06a91c5b1cbc034a18c0b11d5f4e69c050173423.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.79 on 10.5.11.15 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" Separate the test for the newer command into a new function. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemumonitorjsontest.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 33bad45b96..7e0ab4609c 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1435,10 +1435,6 @@ testQemuMonitorJSONqemuMonitorJSONQueryCPUs(const vo= id *opaque) {2, 17626, (char *) "/machine/unattached/device[2]", true}, {3, 17628, NULL, true}, }; - struct qemuMonitorQueryCpusEntry expect_fast[] =3D { - {0, 17629, (char *) "/machine/unattached/device[0]", false}, - {1, 17630, (char *) "/machine/unattached/device[1]", false}, - }; g_autoptr(qemuMonitorTest) test =3D NULL; if (!(test =3D qemuMonitorTestNewSchema(xmlopt, data->schema))) @@ -1483,6 +1479,29 @@ testQemuMonitorJSONqemuMonitorJSONQueryCPUs(const vo= id *opaque) "}") < 0) return -1; + /* query-cpus */ + if (testQEMUMonitorJSONqemuMonitorJSONQueryCPUsHelper(test, expect_slo= w, + false, 4)) + return -1; + + return 0; +} + + +static int +testQemuMonitorJSONqemuMonitorJSONQueryCPUsFast(const void *opaque) +{ + const testGenericData *data =3D opaque; + virDomainXMLOptionPtr xmlopt =3D data->xmlopt; + struct qemuMonitorQueryCpusEntry expect_fast[] =3D { + {0, 17629, (char *) "/machine/unattached/device[0]", false}, + {1, 17630, (char *) "/machine/unattached/device[1]", false}, + }; + g_autoptr(qemuMonitorTest) test =3D NULL; + + if (!(test =3D qemuMonitorTestNewSchema(xmlopt, data->schema))) + return -1; + if (qemuMonitorTestAddItem(test, "query-cpus-fast", "{" " \"return\": [" @@ -1501,11 +1520,6 @@ testQemuMonitorJSONqemuMonitorJSONQueryCPUs(const vo= id *opaque) "}") < 0) return -1; - /* query-cpus */ - if (testQEMUMonitorJSONqemuMonitorJSONQueryCPUsHelper(test, expect_slo= w, - false, 4)) - return -1; - /* query-cpus-fast */ if (testQEMUMonitorJSONqemuMonitorJSONQueryCPUsHelper(test, expect_fas= t, true, 2)) @@ -3236,6 +3250,7 @@ mymain(void) DO_TEST(qemuMonitorJSONGetTargetArch); DO_TEST(qemuMonitorJSONGetMigrationCapabilities); DO_TEST(qemuMonitorJSONQueryCPUs); + DO_TEST(qemuMonitorJSONQueryCPUsFast); DO_TEST(qemuMonitorJSONGetVirtType); DO_TEST(qemuMonitorJSONSendKey); DO_TEST(qemuMonitorJSONGetDumpGuestMemoryCapability); --=20 2.26.2 From nobody Fri May 3 02:16:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 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=1588186191; cv=none; d=zohomail.com; s=zohoarc; b=Xa1Ur+CqrU9toc7hcXMy9VpOug08AauegDsO151aQgd0HL0/+1wwpIDK6KC02hUmImDfHhwTz8QTCK6iEi2HriXixS0cjqBpY5xcLi9Bm75MXK3JKW1NSYE6epbaHqUXZxZ2sQ29ndjcZBSVrZK2dLJgtGRvPOh+XBdFVm6gAYk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588186191; 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=cS5tw5szirb18YdN64SlZ8Gad6u6qzm6IDhCrYXNlFg=; b=MS8zu47kIB1eQbA22U42J2VaY0yqC4imXbEDB0VAEAlBci4XwHfVyLPucOqmUOzVWb9cB+IuRMXq3eDF3qzW53NH3gN3ROIQMzGxRKZ1F94CQPms45MNTc4rbUl1HTGD8vm7E7B+pMk4dhuSrJwjL/119H18X4W7vtlFq2hAPyM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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 [205.139.110.61]) by mx.zohomail.com with SMTPS id 1588186191864202.36058563249912; Wed, 29 Apr 2020 11:49:51 -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-282-kFdnjI43OHeiJNcJFWqL-Q-1; Wed, 29 Apr 2020 14:49:48 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D7429107ACF3; Wed, 29 Apr 2020 18:49:42 +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 B5C705D781; Wed, 29 Apr 2020 18:49:42 +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 7658A4CAAE; Wed, 29 Apr 2020 18:49:42 +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 03TInXI3001598 for ; Wed, 29 Apr 2020 14:49:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id B66005C241; Wed, 29 Apr 2020 18:49:33 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CC045C1BE for ; Wed, 29 Apr 2020 18:49:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588186190; 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=cS5tw5szirb18YdN64SlZ8Gad6u6qzm6IDhCrYXNlFg=; b=ci0smAkMYIehN8zH93bYT8zUPZYGLMV6bbDf6MXGlkiOvwGIWmLFIUX0CmBRFmvPezOOo0 NQWaYJErqsESliRy3BeZMWOidepyhB1ZWy6WIHDyrtj0jXlVNgn8bgDCDyieuPNSplR07A aXSNRDctOa9dPfXAee6nnOcqb3RA2Vk= X-MC-Unique: kFdnjI43OHeiJNcJFWqL-Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/15] qemumonitorjsontest: Allow use of deprecated 'query-cpus' Date: Wed, 29 Apr 2020 20:49:12 +0200 Message-Id: <984a6b8817ae497ed0cf67e38298efa000d8eef9.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.79 on 10.5.11.15 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" The command was replaced with 'query-cpus-fast' which is always used when detected by the capabilities so we can allow our test usage of the deprecated command even if it will be removed from the schema. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemumonitorjsontest.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 7e0ab4609c..eaaabe9a47 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1440,6 +1440,8 @@ testQemuMonitorJSONqemuMonitorJSONQueryCPUs(const voi= d *opaque) if (!(test =3D qemuMonitorTestNewSchema(xmlopt, data->schema))) return -1; + qemuMonitorTestSkipDeprecatedValidation(test, true); + if (qemuMonitorTestAddItem(test, "query-cpus", "{" " \"return\": [" @@ -2696,10 +2698,12 @@ testQemuMonitorCPUInfo(const void *opaque) queryHotpluggableStr) < 0) goto cleanup; - if (data->fast) + if (data->fast) { queryCpusFunction =3D "query-cpus-fast"; - else + } else { queryCpusFunction =3D "query-cpus"; + qemuMonitorTestSkipDeprecatedValidation(test, true); + } if (qemuMonitorTestAddItem(test, queryCpusFunction, queryCpusStr) < 0) goto cleanup; --=20 2.26.2 From nobody Fri May 3 02:16:29 2024 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=1588186199; cv=none; d=zohomail.com; s=zohoarc; b=MTvNjBAyUXXXL9/+DX7gXfTX6P0a6lFyqyBbUOyIW35PcSgrE79wdGmBxcAnos4Jf4FrQetc30pvkuDBQZbuT2xM3C5g/WIW07wpCnHgN82oTOnE3O/fKfVWbrPP7Byb/HvJpCrPzWhTuuB0cwLuMsAFKDIDrRmqm4OO4TQlN2U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588186199; 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=Im1dhq77fBm2ofOpFYH55ro1Fv1T/4/VWpKy79EGUNE=; b=iLPDa8MmKnP3fuGwvYH1SgwWJlLdVEI+pA3jX9/eFvJ/IBGHYSN6+E5YD9DHcKbfOttaJi/qJdVvAUNhmfudlnJSNgfdHlEeoL3CJhq7MU0a9fckma+Mh2BEDtc+/KA6sWlqgSampzOkurJO6lvXdn3q+ApfuyOETuY+F7rhMY8= 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 1588186199190259.58652639918637; Wed, 29 Apr 2020 11:49:59 -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-427-HeLnPwTGNW2OpcYAJxypJA-1; Wed, 29 Apr 2020 14:49:53 -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 E289B8015CE; Wed, 29 Apr 2020 18:49:46 +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 B935E66064; Wed, 29 Apr 2020 18:49:46 +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 765EC4CAB0; Wed, 29 Apr 2020 18:49:46 +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 03TInYTD001610 for ; Wed, 29 Apr 2020 14:49:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id A66E95C241; Wed, 29 Apr 2020 18:49:34 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D41C5C1BE for ; Wed, 29 Apr 2020 18:49:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588186198; 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=Im1dhq77fBm2ofOpFYH55ro1Fv1T/4/VWpKy79EGUNE=; b=ZKgtHkLUuFykMn/FbLtREayy3xoSW/BcDHxu/3kjPONJa9SgKZNzvG8oNEy+5gd7flY6Nt BmwqqGTsMxe//RDBsysDMNhm/2Fsld9U86oPl2ACbtutMLG9kBjQSv/9KCLsYe9gnTevT+ vN8obianEI+DLMHGwE49sXVtuP2AsUU= X-MC-Unique: HeLnPwTGNW2OpcYAJxypJA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/15] qemumonitorjsontest: Allow use of deprecated 'cpu-add' and 'change' command Date: Wed, 29 Apr 2020 20:49:13 +0200 Message-Id: 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.79 on 10.5.11.13 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" Modify the generated test cases for the 'cpu-add' and 'change' command which are deprecated by qemu. We now use device-add and blockdev-change-media instead so we are okay if they will be removed. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemumonitorjsontest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index eaaabe9a47..82a8122f29 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -3214,9 +3214,9 @@ mymain(void) DO_TEST_GEN(qemuMonitorJSONSetPassword); DO_TEST_GEN(qemuMonitorJSONExpirePassword); DO_TEST_GEN(qemuMonitorJSONSetBalloon); - DO_TEST_GEN(qemuMonitorJSONSetCPU); + DO_TEST_GEN_DEPRECATED(qemuMonitorJSONSetCPU, true); DO_TEST_GEN(qemuMonitorJSONEjectMedia); - DO_TEST_GEN(qemuMonitorJSONChangeMedia); + DO_TEST_GEN_DEPRECATED(qemuMonitorJSONChangeMedia, true); DO_TEST_GEN(qemuMonitorJSONSaveVirtualMemory); DO_TEST_GEN(qemuMonitorJSONSavePhysicalMemory); DO_TEST_GEN(qemuMonitorJSONSetMigrationSpeed); --=20 2.26.2 From nobody Fri May 3 02:16:29 2024 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=1588186207; cv=none; d=zohomail.com; s=zohoarc; b=ZsP3Bs8hcRo4wWD74GkBHv06cd5pyEzO6A15We6/4Km3/7QaKab+0hr4rE11MfoTPtfzn5Hh+vzCvelmZJPMbs7Me16BRyg6+wc6MlZz+M9jE7rn5zEJbrM0ha5udacUxTXoMAWhWzSHyWh0tsUGQk8w15++cykL/HVuNWOpYvQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588186207; 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=/YB1E6sv9uYIoJcBvers/UW095keU7kbjSzpdhT/GBg=; b=Mtq4V1oP8NWpz8xLckyHKRArX6aMOUG4NykXiRKaWx5A+cHdtx1Xe+bgNyK8F5QWh8CNDHOiGOOfnJrR2tWID6roRM1MYrLiclzPBdsWn06sjNKoQIk2hEqe9v/Q2sfIaJZNwfdfCkOdg66wZwpFNNMx/X2lbFrfGN7+QSnRNns= 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 158818620776365.33143995390458; Wed, 29 Apr 2020 11:50:07 -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-87-G8myNP2KMQSi98emVsV1qA-1; Wed, 29 Apr 2020 14:50:03 -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 350E1835B40; Wed, 29 Apr 2020 18:49:58 +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 11F3E5D9E5; Wed, 29 Apr 2020 18: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 C5DD91805310; Wed, 29 Apr 2020 18:49:57 +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 03TInelm001652 for ; Wed, 29 Apr 2020 14:49:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id F3D2F5C254; Wed, 29 Apr 2020 18:49:39 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 69FFA5C241 for ; Wed, 29 Apr 2020 18:49:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588186206; 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=/YB1E6sv9uYIoJcBvers/UW095keU7kbjSzpdhT/GBg=; b=VyXY3nosRZMUY4TcmwNLguRxrMPjkeVkD/oQz/f3fyDkRHMJ+TApUnV4qK3xSFQc/skOtd xrGwOpvsKCRYqk4t1WOOMKy8U5zlI9G+fP+nC9eyyZqALd660sCXpLBKH/dmFNiOF+UF/7 kkmmi3VNUQEgoGtuc8Ns0mEQpVAMwE8= X-MC-Unique: G8myNP2KMQSi98emVsV1qA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/15] qemumonitorjsontest: Mark recently deprecated migration command in our tests Date: Wed, 29 Apr 2020 20:49:14 +0200 Message-Id: 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.79 on 10.5.11.14 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" "migrate_set_downtime", "migrate_set_speed", and "query-migrate-cache-size" were marked as deprecated in the QMP schema in qemu 5.0. Since libvirt still actively uses them we must not mark them as okay to be missing, but still mark them as deprecated, so that we can add tests for deprecated commands. The replacement of the command usage in libvirt is tracked by: https://bugzilla.redhat.com/show_bug.cgi?id=3D1829543 https://bugzilla.redhat.com/show_bug.cgi?id=3D1829544 https://bugzilla.redhat.com/show_bug.cgi?id=3D1829545 Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemumonitorjsontest.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 82a8122f29..f58b18a110 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1889,6 +1889,8 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationCacheSi= ze(const void *opaque) if (!(test =3D qemuMonitorTestNewSchema(xmlopt, data->schema))) return -1; + qemuMonitorTestSkipDeprecatedValidation(test, false); + if (qemuMonitorTestAddItem(test, "query-migrate-cache-size", "{" " \"return\": 67108864," @@ -3219,8 +3221,8 @@ mymain(void) DO_TEST_GEN_DEPRECATED(qemuMonitorJSONChangeMedia, true); DO_TEST_GEN(qemuMonitorJSONSaveVirtualMemory); DO_TEST_GEN(qemuMonitorJSONSavePhysicalMemory); - DO_TEST_GEN(qemuMonitorJSONSetMigrationSpeed); - DO_TEST_GEN(qemuMonitorJSONSetMigrationDowntime); + DO_TEST_GEN_DEPRECATED(qemuMonitorJSONSetMigrationSpeed, false); + DO_TEST_GEN_DEPRECATED(qemuMonitorJSONSetMigrationDowntime, false); DO_TEST_GEN(qemuMonitorJSONMigrate); DO_TEST_GEN(qemuMonitorJSONDump); DO_TEST_GEN(qemuMonitorJSONGraphicsRelocate); --=20 2.26.2 From nobody Fri May 3 02:16:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.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 205.139.110.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=1588186327; cv=none; d=zohomail.com; s=zohoarc; b=hMaqfZMXFzusGW7P4GGXov75RKQpwqYQIaFf3TaWAINfYkDH55imUkgrD7Y+ObxUMBc4U9hbPhvh3yOCxPDRMvMMDJwjIT5OVw/EEoUIE87j5pg18Vp/bER3eonsAALKNQ6Vqn6EKH0eVudN4daycDlOxSJxUq/xg3zphw4O75E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588186327; 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=4fx4l0Pwx8RPkwlKSSgdINfjsdC0cdsyqSfeovhliZU=; b=UdELk4WWE3QROEADDSfFPvE6Y/WAbZ3LhVHamJPk6Q0ehoc0rTQfWl5QcYnp8vxMv4BRXpRYTl7FU+aSJbkIFzbk6vv5KVlCXViZpUQPrBVWx48zd01fpxG9V220OLyfLFBjCpfw3RBjgmuqGQWNvTb3FyzdBBSBNElN3OGnkNk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.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 [205.139.110.120]) by mx.zohomail.com with SMTPS id 1588186327038959.4324170317965; Wed, 29 Apr 2020 11:52:07 -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-365-kPfLZOI1NN26hFs6rKmZog-1; Wed, 29 Apr 2020 14:50:04 -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 200A4107ACCD; Wed, 29 Apr 2020 18:49:59 +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 EDD355D9E5; Wed, 29 Apr 2020 18: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 A5F874E588; Wed, 29 Apr 2020 18:49:58 +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 03TIngRv001667 for ; Wed, 29 Apr 2020 14:49:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 946165C241; Wed, 29 Apr 2020 18:49:42 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D8705C254 for ; Wed, 29 Apr 2020 18:49:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588186325; 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=4fx4l0Pwx8RPkwlKSSgdINfjsdC0cdsyqSfeovhliZU=; b=IOFDLeTPJGKCRhjNlpbcSdWw7XHii6wv35vDKv7asWursYuL80DaJrN88OaQAkKTcNpzes a/HmTDD3P6vsAq8d5qcqUMxfC0Cgr9bdudXcBXHkD9/8bu/immmbo1HXjd6XKcwujZ0Ohc Hjn6HkrKfRSc/CLAkyl9BOL6piNPI04= X-MC-Unique: kPfLZOI1NN26hFs6rKmZog-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 15/15] testQEMUSchemaValidate*: Reject usage of fields with 'deprecated' set Date: Wed, 29 Apr 2020 20:49:15 +0200 Message-Id: <208da2c7c40322d2224c376c0d866717a41321e9.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.79 on 10.5.11.14 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" Make our QMP schema validator reject any use of schema entries which were deprecated by QEMU except for those whitelisted. This will allow us to catch this before qemu actually removed what we'd still use. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/testutilsqemuschema.c | 54 ++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/tests/testutilsqemuschema.c b/tests/testutilsqemuschema.c index f94a415b18..898be68b0a 100644 --- a/tests/testutilsqemuschema.c +++ b/tests/testutilsqemuschema.c @@ -445,6 +445,47 @@ testQEMUSchemaValidateAlternate(virJSONValuePtr obj, } +static int +testQEMUSchemaValidateDeprecated(virJSONValuePtr root, + const char *name, + struct testQEMUSchemaValidateCtxt *ctxt) +{ + virJSONValuePtr features =3D virJSONValueObjectGetArray(root, "feature= s"); + size_t nfeatures; + size_t i; + + if (!features) + return 0; + + nfeatures =3D virJSONValueArraySize(features); + + for (i =3D 0; i < nfeatures; i++) { + virJSONValuePtr 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(virJSONValuePtr obj, virJSONValuePtr root, @@ -452,6 +493,10 @@ testQEMUSchemaValidateRecurse(virJSONValuePtr obj, { const char *n =3D virJSONValueObjectGetString(root, "name"); const char *t =3D virJSONValueObjectGetString(root, "meta-type"); + int rc; + + if ((rc =3D testQEMUSchemaValidateDeprecated(root, n, ctxt)) < 0) + return rc; if (STREQ_NULLABLE(t, "builtin")) { return testQEMUSchemaValidateBuiltin(obj, root, ctxt); @@ -525,7 +570,7 @@ testQEMUSchemaValidateCommand(const char *command, virJSONValuePtr arguments, virHashTablePtr schema, bool allowDeprecated, - bool allowRemoved G_GNUC_UNUSED, + bool allowRemoved, virBufferPtr debug) { struct testQEMUSchemaValidateCtxt ctxt =3D { .schema =3D schema, @@ -535,13 +580,20 @@ testQEMUSchemaValidateCommand(const char *command, g_autoptr(virJSONValue) emptyargs =3D NULL; virJSONValuePtr schemarootcommand; virJSONValuePtr schemarootarguments; + int rc; if (virQEMUQAPISchemaPathGet(command, schema, &schemarootcommand) < 0 = || !schemarootcommand) { + if (allowRemoved) + return 0; + virBufferAsprintf(debug, "ERROR: command '%s' not found in the sch= ema", command); return -1; } + if ((rc =3D testQEMUSchemaValidateDeprecated(schemarootcommand, comman= d, &ctxt)) < 0) + return rc; + if (!arguments) arguments =3D emptyargs =3D virJSONValueNewObject(); --=20 2.26.2