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-devel

[Xen-devel] [patch v2] xend: xen-api, pass-through: Add create_dpci_from

To: Masaki Kanno <kanno.masaki@xxxxxxxxxxxxxx>
Subject: [Xen-devel] [patch v2] xend: xen-api, pass-through: Add create_dpci_from_sxp()
From: Simon Horman <horms@xxxxxxxxxxxx>
Date: Thu, 4 Jun 2009 16:57:05 +1000
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx, Dexuan Cui <dexuan.cui@xxxxxxxxx>
Delivery-date: Wed, 03 Jun 2009 23:57:42 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <89C9E4CB840D28kanno.masaki@xxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20090604032115.934982694@xxxxxxxxxxxx> <20090604032230.575111995@xxxxxxxxxxxx> <89C9E4CB840D28kanno.masaki@xxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.18 (2008-05-17)
Move some duplicated code into create_dpci_from_sxp()

Cc: Dexuan Cui <dexuan.cui@xxxxxxxxx>
Cc: Masaki Kanno <kanno.masaki@xxxxxxxxxxxxxx>
Signed-off-by: Simon Horman <horms@xxxxxxxxxxxx>

--- 
* v2: Updated to remove spurious debug message

Index: xen-unstable.hg/tools/python/xen/xend/XendConfig.py
===================================================================
--- xen-unstable.hg.orig/tools/python/xen/xend/XendConfig.py    2009-06-03 
16:30:59.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xend/XendConfig.py 2009-06-04 
08:27:04.000000000 +1000
@@ -1221,7 +1221,28 @@ class XendConfig(dict):
                         raise XendConfigError('The mac "%s" is already 
defined' %
                                               dev_mac)
         return None
-    
+
+    def create_dpci_from_sxp(self, pci_devs):
+        for pci_dev in pci_devs:
+            dpci_uuid = pci_dev.get('uuid')
+            ppci_uuid = XendPPCI.get_by_sbdf(pci_dev['domain'],
+                                             pci_dev['bus'],
+                                             pci_dev['slot'],
+                                             pci_dev['func'])
+            if ppci_uuid is None:
+                continue
+            dpci_record = {
+                'VM': self['uuid'],
+                'PPCI': ppci_uuid,
+                'hotplug_slot': pci_dev.get('vslot', 0)
+            }
+
+            dpci_opts = pci_dev.get('opts')
+            if dpci_opts and len(dpci_opts) > 0:
+                dpci_record['options'] = dpci_opts
+
+            XendDPCI(dpci_uuid, dpci_record)
+
     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.
@@ -1276,25 +1298,7 @@ class XendConfig(dict):
                 pci_devs = pci_dict['devs']
 
                 # create XenAPI DPCI objects.
-                for pci_dev in pci_devs:
-                    dpci_uuid = pci_dev.get('uuid')
-                    ppci_uuid = XendPPCI.get_by_sbdf(pci_dev['domain'],
-                                                     pci_dev['bus'],
-                                                     pci_dev['slot'],
-                                                     pci_dev['func'])
-                    if ppci_uuid is None:
-                        continue
-                    dpci_record = {
-                        'VM': self['uuid'],
-                        'PPCI': ppci_uuid,
-                        'hotplug_slot': pci_dev.get('vslot', 0)
-                    }
-
-                    dpci_opts = pci_dev.get('opts')
-                    if dpci_opts and len(dpci_opts) > 0:
-                        dpci_record['options'] = dpci_opts
-
-                    XendDPCI(dpci_uuid, dpci_record)
+                self.create_dpci_from_sxp(pci_devs)
 
                 target['devices'][pci_devs_uuid] = (dev_type,
                                                     {'devs': pci_devs,
@@ -1846,25 +1850,7 @@ class XendConfig(dict):
                     XendAPIStore.deregister(dpci_uuid, "DPCI")
 
                 # create XenAPI DPCI objects.
-                for pci_dev in pci_devs:
-                    dpci_uuid = pci_dev.get('uuid')
-                    ppci_uuid = XendPPCI.get_by_sbdf(pci_dev['domain'],
-                                                     pci_dev['bus'],
-                                                     pci_dev['slot'],
-                                                     pci_dev['func'])
-                    if ppci_uuid is None:
-                        continue
-                    dpci_record = {
-                        'VM': self['uuid'],
-                        'PPCI': ppci_uuid,
-                        'hotplug_slot': pci_dev.get('vslot', 0)
-                    }
-
-                    dpci_opts = pci_dev.get('opts')
-                    if dpci_opts and len(dpci_opts) > 0:
-                        dpci_record['options'] = dpci_opts
-
-                    XendDPCI(dpci_uuid, dpci_record)
+                self.create_dpci_from_sxp(pci_devs)
 
                 self['devices'][dev_uuid] = (dev_type,
                                              {'devs': pci_devs,

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

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