1 /*
2 * Copyright 2009-2017 Citrix Ltd and other contributors
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published
6 * by the Free Software Foundation; version 2.1 only. with the special
7 * exception on linking described in file LICENSE.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 */
14
15 /*
16 * Legacy SXP output handling
17 */
18
19 #include <stdlib.h>
20 #include <inttypes.h>
21
22 #include <libxl.h>
23 #include <libxl_utils.h>
24 #include "xl.h"
25
26 /* In general you should not add new output to this function since it
27 * is intended only for legacy use.
28 */
printf_info_sexp(int domid,libxl_domain_config * d_config,FILE * fh)29 void printf_info_sexp(int domid, libxl_domain_config *d_config, FILE *fh)
30 {
31 int i;
32 libxl_dominfo info;
33
34 libxl_domain_create_info *c_info = &d_config->c_info;
35 libxl_domain_build_info *b_info = &d_config->b_info;
36
37 fprintf(fh, "(domain\n\t(domid %d)\n", domid);
38 fprintf(fh, "\t(create_info)\n");
39 fprintf(fh, "\t(hvm %d)\n", c_info->type == LIBXL_DOMAIN_TYPE_HVM);
40 fprintf(fh, "\t(hap %s)\n", libxl_defbool_to_string(c_info->hap));
41 fprintf(fh, "\t(oos %s)\n", libxl_defbool_to_string(c_info->oos));
42 fprintf(fh, "\t(ssidref %d)\n", c_info->ssidref);
43 fprintf(fh, "\t(name %s)\n", c_info->name);
44
45 /* retrieve the UUID from dominfo, since it is probably generated
46 * during parsing and thus does not match the real one
47 */
48 if (libxl_domain_info(ctx, &info, domid) == 0) {
49 fprintf(fh, "\t(uuid " LIBXL_UUID_FMT ")\n", LIBXL_UUID_BYTES(info.uuid));
50 } else {
51 fprintf(fh, "\t(uuid <unknown>)\n");
52 }
53 if (c_info->pool_name)
54 fprintf(fh, "\t(cpupool %s)\n", c_info->pool_name);
55 if (c_info->xsdata)
56 fprintf(fh, "\t(xsdata contains data)\n");
57 else
58 fprintf(fh, "\t(xsdata (null))\n");
59 if (c_info->platformdata)
60 fprintf(fh, "\t(platformdata contains data)\n");
61 else
62 fprintf(fh, "\t(platformdata (null))\n");
63
64
65 fprintf(fh, "\t(build_info)\n");
66 fprintf(fh, "\t(max_vcpus %d)\n", b_info->max_vcpus);
67 fprintf(fh, "\t(max_grant_frames %d)\n", b_info->max_grant_frames);
68 fprintf(fh, "\t(max_maptrack_frames %d)\n", b_info->max_maptrack_frames);
69 fprintf(fh, "\t(tsc_mode %s)\n", libxl_tsc_mode_to_string(b_info->tsc_mode));
70 fprintf(fh, "\t(max_memkb %"PRId64")\n", b_info->max_memkb);
71 fprintf(fh, "\t(target_memkb %"PRId64")\n", b_info->target_memkb);
72 fprintf(fh, "\t(nomigrate %s)\n",
73 libxl_defbool_to_string(b_info->disable_migrate));
74
75 if (c_info->type == LIBXL_DOMAIN_TYPE_PV && b_info->bootloader) {
76 fprintf(fh, "\t(bootloader %s)\n", b_info->bootloader);
77 if (b_info->bootloader_args) {
78 fprintf(fh, "\t(bootloader_args");
79 for (i=0; b_info->bootloader_args[i]; i++)
80 fprintf(fh, " %s", b_info->bootloader_args[i]);
81 fprintf(fh, ")\n");
82 }
83 }
84
85 fprintf(fh, "\t(image\n");
86 switch (c_info->type) {
87 case LIBXL_DOMAIN_TYPE_HVM:
88 fprintf(fh, "\t\t(hvm\n");
89 fprintf(fh, "\t\t\t(firmware %s)\n", b_info->u.hvm.firmware);
90 fprintf(fh, "\t\t\t(video_memkb %"PRId64")\n", b_info->video_memkb);
91 fprintf(fh, "\t\t\t(shadow_memkb %"PRId64")\n", b_info->shadow_memkb);
92 fprintf(fh, "\t\t\t(pae %s)\n", libxl_defbool_to_string(b_info->u.hvm.pae));
93 fprintf(fh, "\t\t\t(apic %s)\n",
94 libxl_defbool_to_string(b_info->apic));
95 fprintf(fh, "\t\t\t(acpi %s)\n",
96 libxl_defbool_to_string(b_info->u.hvm.acpi));
97 fprintf(fh, "\t\t\t(nx %s)\n", libxl_defbool_to_string(b_info->u.hvm.nx));
98 fprintf(fh, "\t\t\t(viridian %s)\n",
99 libxl_defbool_to_string(b_info->u.hvm.viridian));
100 fprintf(fh, "\t\t\t(hpet %s)\n",
101 libxl_defbool_to_string(b_info->u.hvm.hpet));
102 fprintf(fh, "\t\t\t(vpt_align %s)\n",
103 libxl_defbool_to_string(b_info->u.hvm.vpt_align));
104 fprintf(fh, "\t\t\t(timer_mode %s)\n",
105 libxl_timer_mode_to_string(b_info->timer_mode));
106 fprintf(fh, "\t\t\t(nestedhvm %s)\n",
107 libxl_defbool_to_string(b_info->nested_hvm));
108 fprintf(fh, "\t\t\t(stdvga %s)\n", b_info->u.hvm.vga.kind ==
109 LIBXL_VGA_INTERFACE_TYPE_STD ?
110 "True" : "False");
111 fprintf(fh, "\t\t\t(vnc %s)\n",
112 libxl_defbool_to_string(b_info->u.hvm.vnc.enable));
113 fprintf(fh, "\t\t\t(vnclisten %s)\n", b_info->u.hvm.vnc.listen);
114 fprintf(fh, "\t\t\t(vncdisplay %d)\n", b_info->u.hvm.vnc.display);
115 fprintf(fh, "\t\t\t(vncunused %s)\n",
116 libxl_defbool_to_string(b_info->u.hvm.vnc.findunused));
117 fprintf(fh, "\t\t\t(keymap %s)\n", b_info->u.hvm.keymap);
118 fprintf(fh, "\t\t\t(sdl %s)\n",
119 libxl_defbool_to_string(b_info->u.hvm.sdl.enable));
120 fprintf(fh, "\t\t\t(opengl %s)\n",
121 libxl_defbool_to_string(b_info->u.hvm.sdl.opengl));
122 fprintf(fh, "\t\t\t(nographic %s)\n",
123 libxl_defbool_to_string(b_info->u.hvm.nographic));
124 fprintf(fh, "\t\t\t(spice %s)\n",
125 libxl_defbool_to_string(b_info->u.hvm.spice.enable));
126 fprintf(fh, "\t\t\t(spiceport %d)\n", b_info->u.hvm.spice.port);
127 fprintf(fh, "\t\t\t(spicetls_port %d)\n", b_info->u.hvm.spice.tls_port);
128 fprintf(fh, "\t\t\t(spicehost %s)\n", b_info->u.hvm.spice.host);
129 fprintf(fh, "\t\t\t(spicedisable_ticketing %s)\n",
130 libxl_defbool_to_string(b_info->u.hvm.spice.disable_ticketing));
131 fprintf(fh, "\t\t\t(spiceagent_mouse %s)\n",
132 libxl_defbool_to_string(b_info->u.hvm.spice.agent_mouse));
133
134 fprintf(fh, "\t\t\t(device_model %s)\n", b_info->device_model ? : "default");
135 fprintf(fh, "\t\t\t(gfx_passthru %s)\n",
136 libxl_defbool_to_string(b_info->u.hvm.gfx_passthru));
137 fprintf(fh, "\t\t\t(serial %s)\n", b_info->u.hvm.serial);
138 fprintf(fh, "\t\t\t(boot %s)\n", b_info->u.hvm.boot);
139 fprintf(fh, "\t\t\t(usb %s)\n", libxl_defbool_to_string(b_info->u.hvm.usb));
140 fprintf(fh, "\t\t\t(usbdevice %s)\n", b_info->u.hvm.usbdevice);
141 fprintf(fh, "\t\t)\n");
142 break;
143 case LIBXL_DOMAIN_TYPE_PV:
144 fprintf(fh, "\t\t(linux %d)\n", 0);
145 fprintf(fh, "\t\t\t(kernel %s)\n", b_info->kernel);
146 fprintf(fh, "\t\t\t(cmdline %s)\n", b_info->cmdline);
147 fprintf(fh, "\t\t\t(ramdisk %s)\n", b_info->ramdisk);
148 fprintf(fh, "\t\t\t(e820_host %s)\n",
149 libxl_defbool_to_string(b_info->u.pv.e820_host));
150 fprintf(fh, "\t\t)\n");
151 break;
152 default:
153 fprintf(stderr, "Unknown domain type %d\n", c_info->type);
154 exit(1);
155 }
156 fprintf(fh, "\t)\n");
157
158 for (i = 0; i < d_config->num_disks; i++) {
159 fprintf(fh, "\t(device\n");
160 fprintf(fh, "\t\t(tap\n");
161 fprintf(fh, "\t\t\t(backend_domid %d)\n", d_config->disks[i].backend_domid);
162 fprintf(fh, "\t\t\t(frontend_domid %d)\n", domid);
163 fprintf(fh, "\t\t\t(physpath %s)\n", d_config->disks[i].pdev_path);
164 fprintf(fh, "\t\t\t(phystype %d)\n", d_config->disks[i].backend);
165 fprintf(fh, "\t\t\t(virtpath %s)\n", d_config->disks[i].vdev);
166 fprintf(fh, "\t\t\t(unpluggable %d)\n", d_config->disks[i].removable);
167 fprintf(fh, "\t\t\t(readwrite %d)\n", d_config->disks[i].readwrite);
168 fprintf(fh, "\t\t\t(is_cdrom %d)\n", d_config->disks[i].is_cdrom);
169 fprintf(fh, "\t\t)\n");
170 fprintf(fh, "\t)\n");
171 }
172
173 for (i = 0; i < d_config->num_nics; i++) {
174 fprintf(fh, "\t(device\n");
175 fprintf(fh, "\t\t(vif\n");
176 if (d_config->nics[i].ifname)
177 fprintf(fh, "\t\t\t(vifname %s)\n", d_config->nics[i].ifname);
178 fprintf(fh, "\t\t\t(backend_domid %d)\n", d_config->nics[i].backend_domid);
179 fprintf(fh, "\t\t\t(frontend_domid %d)\n", domid);
180 fprintf(fh, "\t\t\t(devid %d)\n", d_config->nics[i].devid);
181 fprintf(fh, "\t\t\t(mtu %d)\n", d_config->nics[i].mtu);
182 fprintf(fh, "\t\t\t(model %s)\n", d_config->nics[i].model);
183 fprintf(fh, "\t\t\t(mac %02x%02x%02x%02x%02x%02x)\n",
184 d_config->nics[i].mac[0], d_config->nics[i].mac[1],
185 d_config->nics[i].mac[2], d_config->nics[i].mac[3],
186 d_config->nics[i].mac[4], d_config->nics[i].mac[5]);
187 fprintf(fh, "\t\t)\n");
188 fprintf(fh, "\t)\n");
189 }
190
191 for (i = 0; i < d_config->num_pcidevs; i++) {
192 fprintf(fh, "\t(device\n");
193 fprintf(fh, "\t\t(pci\n");
194 fprintf(fh, "\t\t\t(pci dev %04x:%02x:%02x.%01x@%02x)\n",
195 d_config->pcidevs[i].domain, d_config->pcidevs[i].bus,
196 d_config->pcidevs[i].dev, d_config->pcidevs[i].func,
197 d_config->pcidevs[i].vdevfn);
198 fprintf(fh, "\t\t\t(opts msitranslate %d power_mgmt %d)\n",
199 d_config->pcidevs[i].msitranslate,
200 d_config->pcidevs[i].power_mgmt);
201 fprintf(fh, "\t\t)\n");
202 fprintf(fh, "\t)\n");
203 }
204
205 for (i = 0; i < d_config->num_vfbs; i++) {
206 fprintf(fh, "\t(device\n");
207 fprintf(fh, "\t\t(vfb\n");
208 fprintf(fh, "\t\t\t(backend_domid %d)\n", d_config->vfbs[i].backend_domid);
209 fprintf(fh, "\t\t\t(frontend_domid %d)\n", domid);
210 fprintf(fh, "\t\t\t(devid %d)\n", d_config->vfbs[i].devid);
211 fprintf(fh, "\t\t\t(vnc %s)\n",
212 libxl_defbool_to_string(d_config->vfbs[i].vnc.enable));
213 fprintf(fh, "\t\t\t(vnclisten %s)\n", d_config->vfbs[i].vnc.listen);
214 fprintf(fh, "\t\t\t(vncdisplay %d)\n", d_config->vfbs[i].vnc.display);
215 fprintf(fh, "\t\t\t(vncunused %s)\n",
216 libxl_defbool_to_string(d_config->vfbs[i].vnc.findunused));
217 fprintf(fh, "\t\t\t(keymap %s)\n", d_config->vfbs[i].keymap);
218 fprintf(fh, "\t\t\t(sdl %s)\n",
219 libxl_defbool_to_string(d_config->vfbs[i].sdl.enable));
220 fprintf(fh, "\t\t\t(opengl %s)\n",
221 libxl_defbool_to_string(d_config->vfbs[i].sdl.opengl));
222 fprintf(fh, "\t\t\t(display %s)\n", d_config->vfbs[i].sdl.display);
223 fprintf(fh, "\t\t\t(xauthority %s)\n", d_config->vfbs[i].sdl.xauthority);
224 fprintf(fh, "\t\t)\n");
225 fprintf(fh, "\t)\n");
226 }
227 fprintf(fh, ")\n");
228 }
229
230
231 /*
232 * Local variables:
233 * mode: C
234 * c-basic-offset: 4
235 * indent-tabs-mode: nil
236 * End:
237 */
238