WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] Merge

# HG changeset patch
# User Tim Deegan <Tim.Deegan@xxxxxxxxxxxxx>
# Date 1172485383 0
# Node ID eefbc33a41abf36451ae6c102ba79e8312906909
# Parent  a70cf505aef97de5e5acab2bd196e0b6577e9440
# Parent  9f199e1fd9298b450b51fe4e7c0104121f15f11c
Merge
---
 tools/libxc/xc_dom_compat_linux.c       |   25 ++++++++++++++
 tools/libxc/xc_dom_ia64.c               |   10 +++++
 tools/libxc/xenguest.h                  |   14 ++++++++
 tools/python/xen/lowlevel/xc/xc.c       |   54 ++++++++++++++++++++++++++------
 tools/python/xen/xend/XendConfig.py     |   34 +++++++++++++++++++-
 tools/python/xen/xend/XendDomainInfo.py |   22 ++++++++++++-
 xen/arch/x86/domain_build.c             |    1 
 xen/common/libelf/libelf-dominfo.c      |    7 +++-
 xen/include/public/elfnote.h            |    5 ++
 xen/include/public/libelf.h             |   18 ++++++++++
 10 files changed, 177 insertions(+), 13 deletions(-)

diff -r a70cf505aef9 -r eefbc33a41ab tools/libxc/xc_dom_compat_linux.c
--- a/tools/libxc/xc_dom_compat_linux.c Mon Feb 26 10:22:38 2007 +0000
+++ b/tools/libxc/xc_dom_compat_linux.c Mon Feb 26 10:23:03 2007 +0000
@@ -122,6 +122,31 @@ int xc_linux_build(int xc_handle, uint32
     return rc;
 }
 
+int xc_dom_linux_build(int xc_handle,
+                       struct xc_dom_image *dom,
+                       uint32_t domid,
+                       unsigned int mem_mb,
+                       const char *image_name,
+                       const char *initrd_name,
+                       unsigned long flags,
+                       unsigned int store_evtchn,
+                       unsigned long *store_mfn,
+                       unsigned int console_evtchn, unsigned long *console_mfn)
+{
+    int rc;
+
+    if ( (rc = xc_dom_kernel_file(dom, image_name)) != 0 )
+        return rc;
+    if ( initrd_name && strlen(initrd_name) &&
+         ((rc = xc_dom_ramdisk_file(dom, initrd_name)) != 0) )
+        return rc;
+
+    return xc_linux_build_internal(dom, xc_handle, domid,
+                                   mem_mb, flags,
+                                   store_evtchn, store_mfn,
+                                   console_evtchn, console_mfn);
+}
+
 /*
  * Local variables:
  * mode: C
diff -r a70cf505aef9 -r eefbc33a41ab tools/libxc/xc_dom_ia64.c
--- a/tools/libxc/xc_dom_ia64.c Mon Feb 26 10:22:38 2007 +0000
+++ b/tools/libxc/xc_dom_ia64.c Mon Feb 26 10:23:03 2007 +0000
@@ -113,9 +113,19 @@ static struct xc_dom_arch xc_dom_arch = 
     .vcpu = vcpu_ia64,
 };
 
+static struct xc_dom_arch xc_dom_arch_ia64be = {
+    .guest_type = "xen-3.0-ia64be",
+    .page_shift = PAGE_SHIFT_IA64,
+    .alloc_magic_pages = alloc_magic_pages,
+    .start_info = start_info_ia64,
+    .shared_info = shared_info_ia64,
+    .vcpu = vcpu_ia64,
+};
+
 static void __init register_arch_hooks(void)
 {
     xc_dom_register_arch_hooks(&xc_dom_arch);
+    xc_dom_register_arch_hooks(&xc_dom_arch_ia64be);
 }
 
 /*
diff -r a70cf505aef9 -r eefbc33a41ab tools/libxc/xenguest.h
--- a/tools/libxc/xenguest.h    Mon Feb 26 10:22:38 2007 +0000
+++ b/tools/libxc/xenguest.h    Mon Feb 26 10:23:03 2007 +0000
@@ -91,6 +91,20 @@ int xc_linux_build(int xc_handle,
                    unsigned int console_evtchn,
                    unsigned long *console_mfn);
 
+/** The same interface, but the dom structure is managed by the caller */
+struct xc_dom_image;
+int xc_dom_linux_build(int xc_handle,
+                      struct xc_dom_image *dom,
+                      uint32_t domid,
+                      unsigned int mem_mb,
+                      const char *image_name,
+                      const char *ramdisk_name,
+                      unsigned long flags,
+                      unsigned int store_evtchn,
+                      unsigned long *store_mfn,
+                      unsigned int console_evtchn,
+                      unsigned long *console_mfn);
+
 /**
  * This function will create a domain for a paravirtualized Linux
  * using buffers for kernel and initrd
diff -r a70cf505aef9 -r eefbc33a41ab tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Mon Feb 26 10:22:38 2007 +0000
+++ b/tools/python/xen/lowlevel/xc/xc.c Mon Feb 26 10:23:03 2007 +0000
@@ -18,6 +18,8 @@
 #include <arpa/inet.h>
 
 #include "xenctrl.h"
+#include <xen/elfnote.h>
+#include "xc_dom.h"
 #include <xen/hvm/hvm_info_table.h>
 #include <xen/hvm/params.h>
 
@@ -371,13 +373,17 @@ static PyObject *pyxc_linux_build(XcObje
                                   PyObject *args,
                                   PyObject *kwds)
 {
-    uint32_t dom;
+    uint32_t domid;
+    struct xc_dom_image *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;
+    PyObject* elfnote_dict;
+    PyObject* elfnote = NULL;
+    int i;
 
     static char *kwd_list[] = { "domid", "store_evtchn", "memsize",
                                 "console_evtchn", "image",
@@ -386,22 +392,52 @@ static PyObject *pyxc_linux_build(XcObje
                                 "features", NULL };
 
     if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiis|ssis", kwd_list,
-                                      &dom, &store_evtchn, &mem_mb,
+                                      &domid, &store_evtchn, &mem_mb,
                                       &console_evtchn, &image,
                                       /* optional */
                                       &ramdisk, &cmdline, &flags,
                                       &features) )
         return NULL;
 
