ia64/xen-unstable

changeset 5349:c768bf758ce1

bitkeeper revision 1.1662.1.11 (42a4a26bkrYJJbT21Mpjyew3rnh7Cw)

xen.h, image.py, XendDomainInfo.py, xc.c, xc_linux_build.c, xc.h:
Create store page for domains and plumb through to python.
XendDomainInfo.py:
Cleanup comments.
Signed-off-by: Mike Wray <mike.wray@hp.com>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Mon Jun 06 19:22:19 2005 +0000 (2005-06-06)
parents 9f893f674211
children 59e72b0399ac
files tools/libxc/xc.h tools/libxc/xc_linux_build.c tools/python/xen/lowlevel/xc/xc.c tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/image.py xen/include/public/xen.h
line diff
     1.1 --- a/tools/libxc/xc.h	Mon Jun 06 17:51:41 2005 +0000
     1.2 +++ b/tools/libxc/xc.h	Mon Jun 06 19:22:19 2005 +0000
     1.3 @@ -252,7 +252,9 @@ int xc_linux_build(int xc_handle,
     1.4                     const char *cmdline,
     1.5                     unsigned int control_evtchn,
     1.6                     unsigned long flags,
     1.7 -                   unsigned int vcpus);
     1.8 +                   unsigned int vcpus,
     1.9 +                   unsigned int store_evtchn,
    1.10 +                   unsigned long *store_mfn);
    1.11  
    1.12  int
    1.13  xc_plan9_build (int xc_handle,
     2.1 --- a/tools/libxc/xc_linux_build.c	Mon Jun 06 17:51:41 2005 +0000
     2.2 +++ b/tools/libxc/xc_linux_build.c	Mon Jun 06 19:22:19 2005 +0000
     2.3 @@ -40,17 +40,18 @@ loadelfsymtab(
     2.4      struct domain_setup_info *dsi);
     2.5  
     2.6  static int setup_guest(int xc_handle,
     2.7 -                         u32 dom,
     2.8 -                         char *image, unsigned long image_size,
     2.9 -                         gzFile initrd_gfd, unsigned long initrd_len,
    2.10 -                         unsigned long nr_pages,
    2.11 -                         unsigned long *pvsi, unsigned long *pvke,
    2.12 -                         vcpu_guest_context_t *ctxt,
    2.13 -                         const char *cmdline,
    2.14 -                         unsigned long shared_info_frame,
    2.15 -                         unsigned int control_evtchn,
    2.16 -                         unsigned long flags,
    2.17 -                         unsigned int vcpus)
    2.18 +                       u32 dom,
    2.19 +                       char *image, unsigned long image_size,
    2.20 +                       gzFile initrd_gfd, unsigned long initrd_len,
    2.21 +                       unsigned long nr_pages,
    2.22 +                       unsigned long *pvsi, unsigned long *pvke,
    2.23 +                       unsigned long *pvss, vcpu_guest_context_t *ctxt,
    2.24 +                       const char *cmdline,
    2.25 +                       unsigned long shared_info_frame,
    2.26 +                       unsigned int control_evtchn,
    2.27 +                       unsigned long flags,
    2.28 +                       unsigned int vcpus,
    2.29 +		       unsigned int store_evtchn, unsigned long *store_mfn)
    2.30  {
    2.31      l1_pgentry_t *vl1tab=NULL, *vl1e=NULL;
    2.32      l2_pgentry_t *vl2tab=NULL, *vl2e=NULL;
    2.33 @@ -74,6 +75,8 @@ static int setup_guest(int xc_handle,
    2.34      unsigned long vphysmap_end;
    2.35      unsigned long vstartinfo_start;
    2.36      unsigned long vstartinfo_end;
    2.37 +    unsigned long vstoreinfo_start;
    2.38 +    unsigned long vstoreinfo_end;
    2.39      unsigned long vstack_start;
    2.40      unsigned long vstack_end;
    2.41      unsigned long vpt_start;
    2.42 @@ -109,7 +112,10 @@ static int setup_guest(int xc_handle,
    2.43          vpt_end          = vpt_start + (nr_pt_pages * PAGE_SIZE);
    2.44          vstartinfo_start = vpt_end;
    2.45          vstartinfo_end   = vstartinfo_start + PAGE_SIZE;
    2.46 -        vstack_start     = vstartinfo_end;
    2.47 +        /* Place store shared page after startinfo. */
    2.48 +        vstoreinfo_start = vstartinfo_end;
    2.49 +        vstoreinfo_end   = vstartinfo_end + PAGE_SIZE;
    2.50 +        vstack_start     = vstoreinfo_end;
    2.51          vstack_end       = vstack_start + PAGE_SIZE;
    2.52          v_end            = (vstack_end + (1<<22)-1) & ~((1<<22)-1);
    2.53          if ( (v_end - vstack_end) < (512 << 10) )
    2.54 @@ -125,6 +131,7 @@ static int setup_guest(int xc_handle,
    2.55             " Phys-Mach map: %08lx->%08lx\n"
    2.56             " Page tables:   %08lx->%08lx\n"
    2.57             " Start info:    %08lx->%08lx\n"
    2.58 +           " Store page:    %08lx->%08lx\n"
    2.59             " Boot stack:    %08lx->%08lx\n"
    2.60             " TOTAL:         %08lx->%08lx\n",
    2.61             dsi.v_kernstart, dsi.v_kernend, 
    2.62 @@ -132,6 +139,7 @@ static int setup_guest(int xc_handle,
    2.63             vphysmap_start, vphysmap_end,
    2.64             vpt_start, vpt_end,
    2.65             vstartinfo_start, vstartinfo_end,
    2.66 +           vstoreinfo_start, vstoreinfo_end,
    2.67             vstack_start, vstack_end,
    2.68             dsi.v_start, v_end);
    2.69      printf(" ENTRY ADDRESS: %08lx\n", dsi.v_kernentry);
    2.70 @@ -261,6 +269,8 @@ static int setup_guest(int xc_handle,
    2.71      start_info->nr_pt_frames = nr_pt_pages;
    2.72      start_info->mfn_list     = vphysmap_start;
    2.73      start_info->domain_controller_evtchn = control_evtchn;
    2.74 +    start_info->store_page   = vstoreinfo_start;
    2.75 +    start_info->store_evtchn = store_evtchn;
    2.76      if ( initrd_len != 0 )
    2.77      {
    2.78          start_info->mod_start    = vinitrd_start;
    2.79 @@ -270,6 +280,9 @@ static int setup_guest(int xc_handle,
    2.80      start_info->cmd_line[MAX_CMDLINE-1] = '\0';
    2.81      munmap(start_info, PAGE_SIZE);
    2.82  
    2.83 +    /* Tell our caller where we told domain store page was. */
    2.84 +    *store_mfn = page_array[((vstoreinfo_start-dsi.v_start)>>PAGE_SHIFT)];
    2.85 +
    2.86      /* shared_info page starts its life empty. */
    2.87      shared_info = xc_map_foreign_range(
    2.88          xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, shared_info_frame);
    2.89 @@ -291,6 +304,7 @@ static int setup_guest(int xc_handle,
    2.90      free(page_array);
    2.91  
    2.92      *pvsi = vstartinfo_start;
    2.93 +    *pvss = vstack_start;
    2.94      *pvke = dsi.v_kernentry;
    2.95  
    2.96      return 0;
    2.97 @@ -310,7 +324,9 @@ int xc_linux_build(int xc_handle,
    2.98                     const char *cmdline,
    2.99                     unsigned int control_evtchn,
   2.100                     unsigned long flags,
   2.101 -                   unsigned int vcpus)
   2.102 +                   unsigned int vcpus,
   2.103 +                   unsigned int store_evtchn,
   2.104 +                   unsigned long *store_mfn)
   2.105  {
   2.106      dom0_op_t launch_op, op;
   2.107      int initrd_fd = -1;
   2.108 @@ -320,7 +336,7 @@ int xc_linux_build(int xc_handle,
   2.109      unsigned long nr_pages;
   2.110      char         *image = NULL;
   2.111      unsigned long image_size, initrd_size=0;
   2.112 -    unsigned long vstartinfo_start, vkern_entry;
   2.113 +    unsigned long vstartinfo_start, vkern_entry, vstack_start;
   2.114  
   2.115      if ( (nr_pages = xc_get_tot_pages(xc_handle, domid)) < 0 )
   2.116      {
   2.117 @@ -377,11 +393,12 @@ int xc_linux_build(int xc_handle,
   2.118      }
   2.119  
   2.120      if ( setup_guest(xc_handle, domid, image, image_size, 
   2.121 -                       initrd_gfd, initrd_size, nr_pages, 
   2.122 -                       &vstartinfo_start, &vkern_entry,
   2.123 -                       ctxt, cmdline,
   2.124 -                       op.u.getdomaininfo.shared_info_frame,
   2.125 -                       control_evtchn, flags, vcpus) < 0 )
   2.126 +                     initrd_gfd, initrd_size, nr_pages, 
   2.127 +                     &vstartinfo_start, &vkern_entry,
   2.128 +                     &vstack_start, ctxt, cmdline,
   2.129 +                     op.u.getdomaininfo.shared_info_frame,
   2.130 +                     control_evtchn, flags, vcpus,
   2.131 +                     store_evtchn, store_mfn) < 0 )
   2.132      {
   2.133          ERROR("Error constructing guest OS");
   2.134          goto error_out;
   2.135 @@ -412,7 +429,7 @@ int xc_linux_build(int xc_handle,
   2.136      ctxt->user_regs.ss = FLAT_KERNEL_DS;
   2.137      ctxt->user_regs.cs = FLAT_KERNEL_CS;
   2.138      ctxt->user_regs.eip = vkern_entry;
   2.139 -    ctxt->user_regs.esp = vstartinfo_start + 2*PAGE_SIZE;
   2.140 +    ctxt->user_regs.esp = vstack_start + PAGE_SIZE;
   2.141      ctxt->user_regs.esi = vstartinfo_start;
   2.142      ctxt->user_regs.eflags = 1 << 9; /* Interrupt Enable */
   2.143  
   2.144 @@ -434,7 +451,7 @@ int xc_linux_build(int xc_handle,
   2.145  
   2.146      /* Ring 1 stack is the initial stack. */
   2.147      ctxt->kernel_ss = FLAT_KERNEL_DS;
   2.148 -    ctxt->kernel_sp = vstartinfo_start + 2*PAGE_SIZE;
   2.149 +    ctxt->kernel_sp = vstack_start + PAGE_SIZE;
   2.150  
   2.151      /* No debugging. */
   2.152      memset(ctxt->debugreg, 0, sizeof(ctxt->debugreg));
     3.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Mon Jun 06 17:51:41 2005 +0000
     3.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Mon Jun 06 19:22:19 2005 +0000
     3.3 @@ -260,25 +260,28 @@ static PyObject *pyxc_linux_build(PyObje
     3.4  {
     3.5      XcObject *xc = (XcObject *)self;
     3.6  
     3.7 -    u32   dom;
     3.8 +    u32 dom;
     3.9      char *image, *ramdisk = NULL, *cmdline = "";
    3.10 -    int   control_evtchn, flags = 0, vcpus = 1;
    3.11 +    int flags = 0, vcpus = 1;
    3.12 +    int control_evtchn, store_evtchn;
    3.13 +    unsigned long store_mfn = 0;
    3.14  
    3.15 -    static char *kwd_list[] = { "dom", "control_evtchn", 
    3.16 -                                "image", "ramdisk", "cmdline", "flags", "vcpus",
    3.17 -                                NULL };
    3.18 +    static char *kwd_list[] = { "dom", "control_evtchn", "store_evtchn", 
    3.19 +                                "image", "ramdisk", "cmdline", "flags",
    3.20 +				"vcpus", NULL };
    3.21  
    3.22 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|ssii", kwd_list, 
    3.23 -                                      &dom, &control_evtchn, 
    3.24 -                                      &image, &ramdisk, &cmdline, &flags, &vcpus) )
    3.25 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiis|ssii", kwd_list,
    3.26 +                                      &dom, &control_evtchn, &store_evtchn,
    3.27 +                                      &image, &ramdisk, &cmdline, &flags,
    3.28 +                                      &vcpus) )
    3.29          return NULL;
    3.30  
    3.31      if ( xc_linux_build(xc->xc_handle, dom, image,
    3.32 -                        ramdisk, cmdline, control_evtchn, flags, vcpus) != 0 )
    3.33 +                        ramdisk, cmdline, control_evtchn, flags, vcpus,
    3.34 +                        store_evtchn, &store_mfn) != 0 )
    3.35          return PyErr_SetFromErrno(xc_error);
    3.36      
    3.37 -    Py_INCREF(zero);
    3.38 -    return zero;
    3.39 +    return Py_BuildValue("{s:i}", "store_mfn", store_mfn);
    3.40  }
    3.41  
    3.42  static PyObject *pyxc_plan9_build(PyObject *self,
     4.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Mon Jun 06 17:51:41 2005 +0000
     4.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Mon Jun 06 19:22:19 2005 +0000
     4.3 @@ -148,7 +148,7 @@ class XendDomainInfo:
     4.4      def _create(cls, uuid=None):
     4.5          """Create a vm object with a uuid.
     4.6  
     4.7 -        @param uuid uuid to use (generated if None)
     4.8 +        @param uuid uuid to use
     4.9          @return vm
    4.10          """
    4.11          if uuid is None:
    4.12 @@ -178,6 +178,7 @@ class XendDomainInfo:
    4.13  
    4.14          @param savedinfo: saved info from the domain DB
    4.15          @param info:      domain info from xc
    4.16 +        @param uuid:      uuid to use
    4.17          @type  info:      xc domain dict
    4.18          """
    4.19          vm = cls._create(uuid=uuid)
    4.20 @@ -216,6 +217,7 @@ class XendDomainInfo:
    4.21          """Create a domain and a VM object to do a restore.
    4.22  
    4.23          @param config:    domain configuration
    4.24 +        @param uuid:      uuid to use
    4.25          """
    4.26          vm = cls._create(uuid=uuid)
    4.27          dom = xc.domain_create()
    4.28 @@ -239,6 +241,8 @@ class XendDomainInfo:
    4.29          self.image = None
    4.30  
    4.31          self.channel = None
    4.32 +        self.store_channel = None
    4.33 +        self.store_mfs = None
    4.34          self.controllers = {}
    4.35          
    4.36          self.info = None
     5.1 --- a/tools/python/xen/xend/image.py	Mon Jun 06 17:51:41 2005 +0000
     5.2 +++ b/tools/python/xen/xend/image.py	Mon Jun 06 19:22:19 2005 +0000
     5.3 @@ -202,21 +202,22 @@ class LinuxImageHandler(ImageHandler):
     5.4      ostype = "linux"
     5.5  
     5.6      def buildDomain(self):
     5.7 -        #if self.vm.store_channel:
     5.8 -        #    store_evtchn = self.vm.store_channel.port2
     5.9 -        #else:
    5.10 -        #    store_evtchn = 0
    5.11 -        d  = xc.linux_build(dom            = self.vm.getDomain(),
    5.12 -                            image          = self.kernel,
    5.13 -                            control_evtchn = self.vm.channel.getRemotePort(),
    5.14 -                            #store_evtchn   = store_evtchn,
    5.15 -                            cmdline        = self.cmdline,
    5.16 -                            ramdisk        = self.ramdisk,
    5.17 -                            flags          = self.flags,
    5.18 -                            vcpus          = self.vm.vcpus)
    5.19 -        #if isinstance(d, dict):
    5.20 -        #    self.vm.store_mfn = d.get('store_mfn')
    5.21 -        return 0
    5.22 +        if self.vm.store_channel:
    5.23 +            store_evtchn = self.vm.store_channel.port2
    5.24 +        else:
    5.25 +            store_evtchn = 0
    5.26 +        ret = xc.linux_build(dom            = self.vm.getDomain(),
    5.27 +                             image          = self.kernel,
    5.28 +                             control_evtchn = self.vm.channel.getRemotePort(),
    5.29 +                             store_evtchn   = store_evtchn,
    5.30 +                             cmdline        = self.cmdline,
    5.31 +                             ramdisk        = self.ramdisk,
    5.32 +                             flags          = self.flags,
    5.33 +                             vcpus          = self.vm.vcpus)
    5.34 +        if isinstance(ret, dict):
    5.35 +            self.vm.store_mfn = ret.get('store_mfn')
    5.36 +            return 0
    5.37 +        return ret
    5.38  
    5.39  class Plan9ImageHandler(ImageHandler):
    5.40  
     6.1 --- a/xen/include/public/xen.h	Mon Jun 06 17:51:41 2005 +0000
     6.2 +++ b/xen/include/public/xen.h	Mon Jun 06 19:22:19 2005 +0000
     6.3 @@ -431,27 +431,30 @@ typedef struct shared_info_st
     6.4  
     6.5  #define MAX_CMDLINE 256
     6.6  typedef struct {
     6.7 -    /* THE FOLLOWING ARE FILLED IN BOTH ON INITIAL BOOT AND ON RESUME.     */
     6.8 -    memory_t nr_pages;        /*  0: Total pages allocated to this domain. */
     6.9 +    /* THE FOLLOWING ARE FILLED IN BOTH ON INITIAL BOOT AND ON RESUME.       */
    6.10 +    memory_t nr_pages;        /*  0: Total pages allocated to this domain.   */
    6.11      _MEMORY_PADDING(A);
    6.12 -    memory_t shared_info;     /*  8: MACHINE address of shared info struct.*/
    6.13 +    memory_t shared_info;     /*  8: MACHINE address of shared info struct.  */
    6.14      _MEMORY_PADDING(B);
    6.15 -    u32      flags;           /* 16: SIF_xxx flags.                        */
    6.16 +    u32      flags;           /* 16: SIF_xxx flags.                          */
    6.17      u16      domain_controller_evtchn; /* 20 */
    6.18      u16      __pad;
    6.19 -    /* THE FOLLOWING ARE ONLY FILLED IN ON INITIAL BOOT (NOT RESUME).      */
    6.20 -    memory_t pt_base;         /* 24: VIRTUAL address of page directory.    */
    6.21 +    /* THE FOLLOWING ARE ONLY FILLED IN ON INITIAL BOOT (NOT RESUME).        */
    6.22 +    memory_t pt_base;         /* 24: VIRTUAL address of page directory.      */
    6.23      _MEMORY_PADDING(C);
    6.24 -    memory_t nr_pt_frames;    /* 32: Number of bootstrap p.t. frames.      */
    6.25 +    memory_t nr_pt_frames;    /* 32: Number of bootstrap p.t. frames.        */
    6.26      _MEMORY_PADDING(D);
    6.27 -    memory_t mfn_list;        /* 40: VIRTUAL address of page-frame list.   */
    6.28 +    memory_t mfn_list;        /* 40: VIRTUAL address of page-frame list.     */
    6.29      _MEMORY_PADDING(E);
    6.30 -    memory_t mod_start;       /* 48: VIRTUAL address of pre-loaded module. */
    6.31 +    memory_t mod_start;       /* 48: VIRTUAL address of pre-loaded module.   */
    6.32      _MEMORY_PADDING(F);
    6.33 -    memory_t mod_len;         /* 56: Size (bytes) of pre-loaded module.    */
    6.34 +    memory_t mod_len;         /* 56: Size (bytes) of pre-loaded module.      */
    6.35      _MEMORY_PADDING(G);
    6.36      s8 cmd_line[MAX_CMDLINE]; /* 64 */
    6.37 -} PACKED start_info_t; /* 320 bytes */
    6.38 +    memory_t store_page;      /* 320: VIRTUAL address of store page.         */
    6.39 +    _MEMORY_PADDING(H);
    6.40 +    u16      store_evtchn;    /* 328: Event channel for store communication. */
    6.41 +} PACKED start_info_t; /* 332/336 bytes */
    6.42  
    6.43  /* These flags are passed in the 'flags' field of start_info_t. */
    6.44  #define SIF_PRIVILEGED    (1<<0)  /* Is the domain privileged? */