Skip to content

Commit

Permalink
add case for virt-xml-validate for virsh domcap
Browse files Browse the repository at this point in the history
    xxxx-17141:validate libvirt XML files against a virsh domcap schema
Signed-off-by: nanli <[email protected]>
  • Loading branch information
nanli1 committed Dec 19, 2024
1 parent 1aa9ac2 commit 718d617
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions libvirt/tests/cfg/virt_cmd/virt_xml_validate.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@
secret_volume = "/var/lib/libvirt/images/virt_xml_validate.secret"
- interface:
schema = "interface"
- domcapabilities:
schema = "domcapabilities"
15 changes: 14 additions & 1 deletion libvirt/tests/src/virt_cmd/virt_xml_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ def interface_validate(test, file=None, **virsh_dargs):
test.error(str(e))


def domcap_validate(file=None, **virsh_dargs):
"""
Prepare schema domcapabilities.
:param file: domcapabilities output file
:param virsh_dargs: virsh debug args.
"""
cmd_result = virsh.domcapabilities(options="> %s" % file, **virsh_dargs)
libvirt.check_exit_status(cmd_result)


def run(test, params, env):
"""
Test for virt-xml-validate
Expand All @@ -203,7 +213,7 @@ def run(test, params, env):

valid_schemas = ['domain', 'domainsnapshot', 'network', 'storagepool',
'storagevol', 'nodedev', 'capability',
'nwfilter', 'secret', 'interface']
'nwfilter', 'secret', 'interface', 'domcapabilities']
if schema not in valid_schemas:
test.fail("invalid %s specified" % schema)

Expand All @@ -230,6 +240,9 @@ def run(test, params, env):
secret_validate(test, secret_volume, file=output_path, **virsh_dargs)
elif schema == "interface":
interface_validate(test, file=output_path, **virsh_dargs)
elif schema == "domcapabilities":
domcap_validate(file=output_path, **virsh_dargs)
schema = ""
else:
# domain
virsh.dumpxml(vm_name, to_file=output_path)
Expand Down

0 comments on commit 718d617

Please sign in to comment.