Skip to content

Commit 2b77e07

Browse files
committed
Merge pull request #159 from thomassa/xenprep
New doc for xenprep design
2 parents ff71c62 + 3965709 commit 2b77e07

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

xapi/futures/xenprep.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
title: XenPrep
3+
layout: default
4+
design_doc: true
5+
revision: 1
6+
status: proposed
7+
---
8+
9+
### Background
10+
Windows guests should have XenServer-specific drivers installed. As of mid-2015 these have been always been installed and upgraded by an essentially manual process involving an ISO carrying the drivers. We have a plan to enable automation through the standard Windows Update mechanism. This will involve a new additional virtual PCI device being provided to the VM, to trigger Windows Update to fetch drivers for the device.
11+
12+
There are many existing Windows guests that have drivers installed already. These drivers must be uninstalled before the new drivers are installed (and ideally before the new PCI device is added). To make this easier, we are planning a XenAPI call that will cause the removal of the old drivers and the addition of the new PCI device.
13+
14+
Since this is only to help with updating old guests, the call may well be removed at some point in the future.
15+
16+
### Brief high-level design
17+
The XenAPI call will be called `VM.xenprep_start`. It will update the VM record to note that the process has started, and will insert a special ISO into the VM's virtual CD drive.
18+
19+
That ISO will contain a tool which will be set up to auto-run (if auto-run is enabled in the guest). The tool will:
20+
21+
1. Lock the CD drive so other Windows programs cannot eject the disc.
22+
2. Uninstall the old drivers.
23+
3. Eject the CD to signal success.
24+
4. Shut down the VM.
25+
26+
XenServer will interpret the ejection of the CD as a success signal, and when the VM shuts down without the special ISO in the drive, XenServer will:
27+
28+
1. Update the VM record:
29+
* Remove the mark that shows that the xenprep process is in progress
30+
* Give it the new PCI device: set `VM.auto_update_drivers` to `true`.
31+
* If `VM.virtual_hardware_platform_version` is less than 2, then set it to 2.
32+
2. Start the VM.
33+
34+
### More details of the xapi-project parts
35+
(The tool that runs in the guest is out of scope for this document.)
36+
37+
#### Start
38+
The XenAPI call `VM.xenprep_start` will throw a power-state error if the VM is not running.
39+
For RBAC roles, it will be available to "VM Operator" and above.
40+
41+
It will:
42+
43+
1. Insert the xenprep ISO into the VM's virtual CD drive.
44+
2. Write `VM.other_config` key `xenprep_progress=ISO_inserted` to record the fact that the xenprep process has been initiated.
45+
46+
If `xenprep_start` is called on a VM already undergoing xenprep, the call will return successfully but will not do anything.
47+
48+
If the VM does not have an empty virtual CD drive, the call will fail with a suitable error.
49+
50+
#### Cancellation
51+
While xenprep is in progress, any request to eject the xenprep ISO (except from inside the guest) will be rejected with a new error "XENPREP_IN_PROGRESS".
52+
53+
There will be a new XenAPI call `VM.xenprep_abort` which will:
54+
55+
1. Remove the `xenprep_progress` entry from `VM.other_config`.
56+
2. Make a best-effort attempt to eject the CD. (The guest might prevent ejection.)
57+
58+
This is not intended for cancellation while the xenprep tool is running, but rather for use before it starts, for example if auto-run is disabled or if the VM has a non-Windows OS.
59+
60+
#### Completion
61+
62+
Aim: when the guest shuts down after ejecting the CD, XenServer will start the guest again with the new PCI device.
63+
64+
Xapi works through the queue of events it receives from xenopsd. It is possible that by the time xapi processes the cd-eject event, the guest might have shut down already.
65+
66+
When the shutdown (not reboot) event is handled, we shall check whether we need to do anything xenprep-related. If
67+
* The VM `other_config` map has `xenprep_progress` as either of `ISO_inserted` or `shutdown`, and
68+
* The xenprep ISO is no longer in the drive
69+
70+
then we must (in the specified order)
71+
72+
1. Update the VM record:
73+
1. In `VM.other_config` set `xenprep_progress=shutdown`
74+
2. If `VM.virtual_hardware_platform_version` is less than 2, then set it to 2.
75+
3. Give it the new PCI device: set `VM.auto_update_drivers` to `true`.
76+
2. Initiate VM start.
77+
3. Remove `xenprep_progress` from `VM.other_config`
78+
79+
The most relevant code is probably the `update_vm` function in `ocaml/xapi/xapi_xenops.ml` in the `xen-api` repo (or in some function called from there).

0 commit comments

Comments
 (0)