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] [XEND] Make SXP parsing re-use device_add

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [XEND] Make SXP parsing re-use device_add in XendConfig
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 08 Dec 2006 13:20:35 +0000
Delivery-date: Fri, 08 Dec 2006 05:22:58 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Alastair Tse <atse@xxxxxxxxxxxxx>
# Node ID 93314655b16f62809c83644eed84592ebe4e8001
# Parent  dcca88fc849cc5ca56f178bce61cf3abe431e83f
[XEND] Make SXP parsing re-use device_add in XendConfig

This will fix the IP address configuration problem for vifs.

Signed-off-by: Alastair Tse <atse@xxxxxxxxxxxxx>
---
 tools/python/xen/xend/XendConfig.py |   38 ++++++++++++++++++++++--------------
 1 files changed, 24 insertions(+), 14 deletions(-)

diff -r dcca88fc849c -r 93314655b16f tools/python/xen/xend/XendConfig.py
--- a/tools/python/xen/xend/XendConfig.py       Thu Dec 07 14:38:16 2006 +0000
+++ b/tools/python/xen/xend/XendConfig.py       Thu Dec 07 14:40:13 2006 +0000
@@ -509,14 +509,8 @@ class XendConfig(dict):
                 
                 log.debug("XendConfig: reading device: %s" % pci_devs)
             else:
-                for opt, val in config[1:]:
-                    dev_info[opt] = val
+                self.device_add(dev_type, cfg_sxp = config, target = cfg)
                 log.debug("XendConfig: reading device: %s" % 
scrub_password(dev_info))
-                # create uuid if it doesn't
-                dev_uuid = dev_info.get('uuid', uuid.createString())
-                dev_info['uuid'] = dev_uuid
-                cfg['devices'][dev_uuid] = (dev_type, dev_info)
-
 
         # Extract missing data from configuration entries
         image_sxp = sxp.child_value(sxp_cfg, 'image', [])
@@ -867,7 +861,8 @@ class XendConfig(dict):
 
         return sxpr    
     
-    def device_add(self, dev_type, cfg_sxp = None, cfg_xenapi = None):
+    def device_add(self, dev_type, cfg_sxp = None, cfg_xenapi = None,
+                   target = None):
         """Add a device configuration in SXP format or XenAPI struct format.
 
         For SXP, it could be either:
@@ -882,9 +877,14 @@ class XendConfig(dict):
         @param cfg_sxp: SXP configuration object
         @type cfg_xenapi: dict
         @param cfg_xenapi: A device configuration from Xen API (eg. vbd,vif)
+        @param target: write device information to
+        @type target: None or a dictionary
         @rtype: string
         @return: Assigned UUID of the device.
         """
+        if target == None:
+            target = self
+        
         if dev_type not in XendDevices.valid_devices() and \
            dev_type not in XendDevices.pseudo_devices():        
             raise XendConfigError("XendConfig: %s not a valid device type" %
@@ -914,15 +914,18 @@ class XendConfig(dict):
             except ValueError:
                 pass # SXP has no options for this device
 
-            
-            def _get_config_ipaddr(config):
+
+            # Special handling for certain device parameters.
+
+            def _get_config_ipaddr(cfg):
                 val = []
-                for ipaddr in sxp.children(config, elt='ip'):
+                for ipaddr in sxp.children(cfg, elt='ip'):
                     val.append(sxp.child0(ipaddr))
                 return val
 
             if dev_type == 'vif' and 'ip' in dev_info:
                 dev_info['ip'] = _get_config_ipaddr(config)
+                log.debug('XendConfig: IP Address: %s' % dev_info['ip'])
 
             if dev_type == 'vbd':
                 if dev_info.get('dev', '').startswith('ioemu:'):
@@ -936,11 +939,18 @@ class XendConfig(dict):
             dev_info['uuid'] = dev_uuid
 
             # store dev references by uuid for certain device types
-            self['devices'][dev_uuid] = (dev_type, dev_info)
+            target['devices'][dev_uuid] = (dev_type, dev_info)
             if dev_type in ('vif', 'vbd', 'vtpm'):
-                self['%s_refs' % dev_type].append(dev_uuid)
+                param = '%s_refs' % dev_type
+                if param not in target:
+                    target[param] = []
+                if dev_uuid in target[param]:
+                    target[param].append(dev_uuid)
             elif dev_type in ('tap',):
-                self['vbd_refs'].append(dev_uuid)
+                if 'vbd_refs' not in target:
+                    target['vbd_refs'] = []
+                if dev_uuid in target['vbd_refs']:
+                    target['vbd_refs'].append(dev_uuid)
 
             return dev_uuid
 

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [XEND] Make SXP parsing re-use device_add in XendConfig, Xen patchbot-unstable <=