diff options
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" ), |