Add a kernel parameter, vendor= which takes a path to a script embedded in the image. If this script is executable, we will then source it during ovirt-early start() after command line processing and before mounting of /config. We also call a post hook at the end of ovirt-early start().
Also include a sample vendor script. Signed-off-by: Ryan Harper <[email protected]> --- scripts/ovirt-early | 25 ++++++++++++++++++++++++- scripts/ovirt-vendor.sample | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletions(-) create mode 100644 scripts/ovirt-vendor.sample diff --git a/scripts/ovirt-early b/scripts/ovirt-early index cdd4afd..7683948 100755 --- a/scripts/ovirt-early +++ b/scripts/ovirt-early @@ -369,9 +369,27 @@ start() { console=*) bootparams="$bootparams $i" ;; + vendor=*) + i=${i#vendor=} + # path to vendor script: + # has 2 stages: + # vendor_pre_hook() + # vendor_post_host() + # pre_hook runs after cmdline processing but before the rest of ovirt-early + # post_hook runs at the end of ovirt-early start() + [ -x "${i}" ] && { + vendor_script="$i" + log "Found vendor script: ${vendor_script}"; + bootparams="$bootparams $i" + } esac done + if [ -n "${vendor_script}" ]; then + . ${vendor_script} + vendor_pre_hook + fi + if [ -z "$ip_netmask" ]; then ip_netmask=$netmask fi @@ -379,7 +397,8 @@ start() { ip_gateway=$gateway fi # save boot parameters as defaults for ovirt-config-* - params="bootif init vol_boot_size vol_swap_size vol_root_size vol_config_size vol_logging_size vol_data_size local_boot standalone overcommit ip_address ip_netmask ip_gateway ipv6 dns ntp vlan ssh_pwauth syslog_server syslog_port collectd_server collectd_port bootparams hostname firstboot" + # and allow vendor prehook set params to be saved + params="${params} bootif init vol_boot_size vol_swap_size vol_root_size vol_config_size vol_logging_size vol_data_size local_boot standalone overcommit ip_address ip_netmask ip_gateway ipv6 dns ntp vlan ssh_pwauth syslog_server syslog_port collectd_server collectd_port bootparams hostname firstboot" # mount /config unless firstboot is forced if [ "$firstboot" != "1" ]; then mount_config @@ -434,6 +453,10 @@ start() { fi fi + if [ -n "${vendor_script}" ]; then + vendor_post_hook + fi + return 0 } diff --git a/scripts/ovirt-vendor.sample b/scripts/ovirt-vendor.sample new file mode 100644 index 0000000..7a57ddd --- /dev/null +++ b/scripts/ovirt-vendor.sample @@ -0,0 +1,35 @@ +#!/bin/bash + +# This is a sample vendor script +# +# We need to provide two hook functions: +# - vendor_pre_hook() +# - vendor_post_hook() +# +# pre_hook is called after command line processing in ovirt-early, before +# /config is mounted +# +# post_hook is called at the very end of ovirt-early start() +# + +# as an example, lets look for a new kernel parameter and save it +function vendor_pre_hook() +{ + log "Entering vendor pre hook"; + for i in $(cat /proc/cmdline); do + case $i in + vendor=*) + bootparams="$bootparams $i" + ;; + esac + done + params="${params} vendor"; + log "Exiting vendor pre hook"; +} + +function vendor_post_hook() +{ + log "Entering vendor post hook"; + + log "Exiting vendor post hook"; +} -- 1.6.2.5 -- Ryan Harper Software Engineer; Linux Technology Center IBM Corp., Austin, Tx [email protected] _______________________________________________ Ovirt-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/ovirt-devel
