From 8cf0ed02be4dda0fd8754667e5940f552de9bf85 Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Tue, 6 Apr 2010 11:09:46 -0400 Subject: [PATCH] nwfilter: Add filter schema for nwfilter XML, extend domain XML schema This patch adds a relaxng nwfilter schema along with a test that verifies all the test output XML against the schema. The input XMLs contain a lot of intentional out-of-range values that make them fail the schema verification, so I am not verifying against those. --- docs/schemas/Makefile.am | 3 +- docs/schemas/domain.rng | 31 ++ docs/schemas/nwfilter.rng | 783 ++++++++++++++++++++++++++++++++++++++ libvirt.spec.in | 1 + tests/Makefile.am | 4 +- tests/nwfilterschematest | 10 + 6 files changed, 830 insertions(+), 2 deletions(-) create mode 100644 docs/schemas/nwfilter.rng create mode 100755 tests/nwfilterschematest diff --git a/docs/schemas/Makefile.am b/docs/schemas/Makefile.am index c217d69482..22f9f3f991 100644 --- a/docs/schemas/Makefile.am +++ b/docs/schemas/Makefile.am @@ -10,6 +10,7 @@ schema_DATA = \ storagepool.rng \ storagevol.rng \ nodedev.rng \ - capability.rng + capability.rng \ + nwfilter.rng EXTRA_DIST = $(schema_DATA) diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng index 228665c6a4..58c9fcb253 100644 --- a/docs/schemas/domain.rng +++ b/docs/schemas/domain.rng @@ -894,6 +894,11 @@ + + + + + + + + + + + + + + root + arp + ipv4 + ipv6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + yes + no + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [a-fA-F0-9]{32} + + + + [a-fA-F0-9]{8}\-([a-fA-F0-9]{4}\-){3}[a-fA-F0-9]{12} + + + + + + + + + [\\$]{1}[a-zA-Z0-9_]+ + + + + ([a-fA-F0-9]{1,2}:){5}[a-fA-F0-9]{1,2} + + + + + + + + + [\\$]{1}[a-zA-Z0-9_]+ + + + + ([0-2]?[0-9]?[0-9]\.){3}[0-2]?[0-9]?[0-9] + + + + + + + + + ^[\\$]{1}[a-zA-Z0-9_]+$ + + + + ([a-fA-F0-9]{0,4}:){2,7}([a-fA-F0-9]*)(([0-2]?[0-9]?[0-9]\.){3}[0-2]?[0-9]?[0-9])? + + + + + + + + + ^[\\$]{1}[a-zA-Z0-9_]+$ + + + + 0 + 32 + + + + ([0-2]?[0-9]?[0-9]\.){3}[0-2]?[0-9]?[0-9] + + + + + + + + + ^[\\$]{1}[a-zA-Z0-9_]+$ + + + + 0 + 128 + + + + ([a-fA-F0-9]{0,4}:){2,7}([a-fA-F0-9]*) + + + + + + + + + ^[\\$]{1}[a-zA-Z0-9_]+$ + + + + 0 + 63 + + + + + + + + + ^[\\$]{1}[a-zA-Z0-9_]+$ + + + + 1536 + 65535 + + + + arp + ipv4 + ipv6 + + + + + + + + + ^[\\$]{1}[a-zA-Z0-9_]+$ + + + + 0 + 255 + + + + + + + + + ^[\\$]{1}[a-zA-Z0-9_]+$ + + + + 0 + 65535 + + + + + + + + + ^[\\$]{1}[a-zA-Z0-9_]+$ + + + + 0 + 65535 + + + + ([Rr]eply|[Rr]equest|[Rr]equest_[Rr]everse|[Rr]eply_[Rr]everse|DRARP_[Rr]equest|DRARP_[Rr]eply|DRARP_[Ee]rror|InARP_[Rr]equest|ARP_NAK) + + + + + + + + + + ^[\\$]{1}[a-zA-Z0-9_]+$ + + + + 0 + 255 + + + + tcp + udp + udplite + esp + ah + icmp + igmp + sctp + icmpv6 + + + + + + + [a-zA-Z0-9_]+ + + + + + + [a-zA-Z0-9_\.:]+ + + + + + + drop + accept + + + + + + in + out + inout + + + + + + 0 + 1000 + + + diff --git a/libvirt.spec.in b/libvirt.spec.in index 21e311c0ed..dcbc139dcb 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -785,6 +785,7 @@ fi %{_datadir}/libvirt/schemas/interface.rng %{_datadir}/libvirt/schemas/secret.rng %{_datadir}/libvirt/schemas/storageencryption.rng +%{_datadir}/libvirt/schemas/nwfilter.rng %{_datadir}/libvirt/cpu_map.xml diff --git a/tests/Makefile.am b/tests/Makefile.am index 883d1ace9b..ef12386cdd 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -74,6 +74,7 @@ EXTRA_DIST = \ xml2vmxdata \ nwfilterxml2xmlout \ nwfilterxml2xmlin \ + nwfilterschematest \ $(patsubst %,qemuhelpdata/%,$(qemuhelpdata)) noinst_PROGRAMS = virshtest conftest \ @@ -120,7 +121,8 @@ test_scripts = \ storagepoolschematest \ storagevolschematest \ domainschematest \ - nodedevschematest + nodedevschematest \ + nwfilterschematest if WITH_LIBVIRTD test_scripts += \ diff --git a/tests/nwfilterschematest b/tests/nwfilterschematest new file mode 100755 index 0000000000..2c50c03322 --- /dev/null +++ b/tests/nwfilterschematest @@ -0,0 +1,10 @@ +#!/bin/sh + +: ${srcdir=.} +. $srcdir/test-lib.sh +. $abs_srcdir/schematestutils.sh + +DIRS="nwfilterxml2xmlout" +SCHEMA="nwfilter.rng" + +check_schema "$DIRS" "$SCHEMA"