[Ovirt-devel] [PATCH] Add support for vendor hooks during ovirt-early start()

Ryan Harper ryanh at us.ibm.com
Mon Nov 16 21:17:06 UTC 2009


* Darryl L. Pierce <dpierce at redhat.com> [2009-11-16 14:51]:
> On Mon, Nov 16, 2009 at 01:21:45PM -0600, Ryan Harper wrote:
> > 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 <ryanh at us.ibm.com>
> > ---
> >  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"
> > +            }
> 
> If there would only be one such vendor script, then perhaps a different
> way to go would be to use a well-known script name and, if such exists,
> source and execute that, rather than specifying it in the kernel 
> commandline? Then an optional kernel argument, "novendor", could be used
> to ignore that script if it exists. That way the default behavior would
> be to execute the script if it's found.

By leaving it up to the kernel parameter to specify the vendor script,
then one can embed multiple vendor scripts into a common image and then
select which one to use at boot time.

> 
> >          esac
> >      done
> >  
> > +    if [ -n "${vendor_script}" ]; then
> > +        . ${vendor_script}
> > +        vendor_pre_hook
> > +    fi
> 
> Here, and also in the call to vendor_post_hook, the script should
> probably check that the function being called exist.
> 
> +    if [ -n "${vendor_script}" ]; then
> +        . ${vendor_script}
> +        if type vendor_pre_hook > /dev/null 2>&1; then
> +            vendor_pre_hook
> +        fi
> +    fi

Yep; That'll protect against vendor scripts that aren't implemented
correctly.

> 
> > +
> >      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
> 
> Same here with the method call, checking if it exists first:
> 
> +    if [ -n "${vendor_script}" ]; then
> +        if type vendor_post_host > /dev/null 2>&1; then
> +            vendor_post_hook
> +        fi
> +    fi

OK.

-- 
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
ryanh at us.ibm.com




More information about the ovirt-devel mailing list