[Devel] vzctl PRE_CREATE hook

Kir Kolyshkin kir at openvz.org
Mon Jun 1 09:48:08 PDT 2015


Thank you, this approach looks way better and in-line with current vzctl
ideas!

Can you please:

1. Use git format-patch

2. Provide some description (in the patch commit message) about why you 
need it etc.
An example of such is 
https://src.openvz.org/projects/OVZL/repos/vzctl/commits/4772f7e

3. Document it in man page (can come as a separate patch or together).
I just noticed that vps.create is not documented either, so that one
is welcome, too (probably as a separate patch). For example, see
https://src.openvz.org/projects/OVZL/repos/vzctl/commits/92f8c756df

Regards,
   Kir

On 05/31/2015 11:51 PM, Nikolay Tenev wrote:
> Hello,
>
> The following patch implements vps.precreate 
> (/etc/sysconfig/vz-scripts/vps.precreate) action script.
>
> diff --git a/include/types.h b/include/types.h
> index b295dc6..a04dfbc 100644
> --- a/include/types.h
> +++ b/include/types.h
> @@ -35,6 +35,7 @@
>  #define VPS_PRESTART           SCRIPTDIR "/vps-prestart"
>  /* User-defined scripts are in VPSCONFDIR */
> +#define USER_PRECREATE_SCRIPT  VPSCONFDIR "/vps.precreate"
>  #define USER_CREATE_SCRIPT     VPSCONFDIR "/vps.create"
>  #ifndef __ENVID_T_DEFINED__
> diff --git a/src/lib/create.c b/src/lib/create.c
> index effcd08..6c16436 100644
> --- a/src/lib/create.c
> +++ b/src/lib/create.c
> @@ -465,6 +465,12 @@ int vps_create(vps_handler *h, envid_t veid, 
> vps_param *vps_p, vps_param *cmd_p,
>                         goto err_cfg;
>         }
> +       if ((ret = run_pre_script(veid, USER_PRECREATE_SCRIPT))) {
> +               logger(0, 0, "User pre-create script " 
> USER_PRECREATE_SCRIPT
> +                       " exited with error");
> +               goto err_cfg;
> +        }
> +
>         if (action != NULL && action->mod_count) {
>                 if ((ret = mod_setup(h, veid, 0, 0, action, vps_p)))
>                         goto err_cfg;
>
>
> On 19 May 2015 at 07:37, Kir Kolyshkin <kir at openvz.org 
> <mailto:kir at openvz.org>> wrote:
>
>     (I previously replied to Nikolay only -- re-sending with devel@
>     included)
>
>     On 05/12/2015 02:36 AM, Nikolay Tenev wrote:
>>     Hello devs,
>>
>>     In my project I wanted to make every OpenVZ container to use for
>>     a private directory (VE_PRIVATE) separated block device (HDD
>>     partition, lvm volume, NFS share, etc.). To use wrapper script
>>     over vzctl was one option, but PRE_CREATE hook, in which to
>>     create, mkfs and mount LVM volume would be even better.
>>
>>     So, I'm not a developer, but using code from POST_CREATE hook I
>>     was able to create the PRE_CREATE one, which can be used as the
>>     other hooks e.g.
>>
>>     add in /etc/vz/dists/ default
>>     PRE_CREATE = precreate.sh
>>
>>     and during
>>     vzctl --create ...
>>
>>     it will call /etc/vz/dists/scripts/precreate.sh with VEID as argument
>
>     Nope. These scripts are per-distribution scripts, i.e. they are
>     targeted for
>     various distro-specific things, such as setting IP addresses etc.
>
>     What you need is a global script, not dependent on CT distro. I
>     suggest
>     a precreate.sh script similar to prestart.sh one (for details, see
>     commit
>     https://github.com/kolyshkin/vzctl/commit/0807ef4)
>
>>
>>     Currently I have a patch to vzctl master branch which implements
>>     this PRE_CREATE hook and I'm ready to share it.
>>
>>     So my questions are:
>>     - Do you find this for interesting and/or useful?
>>     - If 'yes', what is the right way to send this patch: here, by
>>     email; or to create pull request in git repo?
>
>     The best way would be to redo as advised above and send a patch to
>     devel@ list.
>
>     Thanks,
>       Kir.
>
>>
>>     Best regards!
>>
>>     Nikolay Tenev
>>
>>
>>
>>     _______________________________________________
>>     Devel mailing list
>>     Devel at openvz.org  <mailto:Devel at openvz.org>
>>     https://lists.openvz.org/mailman/listinfo/devel
>
>
>
>
> _______________________________________________
> Devel mailing list
> Devel at openvz.org
> https://lists.openvz.org/mailman/listinfo/devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvz.org/pipermail/devel/attachments/20150601/954e195c/attachment-0001.html>


More information about the Devel mailing list