Fix typo in manual and add README file.
[mclu.git] / template.ml
index 4db0b66..404ec6b 100644 (file)
@@ -73,6 +73,7 @@ let run_template ~verbose filename subcmd args =
 
 type template_info = {
   base_image : string;
+  guest_arch : string option;
   minimum_memory : int64 option;
   recommended_memory : int64 option;
   minimum_size : int64 option;
@@ -80,6 +81,7 @@ type template_info = {
   network_model : string option;
   has_xml_target : bool;
   needs_external_kernel : bool;
+  cmdline : string option;
 }
 
 let probe ?(verbose = false) filename =
@@ -98,6 +100,10 @@ let probe ?(verbose = false) filename =
     | _ ->
       eprintf "mclu: cannot parse '%s base-image'\n" filename;
       exit 1 in
+  let guest_arch =
+    match run_template ~verbose filename "guest-arch" [] with
+    | Some [arch] -> Some arch
+    | _ -> None in
   let minimum_memory =
     match run_template ~verbose filename "minimum-memory" [] with
     | Some [memory] ->
@@ -145,11 +151,23 @@ let probe ?(verbose = false) filename =
     | Some ["1"|"yes"] -> true
     | Some _ -> false in
 
+  let cmdline =
+    match run_template ~verbose filename "cmdline" [] with
+    | Some [cmdline] -> Some cmdline
+    | _ -> None in
+
+  if not needs_external_kernel && cmdline <> None then (
+    eprintf "mclu: template cannot set 'cmdline' unless 'needs-external-kernel' is 'yes'.\n";
+    exit 1
+  );
+
   { base_image = base_image;
+    guest_arch = guest_arch;
     minimum_memory = minimum_memory;
     recommended_memory = recommended_memory;
     minimum_size = minimum_size;
     disk_bus = disk_bus;
     network_model = network_model;
     has_xml_target = has_xml_target;
-    needs_external_kernel = needs_external_kernel; }
+    needs_external_kernel = needs_external_kernel;
+    cmdline = cmdline }