--- docs/schemas/domainbackup.rng | 79 ++++++++++++++++++++++++++ tests/domainbackupxml/block_target.xml | 5 ++ tests/domainbackupxml/explicit_description.xml | 6 ++ tests/domainbackupxml/explicit_file_type.xml | 5 ++ tests/domainbackupxml/explicit_format.xml | 5 ++ tests/domainbackupxml/explicit_name.xml | 6 ++ tests/domainbackupxml/multi_disk.xml | 8 +++ tests/domainbackupxml/ref_by_path.xml | 5 ++ tests/virschematest.c | 1 + tools/virt-xml-validate.in | 5 +- 10 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 docs/schemas/domainbackup.rng create mode 100644 tests/domainbackupxml/block_target.xml create mode 100644 tests/domainbackupxml/explicit_description.xml create mode 100644 tests/domainbackupxml/explicit_file_type.xml create mode 100644 tests/domainbackupxml/explicit_format.xml create mode 100644 tests/domainbackupxml/explicit_name.xml create mode 100644 tests/domainbackupxml/multi_disk.xml create mode 100644 tests/domainbackupxml/ref_by_path.xml
diff --git a/docs/schemas/domainbackup.rng b/docs/schemas/domainbackup.rng new file mode 100644 index 0000000..4a93dfb --- /dev/null +++ b/docs/schemas/domainbackup.rng @@ -0,0 +1,79 @@ +<?xml version="1.0"?> +<!-- A Relax NG schema for the libvirt domain backup properties XML format --> +<grammar xmlns="http://relaxng.org/ns/structure/1.0"> + <start> + <ref name='domainBackup'/> + </start> + + <include href='domaincommon.rng'/> + + <define name='domainBackup'> + <element name='domainbackup'> + <interleave> + <optional> + <element name='name'> + <text/> + </element> + </optional> + <optional> + <element name='description'> + <text/> + </element> + </optional> + <oneOrMore> + <ref name='diskBackup'/> + </oneOrMore> + </interleave> + </element> + </define> + + <define name='diskBackup'> + <element name='disk'> + <attribute name='name'> + <choice> + <ref name='diskTarget'/> + <ref name='absFilePath'/> + </choice> + </attribute> + <choice> + <ref name="backupTargetFile"/> + <ref name="backupTargetBlock"/> + </choice> + </element> + </define> + + <define name="backupTargetCommon"> + <optional> + <attribute name='format'> + <ref name='storageFormatBacking'/> + </attribute> + </optional> + </define> + + <define name="backupTargetFile"> + <optional> + <attribute name="type"> + <value>file</value> + </attribute> + </optional> + <element name="target"> + <attribute name="file"> + <ref name="absFilePath"/> + </attribute> + <ref name="backupTargetCommon"/> + </element> + </define> + + <define name="backupTargetBlock"> + <attribute name="type"> + <value>block</value> + </attribute> + <element name="target"> + <attribute name="dev"> + <ref name="absFilePath"/> + </attribute> + <ref name="backupTargetCommon"/> + </element> + </define> + +</grammar> diff --git a/tests/domainbackupxml/block_target.xml b/tests/domainbackupxml/block_target.xml new file mode 100644 index 0000000..a7618d1 --- /dev/null +++ b/tests/domainbackupxml/block_target.xml @@ -0,0 +1,5 @@ +<domainbackup> + <disk name="sda" type="block"> + <target dev="/path/to/backup/dev"/> + </disk> +</domainbackup> diff --git a/tests/domainbackupxml/explicit_description.xml b/tests/domainbackupxml/explicit_description.xml new file mode 100644 index 0000000..ea378a4 --- /dev/null +++ b/tests/domainbackupxml/explicit_description.xml @@ -0,0 +1,6 @@ +<domainbackup> + <description>description</description> + <disk name="sda"> + <target file="/path/to/file"/> + </disk> +</domainbackup> diff --git a/tests/domainbackupxml/explicit_file_type.xml b/tests/domainbackupxml/explicit_file_type.xml new file mode 100644 index 0000000..cfc424f --- /dev/null +++ b/tests/domainbackupxml/explicit_file_type.xml @@ -0,0 +1,5 @@ +<domainbackup> + <disk name="sda" type="file"> + <target file="/path/to/backup/file"/> + </disk> +</domainbackup> diff --git a/tests/domainbackupxml/explicit_format.xml b/tests/domainbackupxml/explicit_format.xml new file mode 100644 index 0000000..3151f84 --- /dev/null +++ b/tests/domainbackupxml/explicit_format.xml @@ -0,0 +1,5 @@ +<domainbackup> + <disk name="sda" type="file"> + <target file="/path/to/backup/file" format="qcow2"/> + </disk> +</domainbackup> diff --git a/tests/domainbackupxml/explicit_name.xml b/tests/domainbackupxml/explicit_name.xml new file mode 100644 index 0000000..61f7731 --- /dev/null +++ b/tests/domainbackupxml/explicit_name.xml @@ -0,0 +1,6 @@ +<domainbackup> + <name>name</name> + <disk name="sda"> + <target file="/path/to/file"/> + </disk> +</domainbackup> diff --git a/tests/domainbackupxml/multi_disk.xml b/tests/domainbackupxml/multi_disk.xml new file mode 100644 index 0000000..2d1797f --- /dev/null +++ b/tests/domainbackupxml/multi_disk.xml @@ -0,0 +1,8 @@ +<domainbackup> + <disk name="sda"> + <target file="/path/to/backup/sda"/> + </disk> + <disk name="sdb"> + <target file="/path/to/backup/sdb"/> + </disk> +</domainbackup> diff --git a/tests/domainbackupxml/ref_by_path.xml b/tests/domainbackupxml/ref_by_path.xml new file mode 100644 index 0000000..496fc49 --- /dev/null +++ b/tests/domainbackupxml/ref_by_path.xml @@ -0,0 +1,5 @@ +<domainbackup> + <disk name="/path/to/disk/file"> + <target file="/path/to/backup/file"/> + </disk> +</domainbackup> diff --git a/tests/virschematest.c b/tests/virschematest.c index ffed217..c1624e6 100644 --- a/tests/virschematest.c +++ b/tests/virschematest.c @@ -226,6 +226,7 @@ mymain(void) DO_TEST_DIR("domaincaps.rng", "domaincapsschemadata"); DO_TEST_DIR("domainsnapshot.rng", "domainsnapshotxml2xmlin", "domainsnapshotxml2xmlout"); + DO_TEST_DIR("domainbackup.rng", "domainbackupxml"); DO_TEST_DIR("interface.rng", "interfaceschemadata"); DO_TEST_DIR("network.rng", "../src/network", "networkxml2xmlin", "networkxml2xmlout", "networkxml2confdata"); diff --git a/tools/virt-xml-validate.in b/tools/virt-xml-validate.in index 81fde4d..b890b22 100644 --- a/tools/virt-xml-validate.in +++ b/tools/virt-xml-validate.in @@ -56,9 +56,12 @@ fi if [ -z "$TYPE" ]; then ROOT=`xmllint --stream --debug "$XMLFILE" 2>/dev/null | grep "^0 1 " | awk '{ print $3 }'` case "$ROOT" in - *domainsnapshot*) # Must come first, since *domain* is a substring + *domainsnapshot*) # Must be above domain, since *domain* is a substring TYPE="domainsnapshot" ;; + *domainbackup*) # Must be above domain, since *domain* is a substring + TYPE="domainbackup" + ;; *domain*) TYPE="domain" ;; -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list