-    if ( 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();
+    xc_dom_loginit();
+    if (!(dom = xc_dom_allocate(cmdline, features)))
+       return pyxc_error_to_exception();
+
+    if ( xc_dom_linux_build(self->xc_handle, dom, domid, mem_mb, image,
+                           ramdisk, flags, store_evtchn, &store_mfn,
+                           console_evtchn, &console_mfn) != 0 ) {
+       goto out;
     }
-    return Py_BuildValue("{s:i,s:i}", 
+
+    if (!(elfnote_dict = PyDict_New()))
+       goto out;
+    for (i = 0; i < XEN_ELFNOTE_MAX; i++) {
+       switch (dom->parms.elf_notes[i].type) {
+       case XEN_ENT_NONE:
+           continue;
+       case XEN_ENT_LONG:
+           elfnote = Py_BuildValue("k", dom->parms.elf_notes[i].data.num);
+           break;
+       case XEN_ENT_STR:
+           elfnote = Py_BuildValue("s", dom->parms.elf_notes[i].data.str);
+           break;
+       }
+       PyDict_SetItemString(elfnote_dict,
+                            dom->parms.elf_notes[i].name,
+                            elfnote);
+       Py_DECREF(elfnote);
+    }
+
+    xc_dom_release(dom);
+
+    return Py_BuildValue("{s:i,s:i,s:N}", 
                          "store_mfn", store_mfn,
-                         "console_mfn", console_mfn);
+                         "console_mfn", console_mfn,
+                        "notes", elfnote_dict);
+
+  out:
+    xc_dom_release(dom);
+    return pyxc_error_to_exception();
 }
 
 static PyObject *pyxc_hvm_build(XcObject *self,
diff -r a70cf505aef9 -r eefbc33a41ab tools/python/xen/xend/XendConfig.py
--- a/tools/python/xen/xend/XendConfig.py       Mon Feb 26 10:22:38 2007 +0000
+++ b/tools/python/xen/xend/XendConfig.py       Mon Feb 26 10:23:03 2007 +0000
@@ -729,6 +729,10 @@ class XendConfig(dict):
                 image['hvm'] = image_hvm
                 image['hvm']['devices'] = image_hvm_devices
 
+            notes = sxp.children(image_sxp, 'notes')
+            if notes:
+                image['notes'] = self.notes_from_sxp(notes[0])
+
             self['image'] = image
 
             for apikey, imgkey in XENAPI_HVM_CFG.items():
@@ -1363,6 +1367,9 @@ class XendConfig(dict):
                             
                     image.append([arg, val])
 
+        if 'notes' in self['image']:
+            image.append(self.notes_sxp(self['image']['notes']))
+
         return image
 
     def update_with_image_sxp(self, image_sxp, bootloader = False):
@@ -1420,6 +1427,10 @@ class XendConfig(dict):
             image['hvm'] = image_hvm
             image['hvm']['devices'] = image_hvm_devices
 
+        notes = sxp.children(image_sxp, 'notes')
+        if notes:
+            image['notes'] = self.notes_from_sxp(notes[0])
+
         self['image'] = image
 
         for apikey, imgkey in XENAPI_HVM_CFG.items():
@@ -1432,7 +1443,28 @@ class XendConfig(dict):
                     self[apikey] = val
         self._hvm_boot_params_from_sxp(image_sxp)
 
-
+    def set_notes(self, notes):
+        'Add parsed elfnotes to image'
+        self['image']['notes'] = notes
+
+    def get_notes(self):
+        try:
+            return self['image']['notes'] or {}
+        except KeyError:
+            return {}
+
+    def notes_from_sxp(self, nsxp):
+        notes = {}
+        for note in sxp.children(nsxp):
+            notes[note[0]] = note[1]
+        return notes
+
+    def notes_sxp(self, notes):
+        nsxp = ['notes']
+        for k, v in notes.iteritems():
+            nsxp.append([k, str(v)])
+        return nsxp
+        
     def _hvm_boot_params_from_sxp(self, image_sxp):
         boot = sxp.child_value(image_sxp, 'boot', None)
         if boot is not None:
diff -r a70cf505aef9 -r eefbc33a41ab tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Mon Feb 26 10:22:38 2007 +0000
+++ b/tools/python/xen/xend/XendDomainInfo.py   Mon Feb 26 10:23:03 2007 +0000
@@ -302,6 +302,8 @@ class XendDomainInfo:
     @type store_mfn: int
     @ivar console_mfn: xenconsoled mfn
     @type console_mfn: int
+    @ivar notes: OS image notes
+    @type notes: dictionary
     @ivar vmWatch: reference to a watch on the xenstored vmpath
     @type vmWatch: xen.xend.xenstore.xswatch
     @ivar shutdownWatch: reference to watch on the xenstored domain shutdown
@@ -776,12 +778,28 @@ class XendDomainInfo:
 
         def f(n, v):
             if v is not None:
-                to_store[n] = str(v)
+                if type(v) == bool:
+                    to_store[n] = v and "1" or "0"
+                else:
+                    to_store[n] = str(v)
 
         f('console/port',     self.console_port)
         f('console/ring-ref', self.console_mfn)
         f('store/port',       self.store_port)
         f('store/ring-ref',   self.store_mfn)
+
+        # elfnotes
+        for n, v in self.info.get_notes().iteritems():
+            n = n.lower().replace('_', '-')
+            if n == 'features':
+                for v in v.split('|'):
+                    v = v.replace('_', '-')
+                    if v.startswith('!'):
+                        f('image/%s/%s' % (n, v[1:]), False)
+                    else:
+                        f('image/%s/%s' % (n, v), True)
+            else:
+                f('image/%s' % n, v)
 
         to_store.update(self._vcpuDomDetails())
 
@@ -1462,6 +1480,8 @@ class XendDomainInfo:
             self.store_mfn = channel_details['store_mfn']
             if 'console_mfn' in channel_details:
                 self.console_mfn = channel_details['console_mfn']
+            if 'notes' in channel_details:
+                self.info.set_notes(channel_details['notes'])
 
             self._introduceDomain()
 
diff -r a70cf505aef9 -r eefbc33a41ab xen/arch/x86/domain_build.c
--- a/xen/arch/x86/domain_build.c       Mon Feb 26 10:22:38 2007 +0000
+++ b/xen/arch/x86/domain_build.c       Mon Feb 26 10:23:03 2007 +0000
@@ -28,6 +28,7 @@
 #include <asm/paging.h>
 
 #include <public/version.h>
+#include <public/elfnote.h>
 #include <public/libelf.h>
 
 extern unsigned long initial_images_nrpages(void);
diff -r a70cf505aef9 -r eefbc33a41ab xen/common/libelf/libelf-dominfo.c
--- a/xen/common/libelf/libelf-dominfo.c        Mon Feb 26 10:22:38 2007 +0000
+++ b/xen/common/libelf/libelf-dominfo.c        Mon Feb 26 10:23:03 2007 +0000
@@ -119,13 +119,18 @@ int elf_xen_parse_note(struct elf_binary
         str = elf_note_desc(elf, note);
         elf_msg(elf, "%s: %s = \"%s\"\n", __FUNCTION__,
                 note_desc[type].name, str);
+        parms->elf_notes[type].type = XEN_ENT_STR;
+        parms->elf_notes[type].data.str = str;
     }
     else
     {
         val = elf_note_numeric(elf, note);
         elf_msg(elf, "%s: %s = 0x%" PRIx64 "\n", __FUNCTION__,
                 note_desc[type].name, val);
-    }
+        parms->elf_notes[type].type = XEN_ENT_LONG;
+        parms->elf_notes[type].data.num = val;
+    }
+    parms->elf_notes[type].name = note_desc[type].name;
 
     switch ( type )
     {
diff -r a70cf505aef9 -r eefbc33a41ab xen/include/public/elfnote.h
--- a/xen/include/public/elfnote.h      Mon Feb 26 10:22:38 2007 +0000
+++ b/xen/include/public/elfnote.h      Mon Feb 26 10:23:03 2007 +0000
@@ -157,6 +157,11 @@
 #define XEN_ELFNOTE_L1_MFN_VALID  13
 
 /*
+ * The number of the highest elfnote defined.
+ */
+#define XEN_ELFNOTE_MAX XEN_ELFNOTE_L1_MFN_VALID
+
+/*
  * System information exported through crash notes.
  *
  * The kexec / kdump code will create one XEN_ELFNOTE_CRASH_INFO 
diff -r a70cf505aef9 -r eefbc33a41ab xen/include/public/libelf.h
--- a/xen/include/public/libelf.h       Mon Feb 26 10:22:38 2007 +0000
+++ b/xen/include/public/libelf.h       Mon Feb 26 10:23:03 2007 +0000
@@ -174,12 +174,28 @@ int elf_reloc(struct elf_binary *elf);
 
 #define UNSET_ADDR          ((uint64_t)-1)
 
+enum xen_elfnote_type {
+    XEN_ENT_NONE = 0,
+    XEN_ENT_LONG = 1,
+    XEN_ENT_STR  = 2
+};
+
+struct xen_elfnote {
+    enum xen_elfnote_type type;
+    const char *name;
+    union {
+       const char *str;
+       uint64_t num;
+    } data;
+};
+
 struct elf_dom_parms {
     /* raw */
     const char *guest_info;
     const void *elf_note_start;
     const void *elf_note_end;
-
+    struct xen_elfnote elf_notes[XEN_ELFNOTE_MAX + 1];
+  
     /* parsed */
     char guest_os[16];
     char guest_ver[16];

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>