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

Dominik Csapak d.csapak at proxmox.com
Mon Jan 21 09:44:30 CET 2019


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?

dependcy wise it is relatively straight forward:

manager depends on
qemu-server/container/storage

qemu-server/container depends on
guest-common/storage

after (a version of) this series gets applied, i will write
some documentation about it (with an example script) and mark
it 'experimental' and note that the calling convention and
the exact phases/points in time are not fixed yet and subject to change,
since we may want to change it in the future until we know
exactly what our users need

pve-storage:

Dominik Csapak (3):
  add new content type 'scripts'
  enable scripts content type for all directory based storages
  allow scripts by default for new dir storages

 PVE/API2/Disks/Directory.pm |  2 +-
 PVE/Storage.pm              | 60 +++++++++++++++++++++++++++++++++++++++++++--
 PVE/Storage/CIFSPlugin.pm   |  2 +-
 PVE/Storage/CephFSPlugin.pm |  2 +-
 PVE/Storage/DirPlugin.pm    |  2 +-
 PVE/Storage/NFSPlugin.pm    |  2 +-
 PVE/Storage/Plugin.pm       |  5 +++-
 7 files changed, 67 insertions(+), 8 deletions(-)

pve-guest-common:

Dominik Csapak (1):
  add exec_hookscript to GuestHelpers

 PVE/GuestHelpers.pm | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

qemu-server:

Dominik Csapak (1):
  add hookscripts to vms

 PVE/API2/Qemu.pm  |  8 ++++++++
 PVE/CLI/qm.pm     |  2 ++
 PVE/QemuServer.pm | 12 ++++++++++++
 3 files changed, 22 insertions(+)

pve-container:

Dominik Csapak (1):
  add hookscript to containers

 src/PVE/LXC.pm            |  6 ++++++
 src/PVE/LXC/Config.pm     | 18 +++++++++++++++++-
 src/lxc-pve-poststop-hook |  3 +++
 3 files changed, 26 insertions(+), 1 deletion(-)

pve-manager:

Dominik Csapak (3):
  refactor format_content_types
  add scripts content type to the gui
  show hookscript in gui

 www/manager6/Utils.js                    | 33 +++++++++++---------------------
 www/manager6/form/ContentTypeSelector.js |  2 +-
 www/manager6/lxc/Options.js              |  3 +++
 www/manager6/qemu/Options.js             |  3 +++
 www/manager6/storage/CephFSEdit.js       |  2 +-
 www/manager6/storage/GlusterFsEdit.js    |  2 +-
 6 files changed, 20 insertions(+), 25 deletions(-)

-- 
2.11.0





More information about the pve-devel mailing list