From nobody Thu May 2 11:27:05 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=1598269400; cv=none; d=zohomail.com; s=zohoarc; b=Itt7CpEyaoGt3+++gGJMd3TjPezu9HXuWtNS5FdXX2oivDQOcDleiPxFUf4G392asJMazvZNpm65Kl8T6Ve+iyZtzVavApTVpcFdRMsRK61ekzPsCVhMxG8QdbaRuFYacyf6E3++o6l0VkcKfRWVOuY9PZvQpReEPng8Qxkoi6w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598269400; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=sQtsJsxoaz6OSAQ3tKdnI03VBC4hgy4ByimeTM48qCQ=; b=HesoOEtiFIYOwodc/K6M0/FyF2pUs+0uU71ULMw3QMQ9a00+vcasVNvvDIm/0OEuJRE1ZWjP8j7Rk6PMpdM4tiyopuCsywYlw1VWpzeoeOpN3yebrkLXT2fgXQ17ecrIZpGNiAJy4Lc2X9eh8ZOwA1GaBvKmCp4/UwUaAY8KpCI= 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 1598269400119989.2746912110019; Mon, 24 Aug 2020 04:43:20 -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-439-Z8h6hb7_MBWhlxT0-j0ZqQ-1; Mon, 24 Aug 2020 07:43:15 -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 50DC210ABDBA; Mon, 24 Aug 2020 11:43:10 +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 121142B3AB; Mon, 24 Aug 2020 11:43:09 +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 56AAE668F7; Mon, 24 Aug 2020 11:43:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 07OBh6Nq027782 for ; Mon, 24 Aug 2020 07:43:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4191250AC5; Mon, 24 Aug 2020 11:43:06 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 942467C86D for ; Mon, 24 Aug 2020 11:43:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598269398; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=sQtsJsxoaz6OSAQ3tKdnI03VBC4hgy4ByimeTM48qCQ=; b=C414wb7xX/GFWhJhkh5XF+dlhDYZzI0x4yu0TvSPBxlqIL65Jz6u6IfYgDxydJhbl14vog lIpnOMLqziE5KhYw9XuA9ZwJqkBe0BV9Wkxa1Jqbq15px1Z52CcvC6toKnh96QPK+XkV1R RkbsymbQRrK+DgW0G37y1cRiaU5P2zE= X-MC-Unique: Z8h6hb7_MBWhlxT0-j0ZqQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH] qemumigparamstest: Validate output parameters against QMP schema Date: Mon, 24 Aug 2020 13:43:01 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Ensure that the migration parameters are formatted properly according to the schema. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tests/qemumigparamstest.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/qemumigparamstest.c b/tests/qemumigparamstest.c index 0f7809d763..c4fd575401 100644 --- a/tests/qemumigparamstest.c +++ b/tests/qemumigparamstest.c @@ -22,8 +22,10 @@ #include "virjson.h" #include "virbuffer.h" #include "virxml.h" +#include "virhash.h" #include "testutils.h" #include "testutilsqemu.h" +#include "tests/testutilsqemuschema.h" #include "qemumonitortestutils.h" #include "qemu/qemu_migration_params.h" #define LIBVIRT_QEMU_MIGRATION_PARAMSPRIV_H_ALLOW @@ -36,6 +38,7 @@ typedef struct _qemuMigParamsData qemuMigParamsData; struct _qemuMigParamsData { virDomainXMLOptionPtr xmlopt; const char *name; + virHashTablePtr qmpschema; }; @@ -141,6 +144,7 @@ qemuMigParamsTestJSON(const void *opaque) g_autoptr(virJSONValue) paramsOut =3D NULL; g_autoptr(qemuMigrationParams) migParams =3D NULL; g_autofree char *actualJSON =3D NULL; + g_auto(virBuffer) debug =3D VIR_BUFFER_INITIALIZER; int ret =3D -1; replyFile =3D g_strdup_printf("%s/qemumigparamsdata/%s.reply", @@ -162,6 +166,17 @@ qemuMigParamsTestJSON(const void *opaque) !(actualJSON =3D virJSONValueToString(paramsOut, true))) goto cleanup; + if (testQEMUSchemaValidateCommand("migrate-set-parameters", + paramsOut, + data->qmpschema, + false, + false, + &debug) < 0) { + VIR_TEST_VERBOSE("failed to validate migration params '%s' against= QMP schema: %s", + actualJSON, virBufferCurrentContent(&debug)); + goto cleanup; + } + if (virTestCompareToFile(actualJSON, jsonFile) < 0) goto cleanup; @@ -176,6 +191,7 @@ qemuMigParamsTestJSON(const void *opaque) static int mymain(void) { + g_autoptr(virHashTable) qmpschema =3D NULL; virQEMUDriver driver; int ret =3D 0; @@ -184,10 +200,15 @@ mymain(void) virEventRegisterDefaultImpl(); + if (!(qmpschema =3D testQEMUSchemaLoadLatest("x86_64"))) { + VIR_TEST_VERBOSE("failed to load QMP schema"); + return EXIT_FAILURE; + } + #define DO_TEST(name) \ do { \ qemuMigParamsData data =3D { \ - driver.xmlopt, name \ + driver.xmlopt, name, qmpschema \ }; \ if (virTestRun(name " (xml)", qemuMigParamsTestXML, &data) < 0) \ ret =3D -1; \ --=20 2.26.2