diff options
author | Simon Rettberg | 2024-10-23 16:28:06 +0200 |
---|---|---|
committer | Simon Rettberg | 2024-10-23 16:28:06 +0200 |
commit | 3f67ed10bfe493d54a5e6e0ca9dfb30caa5ba395 (patch) | |
tree | c2344740f628bfa2c8c735f6f0bb3abca909fa9e /core | |
parent | [run-virt] Fix DNS blocking (diff) | |
download | mltk-3f67ed10bfe493d54a5e6e0ca9dfb30caa5ba395.tar.gz mltk-3f67ed10bfe493d54a5e6e0ca9dfb30caa5ba395.tar.xz mltk-3f67ed10bfe493d54a5e6e0ca9dfb30caa5ba395.zip |
[qemu] javatool: Add --validate option to check an xml
Diffstat (limited to 'core')
2 files changed, 18 insertions, 0 deletions
diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/App.java b/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/App.java index c89872e7..f5d4b878 100644 --- a/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/App.java +++ b/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/App.java @@ -149,6 +149,18 @@ public class App hypervisor.close(); System.exit( 3 ); } + + // Validation run? + if ( cmdLn.isValidateEnabled() ) { + try { + config.validateXml(); + } catch ( LibvirtXmlValidationException e ) { + // TODO Auto-generated catch block + e.printStackTrace(); + System.exit( 42 ); + } + System.exit( 0 ); + } // create transformation manager to finalize VM configuration final TransformationManager<Domain, CommandLineArgs> transformationManager; diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/cmdln/CommandLineArgs.java b/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/cmdln/CommandLineArgs.java index 1236a997..a2aeef78 100644 --- a/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/cmdln/CommandLineArgs.java +++ b/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/cmdln/CommandLineArgs.java @@ -179,6 +179,11 @@ public class CommandLineArgs { return this.cmdLn.hasOption( CmdLnOption.MANAGER.getShortOption() ); } + + public boolean isValidateEnabled() + { + return this.cmdLn.hasOption( CmdLnOption.VALIDATE.getShortOption() ); + } /** * Returns the state of the command line option {@link CmdLnOption#DEBUG_PTH}. @@ -537,6 +542,7 @@ public class CommandLineArgs VM_CPU_TOPO ( '1', "cputopo", 1, "Set pairs of CPUs belonging to the same thread, semi-colon separated." + " Each group can contain commas or dashes to mark ranges. E.g. 0,1;2-3;4;5;6;7;8,9,10,11" ), MANAGER ( '2', "manager", 0, "Force using virt-manager even if not in debug mode" ), + VALIDATE ( '3', "validate", 0, "Validate input file only, exit immediately with exit code 0 on success, 42 otherwise" ), VM_MAC0 ( 'a', "vmmac0", 1, "MAC address for the first network interface" ), DEBUG ( 'b', "debug", 1, "Enable or disable debug mode" ), VM_NCPUS ( 'c', "vmncpus", 1, "Number of virtual CPUs for the virtual machine" ), |