ia64/xen-unstable

changeset 14131:64d80037e524

Save elfnotes in VM sxpr under image/notes, and load them on restore.
Signed-off-by: Brendan Cully <brendan@cs.ubc.ca>
author kfraser@localhost.localdomain
date Mon Feb 26 09:59:56 2007 +0000 (2007-02-26)
parents a20ec270998b
children 9f199e1fd929
files tools/python/xen/xend/XendConfig.py tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendConfig.py	Mon Feb 26 09:59:33 2007 +0000
     1.2 +++ b/tools/python/xen/xend/XendConfig.py	Mon Feb 26 09:59:56 2007 +0000
     1.3 @@ -729,6 +729,10 @@ class XendConfig(dict):
     1.4                  image['hvm'] = image_hvm
     1.5                  image['hvm']['devices'] = image_hvm_devices
     1.6  
     1.7 +            notes = sxp.children(image_sxp, 'notes')
     1.8 +            if notes:
     1.9 +                image['notes'] = self.notes_from_sxp(notes[0])
    1.10 +
    1.11              self['image'] = image
    1.12  
    1.13              for apikey, imgkey in XENAPI_HVM_CFG.items():
    1.14 @@ -1363,6 +1367,9 @@ class XendConfig(dict):
    1.15                              
    1.16                      image.append([arg, val])
    1.17  
    1.18 +        if 'notes' in self['image']:
    1.19 +            image.append(self.notes_sxp(self['image']['notes']))
    1.20 +
    1.21          return image
    1.22  
    1.23      def update_with_image_sxp(self, image_sxp, bootloader = False):
    1.24 @@ -1420,6 +1427,10 @@ class XendConfig(dict):
    1.25              image['hvm'] = image_hvm
    1.26              image['hvm']['devices'] = image_hvm_devices
    1.27  
    1.28 +        notes = sxp.children(image_sxp, 'notes')
    1.29 +        if notes:
    1.30 +            image['notes'] = self.notes_from_sxp(notes[0])
    1.31 +
    1.32          self['image'] = image
    1.33  
    1.34          for apikey, imgkey in XENAPI_HVM_CFG.items():
    1.35 @@ -1432,7 +1443,28 @@ class XendConfig(dict):
    1.36                      self[apikey] = val
    1.37          self._hvm_boot_params_from_sxp(image_sxp)
    1.38  
    1.39 +    def set_notes(self, notes):
    1.40 +        'Add parsed elfnotes to image'
    1.41 +        self['image']['notes'] = notes
    1.42  
    1.43 +    def get_notes(self):
    1.44 +        try:
    1.45 +            return self['image']['notes'] or {}
    1.46 +        except KeyError:
    1.47 +            return {}
    1.48 +
    1.49 +    def notes_from_sxp(self, nsxp):
    1.50 +        notes = {}
    1.51 +        for note in sxp.children(nsxp):
    1.52 +            notes[note[0]] = note[1]
    1.53 +        return notes
    1.54 +
    1.55 +    def notes_sxp(self, notes):
    1.56 +        nsxp = ['notes']
    1.57 +        for k, v in notes.iteritems():
    1.58 +            nsxp.append([k, str(v)])
    1.59 +        return nsxp
    1.60 +        
    1.61      def _hvm_boot_params_from_sxp(self, image_sxp):
    1.62          boot = sxp.child_value(image_sxp, 'boot', None)
    1.63          if boot is not None:
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Mon Feb 26 09:59:33 2007 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Mon Feb 26 09:59:56 2007 +0000
     2.3 @@ -356,7 +356,6 @@ class XendDomainInfo:
     2.4          self.store_mfn = None
     2.5          self.console_port = None
     2.6          self.console_mfn = None
     2.7 -        self.notes = {}
     2.8  
     2.9          self.vmWatch = None
    2.10          self.shutdownWatch = None
    2.11 @@ -790,7 +789,7 @@ class XendDomainInfo:
    2.12          f('store/ring-ref',   self.store_mfn)
    2.13  
    2.14          # elfnotes
    2.15 -        for n, v in self.notes.iteritems():
    2.16 +        for n, v in self.info.get_notes().iteritems():
    2.17              n = n.lower().replace('_', '-')
    2.18              if n == 'features':
    2.19                  for v in v.split('|'):
    2.20 @@ -1482,7 +1481,7 @@ class XendDomainInfo:
    2.21              if 'console_mfn' in channel_details:
    2.22                  self.console_mfn = channel_details['console_mfn']
    2.23              if 'notes' in channel_details:
    2.24 -                self.notes = channel_details['notes']
    2.25 +                self.info.set_notes(channel_details['notes'])
    2.26  
    2.27              self._introduceDomain()
    2.28