mailestone-2
[linux-based-stubdoms.git] / libxl.patch
blob6017fb1bd693953c5fadae6281c28a6288b36954
1 diff -r 0f36c2eec2e1 Config.mk
2 --- a/Config.mk Thu Jul 28 15:40:54 2011 +0100
3 +++ b/Config.mk Fri Dec 02 16:52:49 2011 +0000
4 @@ -209,7 +209,7 @@
6 # Note that using SeaBIOS requires the use the upstream qemu as the
7 # device model.
8 -SEABIOS_DIR ?=
9 +SEABIOS_DIR ?= $(XEN_ROOT)/tools/firmware/seabios-unstable
11 # Optional components
12 XENSTAT_XENTOP ?= y
13 diff -r 0f36c2eec2e1 config/Linux.mk
14 --- a/config/Linux.mk Thu Jul 28 15:40:54 2011 +0100
15 +++ b/config/Linux.mk Fri Dec 02 16:52:49 2011 +0000
16 @@ -1,7 +1,7 @@
17 include $(XEN_ROOT)/config/StdGNU.mk
19 # You may use wildcards, e.g. KERNELS=*2.6*
20 -KERNELS ?=
21 +KERNELS ?= linux-2.6-pvops
23 XKERNELS := $(foreach kernel, $(KERNELS), \
24 $(patsubst buildconfigs/mk.%,%, \
25 diff -r 0f36c2eec2e1 tools/firmware/hvmloader/hvmloader.c
26 --- a/tools/firmware/hvmloader/hvmloader.c Thu Jul 28 15:40:54 2011 +0100
27 +++ b/tools/firmware/hvmloader/hvmloader.c Fri Dec 02 16:52:49 2011 +0000
28 @@ -369,7 +369,7 @@
29 const struct bios_info *b;
30 const char *bios;
32 - bios = xenstore_read("hvmloader/bios", "rombios");
33 + bios = xenstore_read("hvmloader/bios", "seabios");
35 for ( b = &bios_configs[0]; b->key != NULL; b++ )
36 if ( !strcmp(bios, b->key) )
37 @@ -450,7 +450,8 @@
38 bios->create_pir_tables();
41 - if ( bios->load_roms )
42 +// if ( bios->load_roms )
43 + if(1)
45 switch ( virtual_vga )
47 diff -r 0f36c2eec2e1 tools/libxl/libxl.c
48 --- a/tools/libxl/libxl.c Thu Jul 28 15:40:54 2011 +0100
49 +++ b/tools/libxl/libxl.c Fri Dec 02 16:52:49 2011 +0000
50 @@ -1652,6 +1652,7 @@
51 vfb->keymap = NULL;
52 vfb->sdl = 0;
53 vfb->opengl = 0;
54 + vfb->videoram = 2;
57 int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb)
58 @@ -1701,6 +1702,9 @@
59 flexarray_append_pair(front, "backend-id", libxl__sprintf(&gc, "%d", vfb->backend_domid));
60 flexarray_append_pair(front, "state", libxl__sprintf(&gc, "%d", 1));
62 + flexarray_append_pair(back, "videoram", libxl__sprintf(&gc, "%d", vfb->videoram));
63 + flexarray_append_pair(front, "videoram", libxl__sprintf(&gc, "%d", vfb->videoram));
65 libxl__device_generic_add(&gc, &device,
66 libxl__xs_kvs_of_flexarray(&gc, back, back->count),
67 libxl__xs_kvs_of_flexarray(&gc, front, front->count));
68 @@ -2041,7 +2045,8 @@
69 switch (b_info->type) {
70 case LIBXL_DOMAIN_TYPE_HVM:
71 *need_memkb += b_info->shadow_memkb + LIBXL_HVM_EXTRA_MEMORY;
72 - if (dm_info->device_model_stubdomain)
73 + if (dm_info->device_model_stubdomain ||
74 + dm_info->device_model_linux_stubdomain)
75 *need_memkb += 32 * 1024;
76 break;
77 case LIBXL_DOMAIN_TYPE_PV:
78 diff -r 0f36c2eec2e1 tools/libxl/libxl.idl
79 --- a/tools/libxl/libxl.idl Thu Jul 28 15:40:54 2011 +0100
80 +++ b/tools/libxl/libxl.idl Fri Dec 02 16:52:49 2011 +0000
81 @@ -196,6 +196,7 @@
82 ("dom_name", string),
83 ("device_model_version", libxl_device_model_version),
84 ("device_model_stubdomain", bool),
85 + ("device_model_linux_stubdomain", bool),
86 ("device_model", string, False, "if you set this you must set device_model_version too"),
87 ("saved_state", string),
88 ("type", libxl_domain_type),
89 @@ -259,6 +260,7 @@
90 ("opengl", bool, False, "opengl enabled or disabled (if enabled requires sdl enabled)"),
91 ("display", string),
92 ("xauthority", string),
93 + ("videoram", integer),
96 libxl_device_vkb = Struct("device_vkb", [
97 diff -r 0f36c2eec2e1 tools/libxl/libxl_create.c
98 --- a/tools/libxl/libxl_create.c Thu Jul 28 15:40:54 2011 +0100
99 +++ b/tools/libxl/libxl_create.c Fri Dec 02 16:52:49 2011 +0000
100 @@ -124,6 +124,7 @@
101 dm_info->dom_name = strdup(c_info->name);
102 dm_info->device_model_version = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
103 dm_info->device_model_stubdomain = false;
104 + dm_info->device_model_linux_stubdomain = false;
105 dm_info->device_model = NULL;
106 dm_info->target_ram = libxl__sizekb_to_mb(b_info->target_memkb);
107 dm_info->videoram = libxl__sizekb_to_mb(b_info->video_memkb);
108 diff -r 0f36c2eec2e1 tools/libxl/libxl_device.c
109 --- a/tools/libxl/libxl_device.c Thu Jul 28 15:40:54 2011 +0100
110 +++ b/tools/libxl/libxl_device.c Fri Dec 02 16:52:49 2011 +0000
111 @@ -552,8 +552,8 @@
112 tv.tv_sec = LIBXL_DEVICE_MODEL_START_TIMEOUT;
113 tv.tv_usec = 0;
114 nfds = xs_fileno(xsh) + 1;
115 - if (starting && starting->for_spawn->fd > xs_fileno(xsh))
116 - nfds = starting->for_spawn->fd + 1;
117 + //if (starting && starting->for_spawn->fd > xs_fileno(xsh))
118 + // nfds = starting->for_spawn->fd + 1;
120 while (rc > 0 || (!rc && tv.tv_sec > 0)) {
121 if ( starting ) {
122 @@ -586,8 +586,8 @@
123 free(p);
124 FD_ZERO(&rfds);
125 FD_SET(xs_fileno(xsh), &rfds);
126 - if (starting)
127 - FD_SET(starting->for_spawn->fd, &rfds);
128 + //if (starting)
129 + // FD_SET(starting->for_spawn->fd, &rfds);
130 rc = select(nfds, &rfds, NULL, NULL, &tv);
131 if (rc > 0) {
132 if (FD_ISSET(xs_fileno(xsh), &rfds)) {
133 @@ -597,12 +597,12 @@
134 else
135 goto again;
137 - if (starting && FD_ISSET(starting->for_spawn->fd, &rfds)) {
138 - unsigned char dummy;
139 - if (read(starting->for_spawn->fd, &dummy, sizeof(dummy)) != 1)
140 - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_DEBUG,
141 - "failed to read spawn status pipe");
143 + //if (starting && FD_ISSET(starting->for_spawn->fd, &rfds)) {
144 + // unsigned char dummy;
145 + // if (read(starting->for_spawn->fd, &dummy, sizeof(dummy)) != 1)
146 + // LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_DEBUG,
147 + // "failed to read spawn status pipe");
148 + //}
151 LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Device Model not ready");
152 diff -r 0f36c2eec2e1 tools/libxl/libxl_dm.c
153 --- a/tools/libxl/libxl_dm.c Thu Jul 28 15:40:54 2011 +0100
154 +++ b/tools/libxl/libxl_dm.c Fri Dec 02 16:52:49 2011 +0000
155 @@ -29,9 +29,12 @@
156 #include "libxl.h"
157 #include "flexarray.h"
159 -static const char *libxl_tapif_script(libxl__gc *gc)
160 +static const char *libxl_tapif_script(libxl__gc *gc,
161 + libxl_device_model_info *info)
163 #ifdef __linux__
164 + if(info->device_model_linux_stubdomain)
165 + return libxl__sprintf(gc, "/bin/qemu-ifup");
166 return libxl__strdup(gc, "no");
167 #else
168 return libxl__sprintf(gc, "%s/qemu-ifup", libxl_xen_script_dir_path());
169 @@ -44,7 +47,8 @@
170 libxl_ctx *ctx = libxl__gc_owner(gc);
171 const char *dm;
173 - if (info->device_model_stubdomain)
174 + if (info->device_model_stubdomain ||
175 + info->device_model_linux_stubdomain)
176 return NULL;
178 if (info->device_model) {
179 @@ -55,7 +59,7 @@
180 dm = libxl__abs_path(gc, "qemu-dm", libxl_libexec_path());
181 break;
182 case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
183 - dm = libxl__strdup(gc, "/usr/bin/qemu");
184 + dm = libxl__strdup(gc, "/usr/local/bin/qemu");
185 break;
186 default:
187 LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
188 @@ -184,7 +188,7 @@
189 "-net", libxl__sprintf(gc, "nic,vlan=%d,macaddr=%s,model=%s",
190 vifs[i].devid, smac, vifs[i].model),
191 "-net", libxl__sprintf(gc, "tap,vlan=%d,ifname=%s,bridge=%s,script=%s",
192 - vifs[i].devid, ifname, vifs[i].bridge, libxl_tapif_script(gc)),
193 + vifs[i].devid, ifname, vifs[i].bridge, libxl_tapif_script(gc, info)),
194 NULL);
195 ioemu_vifs++;
197 @@ -384,7 +388,7 @@
198 flexarray_append(dm_args,
199 libxl__sprintf(gc, "type=tap,id=net%d,ifname=%s,script=%s",
200 vifs[i].devid, ifname,
201 - libxl_tapif_script(gc)));
202 + libxl_tapif_script(gc, info)));
203 ioemu_vifs++;
206 @@ -421,6 +425,12 @@
207 flexarray_append(dm_args, "-m");
208 flexarray_append(dm_args, libxl__sprintf(gc, "%d", info->target_ram));
210 + flexarray_append(dm_args, "-machine");
211 + flexarray_append(dm_args, "accel=xen");
213 + if (info->device_model_linux_stubdomain)
214 + flexarray_append(dm_args, "-fbdev");
216 if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
217 for (i = 0; i < num_disks; i++) {
218 int disk, part;
219 @@ -439,6 +449,10 @@
220 if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY)
221 drive = libxl__sprintf
222 (gc, "if=ide,index=%d,media=cdrom", disk);
223 + else if (info->device_model_linux_stubdomain)
224 + drive = libxl__sprintf
225 + (gc, "file=%s,if=ide,index=%d,media=cdrom,format=%s",
226 + "/dev/xvdc", disk, "host_cdrom");
227 else
228 drive = libxl__sprintf
229 (gc, "file=%s,if=ide,index=%d,media=cdrom,format=%s",
230 @@ -466,10 +480,15 @@
231 drive = libxl__sprintf
232 (gc, "file=%s,if=scsi,bus=0,unit=%d,format=%s",
233 disks[i].pdev_path, disk, format);
234 - else if (disk < 4)
235 - drive = libxl__sprintf
236 - (gc, "file=%s,if=ide,index=%d,media=disk,format=%s",
237 - disks[i].pdev_path, disk, format);
238 + else if (disk < 4)
239 + if (info->device_model_linux_stubdomain)
240 + drive = libxl__sprintf
241 + (gc, "file=%s,if=ide,index=%d,media=disk,format=%s",
242 + "/dev/xvda", disk, "host_device");
243 + else
244 + drive = libxl__sprintf
245 + (gc, "file=%s,if=ide,index=%d,media=disk,format=%s",
246 + disks[i].pdev_path, disk, format);
247 else
248 continue; /* Do not emulate this disk */
250 @@ -618,18 +637,18 @@
251 libxl_domain_build_info b_info;
252 libxl__domain_build_state state;
253 uint32_t domid;
254 - char **args;
255 + char **args=NULL;
256 struct xs_permissions perm[2];
257 xs_transaction_t t;
258 libxl__device_model_starting *dm_starting = 0;
259 libxl_device_model_info xenpv_dm_info;
261 - if (info->device_model_version != LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL) {
262 - ret = ERROR_INVAL;
263 - goto out;
266 - args = libxl__build_device_model_args(gc, "stubdom-dm", info,
267 + if (info->device_model_stubdomain)
268 + args = libxl__build_device_model_args(gc, "stubdom-dm", info,
269 + disks, num_disks,
270 + vifs, num_vifs);
271 + if(info->device_model_linux_stubdomain)
272 + args = libxl__build_device_model_args(gc, "linux-stubdom", info,
273 disks, num_disks,
274 vifs, num_vifs);
275 if (!args) {
276 @@ -645,16 +664,27 @@
278 memset(&b_info, 0x00, sizeof(libxl_domain_build_info));
279 b_info.max_vcpus = 1;
280 - b_info.max_memkb = 32 * 1024;
281 + b_info.max_memkb = 64 * 1024;
282 b_info.target_memkb = b_info.max_memkb;
284 b_info.type = LIBXL_DOMAIN_TYPE_PV;
285 - b_info.u.pv.kernel.path = libxl__abs_path(gc, "ioemu-stubdom.gz",
286 - libxl_xenfirmwaredir_path());
287 - b_info.u.pv.cmdline = libxl__sprintf(gc, " -d %d", info->domid);
288 - b_info.u.pv.ramdisk.path = "";
289 b_info.u.pv.features = "";
291 + if(info->device_model_linux_stubdomain){
292 + b_info.u.pv.cmdline = libxl__sprintf(gc, " -d %d", info->domid);
293 + b_info.u.pv.kernel.path = libxl__abs_path(gc, "vmlinuz-ioemu",
294 + libxl_xenfirmwaredir_path());
295 + b_info.u.pv.ramdisk.path = libxl__abs_path(gc, "ramdisk-ioemu",
296 + libxl_xenfirmwaredir_path());
297 + b_info.video_memkb = 8 * 1024;
298 + vfb->videoram = 8;
299 + }else if(info->device_model_stubdomain){
300 + b_info.u.pv.cmdline = libxl__sprintf(gc, " -d %d video=vfb:800*600-32", info->domid);
301 + b_info.u.pv.kernel.path = libxl__abs_path(gc, "ioemu-stubdom.gz",
302 + libxl_xenfirmwaredir_path());
303 + b_info.u.pv.ramdisk.path = "";
306 /* fixme: this function can leak the stubdom if it fails */
307 domid = 0;
308 ret = libxl__domain_make(gc, &c_info, &domid);
309 @@ -732,7 +762,9 @@
310 case STUBDOM_CONSOLE_LOGGING:
311 name = libxl__sprintf(gc, "qemu-dm-%s", libxl_domid_to_name(ctx, info->domid));
312 libxl_create_logfile(ctx, name, &filename);
313 - console[i].output = libxl__sprintf(gc, "file:%s", filename);
314 + //console[i].output = libxl__sprintf(gc, "file:%s", filename);
315 + //for debugging
316 + console[i].output = libxl__sprintf(gc, "/dev/hvc0");
317 free(filename);
318 break;
319 case STUBDOM_CONSOLE_SAVE:
320 @@ -805,11 +837,13 @@
321 char **pass_stuff;
322 const char *dm;
324 - if (info->device_model_stubdomain) {
325 + if (info->device_model_stubdomain ||
326 + info->device_model_linux_stubdomain) {
327 libxl_device_vfb vfb;
328 libxl_device_vkb vkb;
330 libxl__vfb_and_vkb_from_device_model_info(gc, info, &vfb, &vkb);
331 + vfb.sdl=1;
332 rc = libxl__create_stubdom(gc, info,
333 disks, num_disks,
334 vifs, num_vifs,
335 diff -r 0f36c2eec2e1 tools/libxl/xl_cmdimpl.c
336 --- a/tools/libxl/xl_cmdimpl.c Thu Jul 28 15:40:54 2011 +0100
337 +++ b/tools/libxl/xl_cmdimpl.c Fri Dec 02 16:52:49 2011 +0000
338 @@ -1061,6 +1061,8 @@
339 fprintf(stderr, "WARNING: device model override given without specific DM version\n");
340 if (!xlu_cfg_get_long (config, "device_model_stubdomain_override", &l))
341 dm_info->device_model_stubdomain = l;
342 + else if (!xlu_cfg_get_long (config, "device_model_linux_stubdomain_override", &l))
343 + dm_info->device_model_linux_stubdomain = l;
345 #define parse_extra_args(type) \
346 if (!xlu_cfg_get_list(config, "device_model_args"#type, \