diff options
-rw-r--r-- | tools/libxc/xc.h | 4 | ||||
-rw-r--r-- | tools/libxc/xc_linux_build.c | 59 | ||||
-rw-r--r-- | tools/python/xen/lowlevel/xc/xc.c | 25 | ||||
-rw-r--r-- | tools/python/xen/xend/XendDomainInfo.py | 6 | ||||
-rw-r--r-- | tools/python/xen/xend/image.py | 31 | ||||
-rw-r--r-- | xen/include/public/xen.h | 25 |
6 files changed, 90 insertions, 60 deletions
diff --git a/tools/libxc/xc.h b/tools/libxc/xc.h index c31222fc90..f759e79d8b 100644 --- a/tools/libxc/xc.h +++ b/tools/libxc/xc.h @@ -252,7 +252,9 @@ int xc_linux_build(int xc_handle, const char *cmdline, unsigned int control_evtchn, unsigned long flags, - unsigned int vcpus); + unsigned int vcpus, + unsigned int store_evtchn, + unsigned long *store_mfn); int xc_plan9_build (int xc_handle, diff --git a/tools/libxc/xc_linux_build.c b/tools/libxc/xc_linux_build.c index bf92bc749d..768874a203 100644 --- a/tools/libxc/xc_linux_build.c +++ b/tools/libxc/xc_linux_build.c @@ -40,17 +40,18 @@ loadelfsymtab( struct domain_setup_info *dsi); static int setup_guest(int xc_handle, - u32 dom, - char *image, unsigned long image_size, - gzFile initrd_gfd, unsigned long initrd_len, - unsigned long nr_pages, - unsigned long *pvsi, unsigned long *pvke, - vcpu_guest_context_t *ctxt, - const char *cmdline, - unsigned long shared_info_frame, - unsigned int control_evtchn, - unsigned long flags, - unsigned int vcpus) + u32 dom, + char *image, unsigned long image_size, + gzFile initrd_gfd, unsigned long initrd_len, + unsigned long nr_pages, + unsigned long *pvsi, unsigned long *pvke, + unsigned long *pvss, vcpu_guest_context_t *ctxt, + const char *cmdline, + unsigned long shared_info_frame, + unsigned int control_evtchn, + unsigned long flags, + unsigned int vcpus, + unsigned int store_evtchn, unsigned long *store_mfn) { l1_pgentry_t *vl1tab=NULL, *vl1e=NULL; l2_pgentry_t *vl2tab=NULL, *vl2e=NULL; @@ -74,6 +75,8 @@ static int setup_guest(int xc_handle, unsigned long vphysmap_end; unsigned long vstartinfo_start; unsigned long vstartinfo_end; + unsigned long vstoreinfo_start; + unsigned long vstoreinfo_end; unsigned long vstack_start; unsigned long vstack_end; unsigned long vpt_start; @@ -109,7 +112,10 @@ static int setup_guest(int xc_handle, vpt_end = vpt_start + (nr_pt_pages * PAGE_SIZE); vstartinfo_start = vpt_end; vstartinfo_end = vstartinfo_start + PAGE_SIZE; - vstack_start = vstartinfo_end; + /* Place store shared page after startinfo. */ + vstoreinfo_start = vstartinfo_end; + vstoreinfo_end = vstartinfo_end + PAGE_SIZE; + vstack_start = vstoreinfo_end; vstack_end = vstack_start + PAGE_SIZE; v_end = (vstack_end + (1<<22)-1) & ~((1<<22)-1); if ( (v_end - vstack_end) < (512 << 10) ) @@ -125,6 +131,7 @@ static int setup_guest(int xc_handle, " Phys-Mach map: %08lx->%08lx\n" " Page tables: %08lx->%08lx\n" " Start info: %08lx->%08lx\n" + " Store page: %08lx->%08lx\n" " Boot stack: %08lx->%08lx\n" " TOTAL: %08lx->%08lx\n", dsi.v_kernstart, dsi.v_kernend, @@ -132,6 +139,7 @@ static int setup_guest(int xc_handle, vphysmap_start, vphysmap_end, vpt_start, vpt_end, vstartinfo_start, vstartinfo_end, + vstoreinfo_start, vstoreinfo_end, vstack_start, vstack_end, dsi.v_start, v_end); printf(" ENTRY ADDRESS: %08lx\n", dsi.v_kernentry); @@ -261,6 +269,8 @@ static int setup_guest(int xc_handle, start_info->nr_pt_frames = nr_pt_pages; start_info->mfn_list = vphysmap_start; start_info->domain_controller_evtchn = control_evtchn; + start_info->store_page = vstoreinfo_start; + start_info->store_evtchn = store_evtchn; if ( initrd_len != 0 ) { start_info->mod_start = vinitrd_start; @@ -270,6 +280,9 @@ static int setup_guest(int xc_handle, start_info->cmd_line[MAX_CMDLINE-1] = '\0'; munmap(start_info, PAGE_SIZE); + /* Tell our caller where we told domain store page was. */ + *store_mfn = page_array[((vstoreinfo_start-dsi.v_start)>>PAGE_SHIFT)]; + /* shared_info page starts its life empty. */ shared_info = xc_map_foreign_range( xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, shared_info_frame); @@ -291,6 +304,7 @@ static int setup_guest(int xc_handle, free(page_array); *pvsi = vstartinfo_start; + *pvss = vstack_start; *pvke = dsi.v_kernentry; return 0; @@ -310,7 +324,9 @@ int xc_linux_build(int xc_handle, const char *cmdline, unsigned int control_evtchn, unsigned long flags, - unsigned int vcpus) + unsigned int vcpus, + unsigned int store_evtchn, + unsigned long *store_mfn) { dom0_op_t launch_op, op; int initrd_fd = -1; @@ -320,7 +336,7 @@ int xc_linux_build(int xc_handle, unsigned long nr_pages; char *image = NULL; unsigned long image_size, initrd_size=0; - unsigned long vstartinfo_start, vkern_entry; + unsigned long vstartinfo_start, vkern_entry, vstack_start; if ( (nr_pages = xc_get_tot_pages(xc_handle, domid)) < 0 ) { @@ -377,11 +393,12 @@ int xc_linux_build(int xc_handle, } if ( setup_guest(xc_handle, domid, image, image_size, - initrd_gfd, initrd_size, nr_pages, - &vstartinfo_start, &vkern_entry, - ctxt, cmdline, - op.u.getdomaininfo.shared_info_frame, - control_evtchn, flags, vcpus) < 0 ) + initrd_gfd, initrd_size, nr_pages, + &vstartinfo_start, &vkern_entry, + &vstack_start, ctxt, cmdline, + op.u.getdomaininfo.shared_info_frame, + control_evtchn, flags, vcpus, + store_evtchn, store_mfn) < 0 ) { ERROR("Error constructing guest OS"); goto error_out; @@ -412,7 +429,7 @@ int xc_linux_build(int xc_handle, ctxt->user_regs.ss = FLAT_KERNEL_DS; ctxt->user_regs.cs = FLAT_KERNEL_CS; ctxt->user_regs.eip = vkern_entry; - ctxt->user_regs.esp = vstartinfo_start + 2*PAGE_SIZE; + ctxt->user_regs.esp = vstack_start + PAGE_SIZE; ctxt->user_regs.esi = vstartinfo_start; ctxt->user_regs.eflags = 1 << 9; /* Interrupt Enable */ @@ -434,7 +451,7 @@ int xc_linux_build(int xc_handle, /* Ring 1 stack is the initial stack. */ ctxt->kernel_ss = FLAT_KERNEL_DS; - ctxt->kernel_sp = vstartinfo_start + 2*PAGE_SIZE; + ctxt->kernel_sp = vstack_start + PAGE_SIZE; /* No debugging. */ memset(ctxt->debugreg, 0, sizeof(ctxt->debugreg)); diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c index 5b548c77e4..5018a4e4e7 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -260,25 +260,28 @@ static PyObject *pyxc_linux_build(PyObject *self, { XcObject *xc = (XcObject *)self; - u32 dom; + u32 dom; char *image, *ramdisk = NULL, *cmdline = ""; - int control_evtchn, flags = 0, vcpus = 1; + int flags = 0, vcpus = 1; + int control_evtchn, store_evtchn; + unsigned long store_mfn = 0; - static char *kwd_list[] = { "dom", "control_evtchn", - "image", "ramdisk", "cmdline", "flags", "vcpus", - NULL }; + static char *kwd_list[] = { "dom", "control_evtchn", "store_evtchn", + "image", "ramdisk", "cmdline", "flags", + "vcpus", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|ssii", kwd_list, - &dom, &control_evtchn, - &image, &ramdisk, &cmdline, &flags, &vcpus) ) + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiis|ssii", kwd_list, + &dom, &control_evtchn, &store_evtchn, + &image, &ramdisk, &cmdline, &flags, + &vcpus) ) return NULL; if ( xc_linux_build(xc->xc_handle, dom, image, - ramdisk, cmdline, control_evtchn, flags, vcpus) != 0 ) + ramdisk, cmdline, control_evtchn, flags, vcpus, + store_evtchn, &store_mfn) != 0 ) return PyErr_SetFromErrno(xc_error); - Py_INCREF(zero); - return zero; + return Py_BuildValue("{s:i}", "store_mfn", store_mfn); } static PyObject *pyxc_plan9_build(PyObject *self, diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index 257ee38c4f..c466910d97 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -148,7 +148,7 @@ class XendDomainInfo: def _create(cls, uuid=None): """Create a vm object with a uuid. - @param uuid uuid to use (generated if None) + @param uuid uuid to use @return vm """ if uuid is None: @@ -178,6 +178,7 @@ class XendDomainInfo: @param savedinfo: saved info from the domain DB @param info: domain info from xc + @param uuid: uuid to use @type info: xc domain dict """ vm = cls._create(uuid=uuid) @@ -216,6 +217,7 @@ class XendDomainInfo: """Create a domain and a VM object to do a restore. @param config: domain configuration + @param uuid: uuid to use """ vm = cls._create(uuid=uuid) dom = xc.domain_create() @@ -239,6 +241,8 @@ class XendDomainInfo: self.image = None self.channel = None + self.store_channel = None + self.store_mfs = None self.controllers = {} self.info = None diff --git a/tools/python/xen/xend/image.py b/tools/python/xen/xend/image.py index 09fe390b49..d7f6965767 100644 --- a/tools/python/xen/xend/image.py +++ b/tools/python/xen/xend/image.py @@ -202,21 +202,22 @@ class LinuxImageHandler(ImageHandler): ostype = "linux" def buildDomain(self): - #if self.vm.store_channel: - # store_evtchn = self.vm.store_channel.port2 - #else: - # store_evtchn = 0 - d = xc.linux_build(dom = self.vm.getDomain(), - image = self.kernel, - control_evtchn = self.vm.channel.getRemotePort(), - #store_evtchn = store_evtchn, - cmdline = self.cmdline, - ramdisk = self.ramdisk, - flags = self.flags, - vcpus = self.vm.vcpus) - #if isinstance(d, dict): - # self.vm.store_mfn = d.get('store_mfn') - return 0 + if self.vm.store_channel: + store_evtchn = self.vm.store_channel.port2 + else: + store_evtchn = 0 + ret = xc.linux_build(dom = self.vm.getDomain(), + image = self.kernel, + control_evtchn = self.vm.channel.getRemotePort(), + store_evtchn = store_evtchn, + cmdline = self.cmdline, + ramdisk = self.ramdisk, + flags = self.flags, + vcpus = self.vm.vcpus) + if isinstance(ret, dict): + self.vm.store_mfn = ret.get('store_mfn') + return 0 + return ret class Plan9ImageHandler(ImageHandler): diff --git a/xen/include/public/xen.h b/xen/include/public/xen.h index 11f82823a7..a6e2f50d81 100644 --- a/xen/include/public/xen.h +++ b/xen/include/public/xen.h @@ -431,27 +431,30 @@ typedef struct shared_info_st #define MAX_CMDLINE 256 typedef struct { - /* THE FOLLOWING ARE FILLED IN BOTH ON INITIAL BOOT AND ON RESUME. */ - memory_t nr_pages; /* 0: Total pages allocated to this domain. */ + /* THE FOLLOWING ARE FILLED IN BOTH ON INITIAL BOOT AND ON RESUME. */ + memory_t nr_pages; /* 0: Total pages allocated to this domain. */ _MEMORY_PADDING(A); - memory_t shared_info; /* 8: MACHINE address of shared info struct.*/ + memory_t shared_info; /* 8: MACHINE address of shared info struct. */ _MEMORY_PADDING(B); - u32 flags; /* 16: SIF_xxx flags. */ + u32 flags; /* 16: SIF_xxx flags. */ u16 domain_controller_evtchn; /* 20 */ u16 __pad; - /* THE FOLLOWING ARE ONLY FILLED IN ON INITIAL BOOT (NOT RESUME). */ - memory_t pt_base; /* 24: VIRTUAL address of page directory. */ + /* THE FOLLOWING ARE ONLY FILLED IN ON INITIAL BOOT (NOT RESUME). */ + memory_t pt_base; /* 24: VIRTUAL address of page directory. */ _MEMORY_PADDING(C); - memory_t nr_pt_frames; /* 32: Number of bootstrap p.t. frames. */ + memory_t nr_pt_frames; /* 32: Number of bootstrap p.t. frames. */ _MEMORY_PADDING(D); - memory_t mfn_list; /* 40: VIRTUAL address of page-frame list. */ + memory_t mfn_list; /* 40: VIRTUAL address of page-frame list. */ _MEMORY_PADDING(E); - memory_t mod_start; /* 48: VIRTUAL address of pre-loaded module. */ + memory_t mod_start; /* 48: VIRTUAL address of pre-loaded module. */ _MEMORY_PADDING(F); - memory_t mod_len; /* 56: Size (bytes) of pre-loaded module. */ + memory_t mod_len; /* 56: Size (bytes) of pre-loaded module. */ _MEMORY_PADDING(G); s8 cmd_line[MAX_CMDLINE]; /* 64 */ -} PACKED start_info_t; /* 320 bytes */ + memory_t store_page; /* 320: VIRTUAL address of store page. */ + _MEMORY_PADDING(H); + u16 store_evtchn; /* 328: Event channel for store communication. */ +} PACKED start_info_t; /* 332/336 bytes */ /* These flags are passed in the 'flags' field of start_info_t. */ #define SIF_PRIVILEGED (1<<0) /* Is the domain privileged? */ |