[pve-devel] [PATCH v2] implement hookscripts for guests

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Jan 29 10:45:14 CET 2019


On 1/24/19 12:30 PM, Dominik Csapak wrote:
> this series implements a first version of hookscripts for guests
> 
> for this we do the following:
> 
> * add a new content type for storages (scripts) to have a place
>   for the scripts we can reference
> * add it do directory storages
> * execute hook scripts on
>   - pre start (cancel start if hookscript does not exit cleanly)
>   - post start
>   - pre stop (may not be called if vm gets stopped from within)
>   - post stop
> 
>   with parameters 'id' and 'phase'
> * show the content type on the gui
> * show the hookscript (if set) on the gui
> 
> for now only root can set those scripts (via api or qm/pct), but
> putting them into a storage leaves us open the possibility for
> a privilege that the user can have
> 
> i am not really sure about the 'scripts' name for the content
> type, as we may want to use it also for e.g. custom cloud-init
> configs or something similar, does anyone have a better idea?

I'd call it "snippet" or "snippets", fits both script and config stuff.

Further it could be worth a thought to pull out the:
>	    my ($path, undef, $type) = PVE::Storage::path($storecfg, $param->{$opt});
>
>	    raise_param_exc({ $opt => "is not in the scripts directory" })
>		if $type ne 'scripts';
>
>	    raise_param_exc({ $opt => "script '$param->{$opt}' does not exist" })
>		if ! -f $path;

parts you have duplicated in both CT and VM to a guest-common method with
a signature like get_hookscript_path($volid, $noerr) (as idea).

besides that it looks OK, if nobody else has any objections I'd you ask
you to consider the naming and get_hookscript... proposals and resent the
series with that. Thanks!




More information about the pve-devel mailing list