direct-io.hg

changeset 13077:d7150286ca7b

Fix the parsing of the image sexpr to use PV_kernel et al, rather than the old
kernel_ variables. This fixes reboot of PV guests.

Also, give XendConfig its own logger, to allow us to tweak the log level for
that module independently.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Mon Dec 18 00:07:55 2006 +0000 (2006-12-18)
parents a7da43e10ab3
children 469478194aef
files tools/python/xen/xend/XendConfig.py
line diff
     1.1 --- a/tools/python/xen/xend/XendConfig.py	Mon Dec 18 00:00:57 2006 +0000
     1.2 +++ b/tools/python/xen/xend/XendConfig.py	Mon Dec 18 00:07:55 2006 +0000
     1.3 @@ -15,6 +15,7 @@
     1.4  # Copyright (C) 2006 XenSource Ltd
     1.5  #============================================================================
     1.6  
     1.7 +import logging
     1.8  import re
     1.9  import time
    1.10  import types
    1.11 @@ -23,10 +24,13 @@ from xen.xend import sxp
    1.12  from xen.xend import uuid
    1.13  from xen.xend.XendError import VmError
    1.14  from xen.xend.XendDevices import XendDevices
    1.15 -from xen.xend.XendLogging import log
    1.16  from xen.xend.PrettyPrint import prettyprintstring
    1.17  from xen.xend.XendConstants import DOM_STATE_HALTED
    1.18  
    1.19 +log = logging.getLogger("xend.XendConfig")
    1.20 +log.setLevel(logging.WARN)
    1.21 +
    1.22 +
    1.23  """
    1.24  XendConfig API
    1.25  
    1.26 @@ -182,18 +186,18 @@ LEGACY_CFG_TYPES = {
    1.27      'shadow_memory': int,
    1.28      'maxmem':        int,
    1.29      'start_time':    float,
    1.30 -    'cpu_cap':         int,
    1.31 -    'cpu_weight':      int,
    1.32 +    'cpu_cap':       int,
    1.33 +    'cpu_weight':    int,
    1.34      'cpu_time':      float,
    1.35 -    'features':        str,
    1.36 -    'localtime':       int,
    1.37 -    'name':        str,
    1.38 -    'on_poweroff': str,
    1.39 -    'on_reboot':   str,
    1.40 -    'on_crash':    str,
    1.41 -    'on_xend_stop': str,
    1.42 +    'features':      str,
    1.43 +    'localtime':     int,
    1.44 +    'name':          str,
    1.45 +    'on_poweroff':   str,
    1.46 +    'on_reboot':     str,
    1.47 +    'on_crash':      str,
    1.48 +    'on_xend_stop':  str,
    1.49      'on_xend_start': str,
    1.50 -    'online_vcpus': int,
    1.51 +    'online_vcpus':  int,
    1.52  }
    1.53  
    1.54  # Values that should be stored in xenstore's /vm/<uuid> that is used
    1.55 @@ -578,6 +582,8 @@ class XendConfig(dict):
    1.56          """Read in an SXP Configuration object and
    1.57          populate at much of the Xen API with valid values.
    1.58          """
    1.59 +        log.debug('_sxp_to_xapi(%s)' % scrub_password(sxp_cfg))
    1.60 +
    1.61          cfg = self._parse_sxp(sxp_cfg)
    1.62  
    1.63          for key, typ in XENAPI_CFG_TYPES.items():
    1.64 @@ -648,6 +654,8 @@ class XendConfig(dict):
    1.65          the Xen API.
    1.66          """
    1.67  
    1.68 +        log.debug('_sxp_to_xapi_unsupported(%s)' % scrub_password(sxp_cfg))
    1.69 +
    1.70          # Parse and convert parameters used to configure
    1.71          # the image (as well as HVM images)
    1.72          image_sxp = sxp.child_value(sxp_cfg, 'image', [])
    1.73 @@ -761,6 +769,9 @@ class XendConfig(dict):
    1.74          @param xapi: Xen API VM Struct
    1.75          @type xapi: dict
    1.76          """
    1.77 +
    1.78 +        log.debug('update_with_xenapi_config: %s' % scrub_password(xapi))
    1.79 +
    1.80          for key, val in xapi.items():
    1.81              type_conv = XENAPI_CFG_TYPES.get(key)
    1.82              if type_conv is None:
    1.83 @@ -1059,12 +1070,12 @@ class XendConfig(dict):
    1.84          """Returns a backwards compatible image SXP expression that is
    1.85          used in xenstore's /vm/<uuid>/image value and xm list."""
    1.86          image = [self['image'].get('type', 'linux')]
    1.87 -        if self.has_key('kernel_kernel'):
    1.88 -            image.append(['kernel', self['kernel_kernel']])
    1.89 -        if self.has_key('kernel_initrd') and self['kernel_initrd']:
    1.90 -            image.append(['ramdisk', self['kernel_initrd']])
    1.91 -        if self.has_key('kernel_args') and self['kernel_args']:
    1.92 -            image.append(['args', self['kernel_args']])
    1.93 +        if self.has_key('PV_kernel'):
    1.94 +            image.append(['kernel', self['PV_kernel']])
    1.95 +        if self.has_key('PV_ramdisk') and self['PV_ramdisk']:
    1.96 +            image.append(['ramdisk', self['PV_ramdisk']])
    1.97 +        if self.has_key('PV_args') and self['PV_args']:
    1.98 +            image.append(['args', self['PV_args']])
    1.99  
   1.100          for arg, conv in LEGACY_IMAGE_CFG:
   1.101              if self['image'].has_key(arg):
   1.102 @@ -1084,8 +1095,10 @@ class XendConfig(dict):
   1.103          return image
   1.104  
   1.105      def update_with_image_sxp(self, image_sxp):
   1.106 -        # Convert Legacy "image" config to Xen API kernel_*
   1.107 +        # Convert Legacy "image" config to Xen API PV_*
   1.108          # configuration
   1.109 +        log.debug("update_with_image_sxp(%s)" % scrub_password(image_sxp))
   1.110 +
   1.111          self['PV_kernel'] = sxp.child_value(image_sxp, 'kernel','')
   1.112          self['PV_ramdisk'] = sxp.child_value(image_sxp, 'ramdisk','')
   1.113          kernel_args = sxp.child_value(image_sxp, 'args', '')