From nobody Tue Nov 26 23:41:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1562387900; cv=none; d=zoho.com; s=zohoarc; b=FmoZoH3zWQSQZXUW3qkpJELL95AFPRq8Wcj5p97gWLaziMWQjGQyupeEfyI/cdYG9bNwHhsTOd/hECC1ZHUxjU0J0Y4wtbMOf8+CgI/QSzZO5LAzyV93sbfSFIwYqEZZrJRUZh4Mh5qWG7IqcWmIJFqh69NGJo0xYlhx4/gz75Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562387900; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=lCCIjBtoOrl/ORI8Pu3XtKuorAopsUH/CrC5w/u6co4=; b=A+D/j6bpv6u9dxKZk7mcDbJwVyFaRlU+jVIbI0sDdh8HZNTrYApmL4AalCvKg5a09JPm2WAIlRtYeymeOFdJ1n97HXMcO8ZP+xU0+1MS2n6E9AZdY6wTzd/ydrY8EnYnMjusG3Lp5CPLEX9BeheOJZbmlRBHoGFIv3NOGrXFGiE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562387900873801.2009260513918; Fri, 5 Jul 2019 21:38:20 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 3845D3082A9C; Sat, 6 Jul 2019 04:38:19 +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 10739226FD; Sat, 6 Jul 2019 04:38:19 +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 C80A941F63; Sat, 6 Jul 2019 04:38:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x664bk7S006737 for ; Sat, 6 Jul 2019 00:37:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6A26E1001947; Sat, 6 Jul 2019 04:37:46 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-152.phx2.redhat.com [10.3.116.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 30C841001B04 for ; Sat, 6 Jul 2019 04:37:46 +0000 (UTC) From: Eric Blake To: libvir-list@redhat.com Date: Fri, 5 Jul 2019 23:37:30 -0500 Message-Id: <20190706043735.26284-4-eblake@redhat.com> In-Reply-To: <20190706043735.26284-1-eblake@redhat.com> References: <20190706043735.26284-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/8] snapshot: Add internal option to validate XML against schema X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Sat, 06 Jul 2019 04:38:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Similar to VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA; for now used only by the testsuite, but will be exposed in the public API in the next patch. Signed-off-by: Eric Blake --- src/conf/snapshot_conf.h | 1 + src/conf/snapshot_conf.c | 13 +++++++++++++ tests/qemudomainsnapshotxml2xmltest.c | 3 ++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index 08b2a3b955..a0c87e7ade 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -92,6 +92,7 @@ typedef enum { VIR_DOMAIN_SNAPSHOT_PARSE_DISKS =3D 1 << 1, VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL =3D 1 << 2, VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE =3D 1 << 3, + VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE =3D 1 << 4, } virDomainSnapshotParseFlags; typedef enum { diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index c7f29360e7..daea6c616d 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -25,6 +25,7 @@ #include #include +#include "configmake.h" #include "internal.h" #include "virbitmap.h" #include "virbuffer.h" @@ -409,6 +410,18 @@ virDomainSnapshotDefParseNode(xmlDocPtr xml, goto cleanup; } + if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE) { + VIR_AUTOFREE(char *) schema =3D NULL; + + schema =3D virFileFindResource("domainsnapshot.rng", + abs_top_srcdir "/docs/schemas", + PKGDATADIR "/schemas"); + if (!schema) + return NULL; + if (virXMLValidateAgainstSchema(schema, xml) < 0) + return NULL; + } + ctxt =3D xmlXPathNewContext(xml); if (ctxt =3D=3D NULL) { virReportOOMError(); diff --git a/tests/qemudomainsnapshotxml2xmltest.c b/tests/qemudomainsnapsh= otxml2xmltest.c index 10ea9cf8d2..55cb8575f7 100644 --- a/tests/qemudomainsnapshotxml2xmltest.c +++ b/tests/qemudomainsnapshotxml2xmltest.c @@ -35,7 +35,8 @@ testCompareXMLToXMLFiles(const char *inxml, char *outXmlData =3D NULL; char *actual =3D NULL; int ret =3D -1; - unsigned int parseflags =3D VIR_DOMAIN_SNAPSHOT_PARSE_DISKS; + unsigned int parseflags =3D (VIR_DOMAIN_SNAPSHOT_PARSE_DISKS | + VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE); unsigned int formatflags =3D VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE; bool cur =3D false; VIR_AUTOUNREF(virDomainSnapshotDefPtr) def =3D NULL; --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list