Debian Codegraph @

docs/misc/stubdom.txt

raw
1 IOEMU stubdom
2 =============
3
4 This boosts HVM performance by putting ioemu in its own lightweight domain.
5
6 General Configuration
7 =====================
8
9 Due to a race between the creation of the IOEMU stubdomain itself and allocation
10 of video memory for the HVM domain, you need to avoid the need for ballooning,
11 by using the hypervisor dom0_mem= option for instance.
12
13 Using with XL
14 -------------
15
16 The enable IOEMU stub domains set the following in your domain
17 config:
18
19 device_model_stubdomain_override = 1
20
21 See xl.cfg(5) for more details of the xl domain configuration syntax
22 and https://wiki.xen.org/wiki/Device_Model_Stub_Domains for more
23 information on device model stub domains
24
25
26 Toolstack to MiniOS ioemu stubdomain protocol
27 ---------------------------------------------
28
29 This section describe communication protocol between toolstack and
30 qemu-traditional running in MiniOS stubdomain. The protocol include
31 expectations of both qemu and stubdomain itself.
32
33 Setup (done by toolstack, expected by stubdomain):
34 - Block devices for target domain are connected as PV disks to stubdomain,
35 according to configuration order, starting with xvda
36 - Network devices for target domain are connected as PV nics to stubdomain,
37 according to configuration order, starting with 0
38 - if graphics output is expected, VFB and VKB devices are set for stubdomain
39 (its backend is responsible for exposing them using appropriate protocol
40 like VNC or Spice)
41 - other target domain's devices are not connected at this point to stubdomain
42 (may be hot-plugged later)
43 - QEMU command line (space separated arguments) is stored in
44 /vm/<target-uuid>/image/dmargs xenstore path
45 - target domain id is stored in /local/domain/<stubdom-id>/target xenstore path
46 ?? - bios type is stored in /local/domain/<target-id>/hvmloader/bios
47 - stubdomain's console 0 is connected to qemu log file
48 - stubdomain's console 1 is connected to qemu save file (for saving state)
49 - stubdomain's console 2 is connected to qemu save file (for restoring state)
50 - next consoles are connected according to target guest's serial console configuration
51
52 Startup:
53 1. PV stubdomain is started with ioemu-stubdom.gz kernel and no initrd
54 2. stubdomain initialize relevant devices
55 3. stubdomain signal readiness by writing "running" to /local/domain/<stubdom-id>/device-model/<target-id>/state xenstore path
56 4. now stubdomain is considered running
57
58 Runtime control (hotplug etc):
59 Toolstack can issue command through xenstore. The sequence is (from toolstack POV):
60 1. Write parameter to /local/domain/<stubdom-id>/device-model/<target-id>/parameter.
61 2. Write command to /local/domain/<stubdom-id>/device-model/<target-id>/command.
62 3. Wait for command result in /local/domain/<stubdom-id>/device-model/<target-id>/state (command specific value).
63 4. Write "running" back to /local/domain/<stubdom-id>/device-model/<target-id>/state.
64
65 Defined commands:
66 - "pci-ins" - PCI hot plug, results:
67 - "pci-inserted" - success
68 - "pci-insert-failed" - failure
69 - "pci-rem" - PCI hot remove, results:
70 - "pci-removed" - success
71 - ??
72 - "save" - save domain state to console 1, results:
73 - "paused" - success
74 - "continue" - resume domain execution, after loading state from console 2 (require -loadvm command argument), results:
75 - "running" - success
76
77
78 Toolstack to Linux ioemu stubdomain protocol
79 --------------------------------------------
80
81 This section describe communication protocol between toolstack and
82 qemu-upstream running in Linux stubdomain. The protocol include
83 expectations of both stubdomain, and qemu.
84
85 Setup (done by toolstack, expected by stubdomain):
86 - Block devices for target domain are connected as PV disks to stubdomain,
87 according to configuration order, starting with xvda
88 - Network devices for target domain are connected as PV nics to stubdomain,
89 according to configuration order, starting with 0
90 - [not implemented] if graphics output is expected, VFB and VKB devices are set for stubdomain
91 (its backend is responsible for exposing them using appropriate protocol
92 like VNC or Spice)
93 - other target domain's devices are not connected at this point to stubdomain
94 (may be hot-plugged later)
95 - QEMU command line is stored in
96 /vm/<target-uuid>/image/dm-argv xenstore dir, each argument as separate key
97 in form /vm/<target-uuid>/image/dm-argv/NNN, where NNN is 0-padded argument
98 number
99 - target domain id is stored in /local/domain/<stubdom-id>/target xenstore path
100 ?? - bios type is stored in /local/domain/<target-id>/hvmloader/bios
101 - stubdomain's console 0 is connected to qemu log file
102 - stubdomain's console 1 is connected to qemu save file (for saving state)
103 - stubdomain's console 2 is connected to qemu save file (for restoring state)
104 - next consoles are connected according to target guest's serial console configuration
105
106 Environment exposed by stubdomain to qemu (needed to construct appropriate qemu command line and later interact with qmp):
107 - target domain's disks are available as /dev/xvd[a-z]
108 - console 2 (incoming domain state) must be connected to an FD and the command
109 line argument $STUBDOM_RESTORE_INCOMING_ARG must be replaced with fd:$FD to
110 form "-incoming fd:$FD"
111 - console 1 (saving domain state) is added over QMP to qemu as "fdset-id 1" (done by stubdomain, toolstack doesn't need to care about it)
112 - nics are connected to relevant stubdomain PV vifs when available (qemu -netdev should specify ifname= explicitly)
113
114 Startup:
115 1. toolstack starts PV stubdomain with stubdom-linux-kernel kernel and stubdom-linux-initrd initrd
116 2. stubdomain initialize relevant devices
117 3. stubdomain starts qemu with requested command line, plus few stubdomain specific ones - including local qmp access options
118 4. stubdomain starts vchan server on /local/domain/<stubdom-id>/device-model/<target-id>/qmp-vchan, exposing qmp socket to the toolstack
119 5. qemu signal readiness by writing "running" to /local/domain/<stubdom-id>/device-model/<target-id>/state xenstore path
120 6. now device model is considered running
121
122 QEMU can be controlled using QMP over vchan at /local/domain/<stubdom-id>/device-model/<target-id>/qmp-vchan. Only one simultaneous connection is supported and toolstack needs to ensure that.
123
124 Limitations:
125 - PCI passthrough require permissive mode
126 - only one nic is supported
127 - at most 26 emulated disks are supported (more are still available as PV disks)
128 - graphics output (VNC/SDL/Spice) not supported
129
130 CD-ROM changing:
131
132 To change the CD-ROM medium, libxl will:
133 - QMP eject the medium from QEMU
134 - block-detach the old PV disk
135 - block-attach the new PV disk
136 - QMP change the medium to the new PV disk by fdset-id
137
138 The stubdom must internally add /dev/xvdc to an fdset in QEMU with opaque set
139 to "stub-devid:$devid". libxl will lookup the fdset with that string.
140
141 PV-GRUB
142 =======
143
144 This replaces pygrub to boot domU images safely: it runs the regular grub
145 inside the created domain itself and uses regular domU facilities to read the
146 disk / fetch files from network etc. ; it eventually loads the PV kernel and
147 chain-boots it.
148
149 Configuration
150 =============
151
152 In your PV config,
153
154 - use pv-grub.gz as kernel:
155
156 kernel = "pv-grub.gz"
157
158 - set the path to menu.lst, as seen from the domU, in extra:
159
160 extra = "(hd0,0)/boot/grub/menu.lst"
161
162 or you can provide the content of a menu.lst stored in dom0 by passing it as a
163 ramdisk:
164
165 ramdisk = "/boot/domU-1-menu.lst"
166
167 or you can also use a tftp path (dhcp will be automatically performed):
168
169 extra = "(nd)/somepath/menu.lst"
170
171 or you can set it in option 150 of your dhcp server and leave extra and ramdisk
172 empty (dhcp will be automatically performed)
173
174 Limitations
175 ===========
176
177 - You can not boot a 64bit kernel with a 32bit-compiled PV-GRUB and vice-versa.
178 To cross-compile a 32bit PV-GRUB,
179
180 export XEN_TARGET_ARCH=x86_32
181
182 - bootsplash is supported, but the ioemu backend does not yet support restart
183 for use by the booted kernel.
184
185 - PV-GRUB doesn't support virtualized partitions. For instance:
186
187 disk = [ 'phy:hda7,hda7,w' ]
188
189 will be seen by PV-GRUB as (hd0), not (hd0,6), since GRUB will not see any
190 partition table.
191
192
193 Your own stubdom
194 ================
195
196 By running
197
198 cd stubdom/
199 make c-stubdom
200
201 or
202
203 cd stubdom/
204 make caml-stubdom
205
206 you can compile examples of C or caml stub domain kernels. You can use these
207 and the relevant Makefile rules as basis to build your own stub domain kernel.
208 Available libraries are libc, libxc, libxs, zlib and libpci.