Skip to content

Commit efefca0

Browse files
committed
Merge pull request #111 from jonludlam/hooks
Add some info about xenopsd hooks
2 parents b670610 + 7b17222 commit efefca0

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

_data/navbar.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
- xenopsd/futures/roadmap.md
4444
- xenopsd/design/Events.md
4545
- xenopsd/design/Tasks.md
46+
- xenopsd/design/hooks.md
4647
- xenopsd/design/suspend-image-considerations.md
4748
- xenopsd/design/suspend-image-framing-format.md
4849
- xenopsd/walkthroughs/VM.start.md

xenopsd/design/hooks.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
title: Hooks
3+
layout: default
4+
---
5+
6+
There are a number of hook points at which xenopsd may execute certain scripts. These scripts are found in hook-specific directories of the form `/etc/xapi.d/<hookname>/`. All executable scripts in these directories are run with the following arguments:
7+
8+
<script.sh> -reason <reason> -vmuuid <uuid of VM>
9+
10+
The scripts are executed in filename-order. By convention, the filenames are usually of the form `10resetvdis`.
11+
12+
The hook points are:
13+
14+
vm-pre-shutdown
15+
vm-pre-migrate
16+
vm-post-migrate (Dundee only)
17+
vm-pre-start
18+
vm-pre-reboot
19+
vm-pre-resume
20+
vm-post-resume (Dundee only)
21+
vm-post-destroy
22+
23+
and the reason codes are:
24+
25+
clean-shutdown
26+
hard-shutdown
27+
clean-reboot
28+
hard-reboot
29+
suspend
30+
source -- passed to pre-migrate hook on source host
31+
destination -- passed to post-migrate hook on destination (Dundee only)
32+
none
33+
34+
For example, in order to execute a script on VM shutdown, it would be sufficient to create the script in the post-destroy hook point:
35+
36+
/etc/xapi.d/vm-post-destroy/01myscript.sh
37+
38+
containing
39+
40+
#!/bin/bash
41+
echo I was passed $@ > /tmp/output
42+
43+
And when, for example, VM e30d0050-8f15-e10d-7613-cb2d045c8505 is shut-down, the script is executed:
44+
45+
[vagrant@localhost ~]$ sudo xe vm-shutdown --force uuid=e30d0050-8f15-e10d-7613-cb2d045c8505
46+
[vagrant@localhost ~]$ cat /tmp/output
47+
I was passed -vmuuid e30d0050-8f15-e10d-7613-cb2d045c8505 -reason hard-shutdown
48+
49+

0 commit comments

Comments
 (0)