debug: compile old domain builder too. Compile both old and new domain builder into the tools, so both are available and can be selected at runtime. Nice for a quick check when things go wrong, to see if the new domain builder is incompatible with the old one or whenever something else broke. Activate with "builder=old" in the config file or as option for the "xm create" command --- tools/libxc/Makefile | 4 +-- tools/libxc/xc_linux_build.c | 4 +-- tools/libxc/xenguest.h | 28 +++++++++++++++++++++ tools/python/xen/lowlevel/xc/xc.c | 50 +++++++++++++++++++++++++++++++++++++- tools/python/xen/xend/image.py | 40 ++++++++++++++++++++++++++++++ 5 files changed, 121 insertions(+), 5 deletions(-) Index: build-32-release304-13087/tools/libxc/Makefile =================================================================== --- build-32-release304-13087.orig/tools/libxc/Makefile +++ build-32-release304-13087/tools/libxc/Makefile @@ -24,8 +24,8 @@ GUEST_SRCS-y := GUEST_SRCS-y += xc_load_bin.c GUEST_SRCS-y += xc_load_elf.c GUEST_SRCS-y += xg_private.c -#GUEST_SRCS-$(CONFIG_X86) += xc_linux_build.c -#GUEST_SRCS-$(CONFIG_IA64) += xc_linux_build.c +GUEST_SRCS-$(CONFIG_X86) += xc_linux_build.c +GUEST_SRCS-$(CONFIG_IA64) += xc_linux_build.c GUEST_SRCS-$(CONFIG_MIGRATE) += xc_linux_restore.c xc_linux_save.c GUEST_SRCS-$(CONFIG_HVM) += xc_hvm_build.c Index: build-32-release304-13087/tools/libxc/xc_linux_build.c =================================================================== --- build-32-release304-13087.orig/tools/libxc/xc_linux_build.c +++ build-32-release304-13087/tools/libxc/xc_linux_build.c @@ -1185,7 +1185,7 @@ static int xc_linux_build_internal(int x return -1; } -int xc_linux_build_mem(int xc_handle, +int old_xc_linux_build_mem(int xc_handle, uint32_t domid, unsigned int mem_mb, const char *image_buffer, @@ -1254,7 +1254,7 @@ int xc_linux_build_mem(int xc_handle, return sts; } -int xc_linux_build(int xc_handle, +int old_xc_linux_build(int xc_handle, uint32_t domid, unsigned int mem_mb, const char *image_name, Index: build-32-release304-13087/tools/libxc/xenguest.h =================================================================== --- build-32-release304-13087.orig/tools/libxc/xenguest.h +++ build-32-release304-13087/tools/libxc/xenguest.h @@ -59,6 +59,19 @@ int xc_linux_restore(int xc_handle, int * @parm conole_mfn returned with the mfn of the console page * @return 0 on success, -1 on failure */ +int old_xc_linux_build(int xc_handle, + uint32_t domid, + unsigned int mem_mb, + const char *image_name, + const char *ramdisk_name, + const char *cmdline, + const char *features, + unsigned long flags, + unsigned int store_evtchn, + unsigned long *store_mfn, + unsigned int console_evtchn, + unsigned long *console_mfn); + int xc_linux_build(int xc_handle, uint32_t domid, unsigned int mem_mb, @@ -91,6 +104,21 @@ int xc_linux_build(int xc_handle, * @parm conole_mfn returned with the mfn of the console page * @return 0 on success, -1 on failure */ +int old_xc_linux_build_mem(int xc_handle, + uint32_t domid, + unsigned int mem_mb, + const char *image_buffer, + unsigned long image_size, + const char *initrd_buffer, + unsigned long initrd_size, + const char *cmdline, + const char *features, + unsigned long flags, + unsigned int store_evtchn, + unsigned long *store_mfn, + unsigned int console_evtchn, + unsigned long *console_mfn); + int xc_linux_build_mem(int xc_handle, uint32_t domid, unsigned int mem_mb, Index: build-32-release304-13087/tools/python/xen/lowlevel/xc/xc.c =================================================================== --- build-32-release304-13087.orig/tools/python/xen/lowlevel/xc/xc.c +++ build-32-release304-13087/tools/python/xen/lowlevel/xc/xc.c @@ -349,6 +349,43 @@ static PyObject *pyxc_vcpu_getinfo(XcObj return info_dict; } +static PyObject *pyxc_old_linux_build(XcObject *self, + PyObject *args, + PyObject *kwds) +{ + uint32_t dom; + char *image, *ramdisk = NULL, *cmdline = "", *features = NULL; + int flags = 0; + int store_evtchn, console_evtchn; + unsigned int mem_mb; + unsigned long store_mfn = 0; + unsigned long console_mfn = 0; + + static char *kwd_list[] = { "domid", "store_evtchn", "memsize", + "console_evtchn", "image", + /* optional */ + "ramdisk", "cmdline", "flags", + "features", NULL }; + + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiis|ssis", kwd_list, + &dom, &store_evtchn, &mem_mb, + &console_evtchn, &image, + /* optional */ + &ramdisk, &cmdline, &flags, + &features) ) + return NULL; + + if ( old_xc_linux_build(self->xc_handle, dom, mem_mb, image, + ramdisk, cmdline, features, flags, + store_evtchn, &store_mfn, + console_evtchn, &console_mfn) != 0 ) { + return pyxc_error_to_exception(); + } + return Py_BuildValue("{s:i,s:i}", + "store_mfn", store_mfn, + "console_mfn", console_mfn); +} + static PyObject *pyxc_linux_build(XcObject *self, PyObject *args, PyObject *kwds) @@ -1093,7 +1130,18 @@ static PyMethodDef pyxc_methods[] = { " cpumap [int]: Bitmap of CPUs this VCPU can run on\n" " cpu [int]: CPU that this VCPU is currently bound to\n" }, - { "linux_build", + { "old_linux_build", + (PyCFunction)pyxc_old_linux_build, + METH_VARARGS | METH_KEYWORDS, "\n" + "Build a new Linux guest OS.\n" + " dom [int]: Identifier of domain to build into.\n" + " image [str]: Name of kernel image file. May be gzipped.\n" + " ramdisk [str, n/a]: Name of ramdisk file, if any.\n" + " cmdline [str, n/a]: Kernel parameters, if any.\n\n" + " vcpus [int, 1]: Number of Virtual CPUS in domain.\n\n" + "Returns: [int] 0 on success; -1 on error.\n" }, + + { "linux_build", (PyCFunction)pyxc_linux_build, METH_VARARGS | METH_KEYWORDS, "\n" "Build a new Linux guest OS.\n" Index: build-32-release304-13087/tools/python/xen/xend/image.py =================================================================== --- build-32-release304-13087.orig/tools/python/xen/xend/image.py +++ build-32-release304-13087/tools/python/xen/xend/image.py @@ -181,6 +181,35 @@ class ImageHandler: pass +class OldLinuxImageHandler(ImageHandler): + + ostype = "linux" + + def buildDomain(self): + store_evtchn = self.vm.getStorePort() + console_evtchn = self.vm.getConsolePort() + + mem_mb = self.getRequiredInitialReservation() / 1024 + + log.debug("domid = %d", self.vm.getDomid()) + log.debug("memsize = %d", mem_mb) + log.debug("image = %s", self.kernel) + log.debug("store_evtchn = %d", store_evtchn) + log.debug("console_evtchn = %d", console_evtchn) + log.debug("cmdline = %s", self.cmdline) + log.debug("ramdisk = %s", self.ramdisk) + log.debug("vcpus = %d", self.vm.getVCpuCount()) + log.debug("features = %s", self.vm.getFeatures()) + + return xc.old_linux_build(domid = self.vm.getDomid(), + memsize = mem_mb, + image = self.kernel, + store_evtchn = store_evtchn, + console_evtchn = console_evtchn, + cmdline = self.cmdline, + ramdisk = self.ramdisk, + features = self.vm.getFeatures()) + class LinuxImageHandler(ImageHandler): ostype = "linux" @@ -625,6 +654,15 @@ class X86_Linux_ImageHandler(LinuxImageH xc.domain_set_memmap_limit(self.vm.getDomid(), mem_kb) return LinuxImageHandler.buildDomain(self) +class X86_OldLinux_ImageHandler(OldLinuxImageHandler): + + def buildDomain(self): + # set physical mapping limit + # add an 8MB slack to balance backend allocations. + mem_kb = self.getRequiredInitialReservation() + (8 * 1024) + xc.domain_set_memmap_limit(self.vm.getDomid(), mem_kb) + return OldLinuxImageHandler.buildDomain(self) + _handlers = { "powerpc": { "linux": PPC_LinuxImageHandler, @@ -632,10 +670,12 @@ _handlers = { }, "ia64": { "linux": LinuxImageHandler, + "old": OldLinuxImageHandler, "hvm": IA64_HVM_ImageHandler, }, "x86": { "linux": X86_Linux_ImageHandler, + "old": X86_OldLinux_ImageHandler, "hvm": X86_HVM_ImageHandler, }, }