debuggers.hg

view tools/libxl/libxl.idl @ 22855:1d1eec7e1fb4

xl: Perform minimal validation of virtual disk file while parsing config file

This patch performs some very basic validation on the virtual disk
file passed through the config file. This validation ensures that we
don't go too far with the initialization like spawn qemu and more
while there could be some potentially fundamental issues.

[ Patch fixed up to work with PHYSTYPE_EMPTY 22808:6ec61438713a -iwj ]

Signed-off-by: Kamala Narasimhan <kamala.narasimhan@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Kamala Narasimhan <kamala.narasimhan@gmail.com>
date Tue Jan 25 18:09:49 2011 +0000 (2011-01-25)
parents 47be85d61f11
children
line source
1 # -*- python -*-
2 #
3 # Builtin libxl types
4 #
6 libxl_ctx = Builtin("ctx")
7 libxl_uuid = Builtin("uuid")
8 libxl_mac = Builtin("mac")
9 libxl_cpumap = Builtin("cpumap", destructor_fn="libxl_cpumap_destroy", passby=PASS_BY_REFERENCE)
10 libxl_cpuarray = Builtin("cpuarray", destructor_fn="libxl_cpuarray_destroy", passby=PASS_BY_REFERENCE)
11 libxl_qemu_machine_type = Number("qemu_machine_type", namespace="libxl_")
12 libxl_console_consback = Number("console_consback", namespace="libxl_")
13 libxl_console_constype = Number("console_constype", namespace="libxl_")
14 libxl_disk_phystype = Number("disk_phystype", namespace="libxl_")
15 libxl_nic_type = Number("nic_type", namespace="libxl_")
16 libxl_cpuid_policy_list = Builtin("cpuid_policy_list", destructor_fn="libxl_cpuid_destroy", passby=PASS_BY_REFERENCE)
18 libxl_string_list = Builtin("string_list", destructor_fn="libxl_string_list_destroy", passby=PASS_BY_REFERENCE)
19 libxl_key_value_list = Builtin("key_value_list", destructor_fn="libxl_key_value_list_destroy", passby=PASS_BY_REFERENCE)
20 libxl_file_reference = Builtin("file_reference", destructor_fn="libxl_file_reference_destroy", passby=PASS_BY_REFERENCE)
22 libxl_hwcap = Builtin("hwcap")
24 #
25 # Complex libxl types
26 #
27 libxl_dominfo = Struct("dominfo",[
28 ("uuid", libxl_uuid),
29 ("domid", domid),
30 ("running", BitField(uint8, 1)),
31 ("blocked", BitField(uint8, 1)),
32 ("paused", BitField(uint8, 1)),
33 ("shutdown", BitField(uint8, 1)),
34 ("dying", BitField(uint8, 1)),
36 ("shutdown_reason", unsigned, False,
37 """Valid SHUTDOWN_* value from xen/sched.h iff (shutdown||dying).
39 Otherwise set to a value guaranteed not to clash with any valid
40 SHUTDOWN_* constant."""),
41 ("current_memkb", uint64),
42 ("max_memkb", uint64),
43 ("cpu_time", uint64),
44 ("vcpu_max_id", uint32),
45 ("vcpu_online", uint32),
46 ], destructor_fn=None)
48 libxl_cpupoolinfo = Struct("cpupoolinfo", [
49 ("poolid", uint32),
50 ("sched_id", uint32),
51 ("n_dom", uint32),
52 ("cpumap", libxl_cpumap)
53 ])
55 libxl_vminfo = Struct("vminfo", [
56 ("uuid", libxl_uuid),
57 ("domid", domid),
58 ], destructor_fn=None)
60 libxl_version_info = Struct("version_info", [
61 ("xen_version_major", integer),
62 ("xen_version_minor", integer),
63 ("xen_version_extra", string),
64 ("compiler", string),
65 ("compile_by", string),
66 ("compile_domain", string),
67 ("compile_date", string),
68 ("capabilities", string),
69 ("changeset", string),
70 ("virt_start", unsigned_long),
71 ("pagesize", unsigned_long),
72 ("commandline", string),
73 ])
75 libxl_domain_create_info = Struct("domain_create_info",[
76 ("hvm", bool),
77 ("hap", bool),
78 ("oos", bool),
79 ("ssidref", integer),
80 ("name", string),
81 ("uuid", libxl_uuid),
82 ("xsdata", libxl_key_value_list),
83 ("platformdata", libxl_key_value_list),
84 ("poolid", uint32),
85 ("poolname", string),
86 ])
88 libxl_domain_build_info = Struct("domain_build_info",[
89 ("max_vcpus", integer),
90 ("cur_vcpus", integer),
91 ("tsc_mode", integer),
92 ("max_memkb", uint32),
93 ("target_memkb", uint32),
94 ("video_memkb", uint32),
95 ("shadow_memkb", uint32),
96 ("disable_migrate", bool),
97 ("kernel", libxl_file_reference),
98 ("cpuid", libxl_cpuid_policy_list),
99 ("hvm", integer),
100 ("u", KeyedUnion(None, "hvm",
101 [("hvm", "%s", Struct(None,
102 [("pae", bool),
103 ("apic", bool),
104 ("acpi", bool),
105 ("nx", bool),
106 ("viridian", bool),
107 ("timeoffset", string),
108 ("hpet", bool),
109 ("vpt_align", bool),
110 ("timer_mode", integer),
111 ])),
112 ("pv", "!%s", Struct(None,
113 [("slack_memkb", uint32),
114 ("bootloader", string),
115 ("bootloader_args", string),
116 ("cmdline", string),
117 ("ramdisk", libxl_file_reference),
118 ("features", string, True),
119 ])),
120 ])),
121 ],
122 comment =
123 """Instances of libxl_file_reference contained in this struct which
124 have been mapped (with libxl_file_reference_map) will be unmapped
125 by libxl_domain_build/restore. If either of these are never called
126 then the user is responsible for calling
127 libxl_file_reference_unmap.""")
129 libxl_domain_build_state = Struct("domain_build_state",[
130 ("store_port", uint32),
131 ("store_mfn", unsigned_long),
132 ("console_port", uint32),
133 ("console_mfn", unsigned_long),
134 ], destructor_fn=None)
136 libxl_device_model_info = Struct("device_model_info",[
137 ("domid", integer),
138 ("uuid", libxl_uuid, False, "this is use only with stubdom, and must be different from the domain uuid"),
139 ("dom_name", string),
140 ("device_model", string),
141 ("saved_state", string),
142 ("type", libxl_qemu_machine_type),
143 ("target_ram", uint32),
144 ("videoram", integer, False, "size of the videoram in MB"),
145 ("stdvga", bool, False, "stdvga enabled or disabled"),
146 ("vnc", bool, False, "vnc enabled or disabled"),
147 ("vnclisten", string, False, "address:port that should be listened on for the VNC server if vnc is set"),
148 ("vncpasswd", string, False, "the VNC password"),
149 ("vncdisplay", integer, False, "set VNC display number"),
150 ("vncunused", bool, False, "try to find an unused port for the VNC server"),
151 ("keymap", string, False, "set keyboard layout, default is en-us keyboard"),
152 ("sdl", bool, False, "sdl enabled or disabled"),
153 ("opengl", bool, False, "opengl enabled or disabled (if enabled requires sdl enabled)"),
154 ("nographic", bool, False, "no graphics, use serial port"),
155 ("gfx_passthru", bool, False, "graphics passthrough enabled or disabled"),
156 ("serial", string, False, "serial port re-direct to pty deivce"),
157 ("boot", string, False, "boot order, for example dca"),
158 ("usb", bool, False, "usb support enabled or disabled"),
159 ("usbdevice", string, False, "enable usb mouse: tablet for absolute mouse, mouse for PS/2 protocol relative mouse"),
160 ("soundhw", string, False, "enable sound hardware"),
161 ("apic", bool, False, "apic enabled or disabled"),
162 ("vcpus", integer, False, "max number of vcpus"),
163 ("vcpu_avail", integer, False, "vcpus actually available"),
164 ("xen_platform_pci", integer, False, "enable/disable the xen platform pci device"),
165 ("extra", libxl_string_list, False, "extra parameters pass directly to qemu, NULL terminated"),
166 ],
167 comment=
168 """Device Model information.
170 Network is missing""")
172 libxl_device_vfb = Struct("device_vfb", [
173 ("backend_domid", uint32),
174 ("domid", uint32),
175 ("devid", integer),
176 ("vnc", bool, False, "vnc enabled or disabled"),
177 ("vnclisten", string, False, "address:port that should be listened on for the VNC server if vnc is set"),
178 ("vncpasswd", string, False, "the VNC password"),
179 ("vncdisplay", integer, False, "set VNC display number"),
180 ("vncunused", bool, False, "try to find an unused port for the VNC server"),
181 ("keymap", string, False, "set keyboard layout, default is en-us keyboard"),
182 ("sdl", bool, False, "sdl enabled or disabled"),
183 ("opengl", bool, False, "opengl enabled or disabled (if enabled requires sdl enabled)"),
184 ("display", string),
185 ("xauthority", string),
186 ])
188 libxl_device_vkb = Struct("device_vkb", [
189 ("backend_domid", uint32),
190 ("domid", domid),
191 ("devid", integer),
192 ])
194 libxl_device_console = Struct("device_console", [
195 ("backend_domid", uint32),
196 ("domid", domid),
197 ("devid", integer),
198 ("consback", libxl_console_consback),
199 ("build_state", Reference(libxl_domain_build_state), True),
200 ("output", string),
201 ])
203 libxl_device_disk = Struct("device_disk", [
204 ("backend_domid", uint32),
205 ("domid", domid),
206 ("physpath", string),
207 ("phystype", libxl_disk_phystype),
208 ("virtpath", string),
209 ("unpluggable", integer),
210 ("readwrite", integer),
211 ("is_cdrom", integer),
212 ])
214 libxl_device_nic = Struct("device_nic", [
215 ("backend_domid", uint32),
216 ("domid", domid),
217 ("devid", integer),
218 ("mtu", integer),
219 ("model", string),
220 ("mac", libxl_mac),
221 ("ip", inaddr_ip),
222 ("bridge", string),
223 ("ifname", string),
224 ("script", string),
225 ("nictype", libxl_nic_type),
226 ])
228 libxl_device_net2 = Struct("device_net2", [
229 ("devid", integer),
230 ("front_mac", libxl_mac),
231 ("back_mac", libxl_mac),
232 ("backend_domid", uint32),
233 ("domid", domid),
234 ("trusted", BitField(uint32, 1)),
235 ("back_trusted", BitField(uint32, 1)),
236 ("filter_mac", BitField(uint32, 1)),
237 ("front_filter_mac", BitField(uint32, 1)),
238 ("pdev", uint32),
239 ("max_bypasses", uint32),
240 ("bridge", string),
241 ])
243 libxl_device_pci = Struct("device_pci", [
244 ("reg", uint8),
245 ("func", uint8),
246 ("dev", uint8),
247 ("bus", uint8),
248 ("enable", bool),
249 ("domain", unsigned_integer),
250 ("vdevfn", unsigned_integer),
251 ("vfunc_mask", unsigned_integer),
252 ("msitranslate", bool),
253 ("power_mgmt", bool),
254 ])
256 libxl_diskinfo = Struct("diskinfo", [
257 ("backend", string),
258 ("backend_id", uint32),
259 ("frontend", string),
260 ("frontend_id", uint32),
261 ("devid", integer),
262 ("state", integer),
263 ("evtch", integer),
264 ("rref", integer),
265 ])
267 libxl_nicinfo = Struct("nicinfo", [
268 ("backend", string),
269 ("backend_id", uint32),
270 ("frontend", string),
271 ("frontend_id", uint32),
272 ("devid", integer),
273 ("state", integer),
274 ("script", string),
275 ("mac", libxl_mac),
276 ("evtch", integer),
277 ("rref_tx", integer),
278 ("rref_rx", integer),
279 ])
281 libxl_vcpuinfo = Struct("vcpuinfo", [
282 ("vcpuid", uint32, False, "vcpu's id"),
283 ("cpu", uint32, False, "current mapping"),
284 ("online", BitField(uint8, 1), False, "currently online (not hotplugged)?"),
285 ("blocked", BitField(uint8, 1), False, "blocked waiting for an event?"),
286 ("running", BitField(uint8, 1), False, "currently scheduled on its CPU?"),
287 ("vcpu_time", uint64, False, "total vcpu time ran (ns)"),
288 ("cpumap", libxl_cpumap, False, "current cpu's affinities"),
289 ])
291 libxl_physinfo = Struct("physinfo", [
292 ("threads_per_core", uint32),
293 ("cores_per_socket", uint32),
295 ("max_cpu_id", uint32),
296 ("nr_cpus", uint32),
297 ("cpu_khz", uint32),
299 ("total_pages", uint64),
300 ("free_pages", uint64),
301 ("scrub_pages", uint64),
303 ("nr_nodes", uint32),
304 ("hw_cap", libxl_hwcap),
305 ("phys_cap", uint32),
306 ], destructor_fn=None)
308 libxl_topologyinfo = Struct("topologyinfo", [
309 ("coremap", libxl_cpuarray, False, "cpu to core map"),
310 ("socketmap", libxl_cpuarray, False, "cpu to socket map"),
311 ("nodemap", libxl_cpuarray, False, "cpu to node map"),
312 ])
314 libxl_sched_credit = Struct("sched_credit", [
315 ("weight", integer),
316 ("cap", integer),
317 ], destructor_fn=None)
319 libxl_net2info = Struct("net2info", [
320 ("backend", string),
321 ("backend_id", uint32),
322 ("frontend", string),
323 ("frontend_id", uint32),
324 ("devid", integer),
325 ("state", integer),
326 ("mac", libxl_mac),
327 ("trusted", integer),
328 ("back_mac", libxl_mac),
329 ("filter_mac", integer),
330 ])