ia64/xen-unstable

changeset 14134:eefbc33a41ab

Merge
author Tim Deegan <Tim.Deegan@xensource.com>
date Mon Feb 26 10:23:03 2007 +0000 (2007-02-26)
parents a70cf505aef9 9f199e1fd929
children 047748faa4aa
files
line diff
     1.1 --- a/tools/libxc/xc_dom_compat_linux.c	Mon Feb 26 10:22:38 2007 +0000
     1.2 +++ b/tools/libxc/xc_dom_compat_linux.c	Mon Feb 26 10:23:03 2007 +0000
     1.3 @@ -122,6 +122,31 @@ int xc_linux_build(int xc_handle, uint32
     1.4      return rc;
     1.5  }
     1.6  
     1.7 +int xc_dom_linux_build(int xc_handle,
     1.8 +                       struct xc_dom_image *dom,
     1.9 +                       uint32_t domid,
    1.10 +                       unsigned int mem_mb,
    1.11 +                       const char *image_name,
    1.12 +                       const char *initrd_name,
    1.13 +                       unsigned long flags,
    1.14 +                       unsigned int store_evtchn,
    1.15 +                       unsigned long *store_mfn,
    1.16 +                       unsigned int console_evtchn, unsigned long *console_mfn)
    1.17 +{
    1.18 +    int rc;
    1.19 +
    1.20 +    if ( (rc = xc_dom_kernel_file(dom, image_name)) != 0 )
    1.21 +        return rc;
    1.22 +    if ( initrd_name && strlen(initrd_name) &&
    1.23 +         ((rc = xc_dom_ramdisk_file(dom, initrd_name)) != 0) )
    1.24 +        return rc;
    1.25 +
    1.26 +    return xc_linux_build_internal(dom, xc_handle, domid,
    1.27 +                                   mem_mb, flags,
    1.28 +                                   store_evtchn, store_mfn,
    1.29 +                                   console_evtchn, console_mfn);
    1.30 +}
    1.31 +
    1.32  /*
    1.33   * Local variables:
    1.34   * mode: C
     2.1 --- a/tools/libxc/xc_dom_ia64.c	Mon Feb 26 10:22:38 2007 +0000
     2.2 +++ b/tools/libxc/xc_dom_ia64.c	Mon Feb 26 10:23:03 2007 +0000
     2.3 @@ -113,9 +113,19 @@ static struct xc_dom_arch xc_dom_arch = 
     2.4      .vcpu = vcpu_ia64,
     2.5  };
     2.6  
     2.7 +static struct xc_dom_arch xc_dom_arch_ia64be = {
     2.8 +    .guest_type = "xen-3.0-ia64be",
     2.9 +    .page_shift = PAGE_SHIFT_IA64,
    2.10 +    .alloc_magic_pages = alloc_magic_pages,
    2.11 +    .start_info = start_info_ia64,
    2.12 +    .shared_info = shared_info_ia64,
    2.13 +    .vcpu = vcpu_ia64,
    2.14 +};
    2.15 +
    2.16  static void __init register_arch_hooks(void)
    2.17  {
    2.18      xc_dom_register_arch_hooks(&xc_dom_arch);
    2.19 +    xc_dom_register_arch_hooks(&xc_dom_arch_ia64be);
    2.20  }
    2.21  
    2.22  /*
     3.1 --- a/tools/libxc/xenguest.h	Mon Feb 26 10:22:38 2007 +0000
     3.2 +++ b/tools/libxc/xenguest.h	Mon Feb 26 10:23:03 2007 +0000
     3.3 @@ -91,6 +91,20 @@ int xc_linux_build(int xc_handle,
     3.4                     unsigned int console_evtchn,
     3.5                     unsigned long *console_mfn);
     3.6  
     3.7 +/** The same interface, but the dom structure is managed by the caller */
     3.8 +struct xc_dom_image;
     3.9 +int xc_dom_linux_build(int xc_handle,
    3.10 +		       struct xc_dom_image *dom,
    3.11 +		       uint32_t domid,
    3.12 +		       unsigned int mem_mb,
    3.13 +		       const char *image_name,
    3.14 +		       const char *ramdisk_name,
    3.15 +		       unsigned long flags,
    3.16 +		       unsigned int store_evtchn,
    3.17 +		       unsigned long *store_mfn,
    3.18 +		       unsigned int console_evtchn,
    3.19 +		       unsigned long *console_mfn);
    3.20 +
    3.21  /**
    3.22   * This function will create a domain for a paravirtualized Linux
    3.23   * using buffers for kernel and initrd
     4.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Mon Feb 26 10:22:38 2007 +0000
     4.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Mon Feb 26 10:23:03 2007 +0000
     4.3 @@ -18,6 +18,8 @@
     4.4  #include <arpa/inet.h>
     4.5  
     4.6  #include "xenctrl.h"
     4.7 +#include <xen/elfnote.h>
     4.8 +#include "xc_dom.h"
     4.9  #include <xen/hvm/hvm_info_table.h>
    4.10  #include <xen/hvm/params.h>
    4.11  
    4.12 @@ -371,13 +373,17 @@ static PyObject *pyxc_linux_build(XcObje
    4.13                                    PyObject *args,
    4.14                                    PyObject *kwds)
    4.15  {
    4.16 -    uint32_t dom;
    4.17 +    uint32_t domid;
    4.18 +    struct xc_dom_image *dom;
    4.19      char *image, *ramdisk = NULL, *cmdline = "", *features = NULL;
    4.20      int flags = 0;
    4.21      int store_evtchn, console_evtchn;
    4.22      unsigned int mem_mb;
    4.23      unsigned long store_mfn = 0;
    4.24      unsigned long console_mfn = 0;
    4.25 +    PyObject* elfnote_dict;
    4.26 +    PyObject* elfnote = NULL;
    4.27 +    int i;
    4.28  
    4.29      static char *kwd_list[] = { "domid", "store_evtchn", "memsize",
    4.30                                  "console_evtchn", "image",
    4.31 @@ -386,22 +392,52 @@ static PyObject *pyxc_linux_build(XcObje
    4.32                                  "features", NULL };
    4.33  
    4.34      if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiis|ssis", kwd_list,
    4.35 -                                      &dom, &store_evtchn, &mem_mb,
    4.36 +                                      &domid, &store_evtchn, &mem_mb,
    4.37                                        &console_evtchn, &image,
    4.38                                        /* optional */
    4.39                                        &ramdisk, &cmdline, &flags,
    4.40                                        &features) )
    4.41          return NULL;
    4.42  
    4.43 -    if ( xc_linux_build(self->xc_handle, dom, mem_mb, image,
    4.44 -                        ramdisk, cmdline, features, flags,
    4.45 -                        store_evtchn, &store_mfn,
    4.46 -                        console_evtchn, &console_mfn) != 0 ) {
    4.47 -        return pyxc_error_to_exception();
    4.48 +    xc_dom_loginit();
    4.49 +    if (!(dom = xc_dom_allocate(cmdline, features)))
    4.50 +	return pyxc_error_to_exception();
    4.51 +
    4.52 +    if ( xc_dom_linux_build(self->xc_handle, dom, domid, mem_mb, image,
    4.53 +			    ramdisk, flags, store_evtchn, &store_mfn,
    4.54 +			    console_evtchn, &console_mfn) != 0 ) {
    4.55 +	goto out;
    4.56      }
    4.57 -    return Py_BuildValue("{s:i,s:i}", 
    4.58 +
    4.59 +    if (!(elfnote_dict = PyDict_New()))
    4.60 +	goto out;
    4.61 +    for (i = 0; i < XEN_ELFNOTE_MAX; i++) {
    4.62 +	switch (dom->parms.elf_notes[i].type) {
    4.63 +	case XEN_ENT_NONE:
    4.64 +	    continue;
    4.65 +	case XEN_ENT_LONG:
    4.66 +	    elfnote = Py_BuildValue("k", dom->parms.elf_notes[i].data.num);
    4.67 +	    break;
    4.68 +	case XEN_ENT_STR:
    4.69 +	    elfnote = Py_BuildValue("s", dom->parms.elf_notes[i].data.str);
    4.70 +	    break;
    4.71 +	}
    4.72 +	PyDict_SetItemString(elfnote_dict,
    4.73 +			     dom->parms.elf_notes[i].name,
    4.74 +			     elfnote);
    4.75 +	Py_DECREF(elfnote);
    4.76 +    }
    4.77 +
    4.78 +    xc_dom_release(dom);
    4.79 +
    4.80 +    return Py_BuildValue("{s:i,s:i,s:N}", 
    4.81                           "store_mfn", store_mfn,
    4.82 -                         "console_mfn", console_mfn);
    4.83 +                         "console_mfn", console_mfn,
    4.84 +			 "notes", elfnote_dict);
    4.85 +
    4.86 +  out:
    4.87 +    xc_dom_release(dom);
    4.88 +    return pyxc_error_to_exception();
    4.89  }
    4.90  
    4.91  static PyObject *pyxc_hvm_build(XcObject *self,
     5.1 --- a/tools/python/xen/xend/XendConfig.py	Mon Feb 26 10:22:38 2007 +0000
     5.2 +++ b/tools/python/xen/xend/XendConfig.py	Mon Feb 26 10:23:03 2007 +0000
     5.3 @@ -729,6 +729,10 @@ class XendConfig(dict):
     5.4                  image['hvm'] = image_hvm
     5.5                  image['hvm']['devices'] = image_hvm_devices
     5.6  
     5.7 +            notes = sxp.children(image_sxp, 'notes')
     5.8 +            if notes:
     5.9 +                image['notes'] = self.notes_from_sxp(notes[0])
    5.10 +
    5.11              self['image'] = image
    5.12  
    5.13              for apikey, imgkey in XENAPI_HVM_CFG.items():
    5.14 @@ -1363,6 +1367,9 @@ class XendConfig(dict):
    5.15                              
    5.16                      image.append([arg, val])
    5.17  
    5.18 +        if 'notes' in self['image']:
    5.19 +            image.append(self.notes_sxp(self['image']['notes']))
    5.20 +
    5.21          return image
    5.22  
    5.23      def update_with_image_sxp(self, image_sxp, bootloader = False):
    5.24 @@ -1420,6 +1427,10 @@ class XendConfig(dict):
    5.25              image['hvm'] = image_hvm
    5.26              image['hvm']['devices'] = image_hvm_devices
    5.27  
    5.28 +        notes = sxp.children(image_sxp, 'notes')
    5.29 +        if notes:
    5.30 +            image['notes'] = self.notes_from_sxp(notes[0])
    5.31 +
    5.32          self['image'] = image
    5.33  
    5.34          for apikey, imgkey in XENAPI_HVM_CFG.items():
    5.35 @@ -1432,7 +1443,28 @@ class XendConfig(dict):
    5.36                      self[apikey] = val
    5.37          self._hvm_boot_params_from_sxp(image_sxp)
    5.38  
    5.39 +    def set_notes(self, notes):
    5.40 +        'Add parsed elfnotes to image'
    5.41 +        self['image']['notes'] = notes
    5.42  
    5.43 +    def get_notes(self):
    5.44 +        try:
    5.45 +            return self['image']['notes'] or {}
    5.46 +        except KeyError:
    5.47 +            return {}
    5.48 +
    5.49 +    def notes_from_sxp(self, nsxp):
    5.50 +        notes = {}
    5.51 +        for note in sxp.children(nsxp):
    5.52 +            notes[note[0]] = note[1]
    5.53 +        return notes
    5.54 +
    5.55 +    def notes_sxp(self, notes):
    5.56 +        nsxp = ['notes']
    5.57 +        for k, v in notes.iteritems():
    5.58 +            nsxp.append([k, str(v)])
    5.59 +        return nsxp
    5.60 +        
    5.61      def _hvm_boot_params_from_sxp(self, image_sxp):
    5.62          boot = sxp.child_value(image_sxp, 'boot', None)
    5.63          if boot is not None:
     6.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Mon Feb 26 10:22:38 2007 +0000
     6.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Mon Feb 26 10:23:03 2007 +0000
     6.3 @@ -302,6 +302,8 @@ class XendDomainInfo:
     6.4      @type store_mfn: int
     6.5      @ivar console_mfn: xenconsoled mfn
     6.6      @type console_mfn: int
     6.7 +    @ivar notes: OS image notes
     6.8 +    @type notes: dictionary
     6.9      @ivar vmWatch: reference to a watch on the xenstored vmpath
    6.10      @type vmWatch: xen.xend.xenstore.xswatch
    6.11      @ivar shutdownWatch: reference to watch on the xenstored domain shutdown
    6.12 @@ -776,13 +778,29 @@ class XendDomainInfo:
    6.13  
    6.14          def f(n, v):
    6.15              if v is not None:
    6.16 -                to_store[n] = str(v)
    6.17 +                if type(v) == bool:
    6.18 +                    to_store[n] = v and "1" or "0"
    6.19 +                else:
    6.20 +                    to_store[n] = str(v)
    6.21  
    6.22          f('console/port',     self.console_port)
    6.23          f('console/ring-ref', self.console_mfn)
    6.24          f('store/port',       self.store_port)
    6.25          f('store/ring-ref',   self.store_mfn)
    6.26  
    6.27 +        # elfnotes
    6.28 +        for n, v in self.info.get_notes().iteritems():
    6.29 +            n = n.lower().replace('_', '-')
    6.30 +            if n == 'features':
    6.31 +                for v in v.split('|'):
    6.32 +                    v = v.replace('_', '-')
    6.33 +                    if v.startswith('!'):
    6.34 +                        f('image/%s/%s' % (n, v[1:]), False)
    6.35 +                    else:
    6.36 +                        f('image/%s/%s' % (n, v), True)
    6.37 +            else:
    6.38 +                f('image/%s' % n, v)
    6.39 +
    6.40          to_store.update(self._vcpuDomDetails())
    6.41  
    6.42          log.debug("Storing domain details: %s", scrub_password(to_store))
    6.43 @@ -1462,6 +1480,8 @@ class XendDomainInfo:
    6.44              self.store_mfn = channel_details['store_mfn']
    6.45              if 'console_mfn' in channel_details:
    6.46                  self.console_mfn = channel_details['console_mfn']
    6.47 +            if 'notes' in channel_details:
    6.48 +                self.info.set_notes(channel_details['notes'])
    6.49  
    6.50              self._introduceDomain()
    6.51  
     7.1 --- a/xen/arch/x86/domain_build.c	Mon Feb 26 10:22:38 2007 +0000
     7.2 +++ b/xen/arch/x86/domain_build.c	Mon Feb 26 10:23:03 2007 +0000
     7.3 @@ -28,6 +28,7 @@
     7.4  #include <asm/paging.h>
     7.5  
     7.6  #include <public/version.h>
     7.7 +#include <public/elfnote.h>
     7.8  #include <public/libelf.h>
     7.9  
    7.10  extern unsigned long initial_images_nrpages(void);
     8.1 --- a/xen/common/libelf/libelf-dominfo.c	Mon Feb 26 10:22:38 2007 +0000
     8.2 +++ b/xen/common/libelf/libelf-dominfo.c	Mon Feb 26 10:23:03 2007 +0000
     8.3 @@ -119,13 +119,18 @@ int elf_xen_parse_note(struct elf_binary
     8.4          str = elf_note_desc(elf, note);
     8.5          elf_msg(elf, "%s: %s = \"%s\"\n", __FUNCTION__,
     8.6                  note_desc[type].name, str);
     8.7 +        parms->elf_notes[type].type = XEN_ENT_STR;
     8.8 +        parms->elf_notes[type].data.str = str;
     8.9      }
    8.10      else
    8.11      {
    8.12          val = elf_note_numeric(elf, note);
    8.13          elf_msg(elf, "%s: %s = 0x%" PRIx64 "\n", __FUNCTION__,
    8.14                  note_desc[type].name, val);
    8.15 +        parms->elf_notes[type].type = XEN_ENT_LONG;
    8.16 +        parms->elf_notes[type].data.num = val;
    8.17      }
    8.18 +    parms->elf_notes[type].name = note_desc[type].name;
    8.19  
    8.20      switch ( type )
    8.21      {
     9.1 --- a/xen/include/public/elfnote.h	Mon Feb 26 10:22:38 2007 +0000
     9.2 +++ b/xen/include/public/elfnote.h	Mon Feb 26 10:23:03 2007 +0000
     9.3 @@ -157,6 +157,11 @@
     9.4  #define XEN_ELFNOTE_L1_MFN_VALID  13
     9.5  
     9.6  /*
     9.7 + * The number of the highest elfnote defined.
     9.8 + */
     9.9 +#define XEN_ELFNOTE_MAX XEN_ELFNOTE_L1_MFN_VALID
    9.10 +
    9.11 +/*
    9.12   * System information exported through crash notes.
    9.13   *
    9.14   * The kexec / kdump code will create one XEN_ELFNOTE_CRASH_INFO 
    10.1 --- a/xen/include/public/libelf.h	Mon Feb 26 10:22:38 2007 +0000
    10.2 +++ b/xen/include/public/libelf.h	Mon Feb 26 10:23:03 2007 +0000
    10.3 @@ -174,12 +174,28 @@ int elf_reloc(struct elf_binary *elf);
    10.4  
    10.5  #define UNSET_ADDR          ((uint64_t)-1)
    10.6  
    10.7 +enum xen_elfnote_type {
    10.8 +    XEN_ENT_NONE = 0,
    10.9 +    XEN_ENT_LONG = 1,
   10.10 +    XEN_ENT_STR  = 2
   10.11 +};
   10.12 +
   10.13 +struct xen_elfnote {
   10.14 +    enum xen_elfnote_type type;
   10.15 +    const char *name;
   10.16 +    union {
   10.17 +	const char *str;
   10.18 +	uint64_t num;
   10.19 +    } data;
   10.20 +};
   10.21 +
   10.22  struct elf_dom_parms {
   10.23      /* raw */
   10.24      const char *guest_info;
   10.25      const void *elf_note_start;
   10.26      const void *elf_note_end;
   10.27 -
   10.28 +    struct xen_elfnote elf_notes[XEN_ELFNOTE_MAX + 1];
   10.29 +  
   10.30      /* parsed */
   10.31      char guest_os[16];
   10.32      char guest_ver[16];