From 837399023dce58f8fdd9a3c6c5e39af087bacceb Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sun, 28 Feb 2016 20:36:14 +0000 Subject: [PATCH] Add 'cmdline' template option. --- mclu.pod | 5 +++++ mclu_boot.ml | 5 +++++ template.ml | 14 +++++++++++++- template.mli | 1 + 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/mclu.pod b/mclu.pod index 63b9b20..fe4710f 100644 --- a/mclu.pod +++ b/mclu.pod @@ -299,6 +299,11 @@ template can choose a default size. =back +=item cmdline + +The template MAY print a kernel command line. This is used to boot +the guest, but only when C is set (see below). + =item disk-bus The template MAY print the disk type supported by this guest. Possible diff --git a/mclu_boot.ml b/mclu_boot.ml index c1054e5..625aea2 100644 --- a/mclu_boot.ml +++ b/mclu_boot.ml @@ -243,6 +243,11 @@ Try: `mclu on %s'\n" hostname hostname; " remote_external_kernel remote_external_initrd else "" in + let xml = xml ^ + match template_info.Template.cmdline with + | Some cmdline -> sprintf " %s\n" cmdline + | None -> "" in + let xml = xml ^ "\ diff --git a/template.ml b/template.ml index 20a5cc7..404ec6b 100644 --- a/template.ml +++ b/template.ml @@ -81,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 = @@ -150,6 +151,16 @@ 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; @@ -158,4 +169,5 @@ let probe ?(verbose = false) filename = 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 } diff --git a/template.mli b/template.mli index 2cec7b7..3e3c2b0 100644 --- a/template.mli +++ b/template.mli @@ -34,6 +34,7 @@ type template_info = { network_model : string option; has_xml_target : bool; needs_external_kernel : bool; + cmdline : string option; } val probe : ?verbose:bool -> string -> template_info -- 1.8.3.1