[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] stubdom: implement pci coldplug



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1256111470 -3600
# Node ID 9ead82c46efd7f95428a186e3dd3e8587ec9d811
# Parent  76d4f12e07905fbcaf031e7e9d65be120d303c7f
stubdom: implement pci coldplug

This patch fixes the circular dependency problem in the toolstack that
prevented pci coldplug from working with stubdoms: after creating the
stubdom we wait for it to be properly initialized before going
further. We release the domain lock while we wait.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
---
 tools/python/xen/xend/XendDomainInfo.py |   13 +++++++------
 tools/python/xen/xend/image.py          |   21 +++++++++++++++++++++
 tools/python/xen/xend/server/pciif.py   |    9 +++++++--
 3 files changed, 35 insertions(+), 8 deletions(-)

diff -r 76d4f12e0790 -r 9ead82c46efd tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Wed Oct 21 08:50:23 2009 +0100
+++ b/tools/python/xen/xend/XendDomainInfo.py   Wed Oct 21 08:51:10 2009 +0100
@@ -687,7 +687,7 @@ class XendDomainInfo:
         # Test whether the devices can be assigned
 
         pci_name = pci_dict_to_bdf_str(new_dev)
-        _all_assigned_pci_devices =  get_all_assigned_pci_devices()
+        _all_assigned_pci_devices =  get_all_assigned_pci_devices(self.domid)
         if pci_name in _all_assigned_pci_devices:
             raise VmError("failed to assign device %s that has"
                           " already been assigned to other domain." % pci_name)
@@ -906,7 +906,7 @@ class XendDomainInfo:
                 self.pci_device_check_attachability(dev)
 
         # If pci platform does not exist, create and exit.
-        if existing_dev_info is None:
+        if pci_state == 'Initialising' :
             self.device_create(dev_sxp)
             return True
 
@@ -2253,11 +2253,12 @@ class XendDomainInfo:
             if devclass in XendDevices.valid_devices() and devclass != 'vscsi':
                 log.info("createDevice: %s : %s" % (devclass, 
scrub_password(config)))
                 dev_uuid = config.get('uuid')
-                devid = self._createDevice(devclass, config)
+                if devclass != 'pci' or not self.info.is_hvm() :
+                    devid = self._createDevice(devclass, config)
                 
-                # store devid in XendConfig for caching reasons
-                if dev_uuid in self.info['devices']:
-                    self.info['devices'][dev_uuid][1]['devid'] = devid
+                    # store devid in XendConfig for caching reasons
+                    if dev_uuid in self.info['devices']:
+                        self.info['devices'][dev_uuid][1]['devid'] = devid
 
             elif devclass == 'vscsi':
                 vscsi_config = config.get('devs', [])[0]
diff -r 76d4f12e0790 -r 9ead82c46efd tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py    Wed Oct 21 08:50:23 2009 +0100
+++ b/tools/python/xen/xend/image.py    Wed Oct 21 08:51:10 2009 +0100
@@ -460,6 +460,27 @@ class ImageHandler:
         # we would very much prefer not to have a thread here and instead
         #  have a callback but sadly we don't have Twisted in xend
         self.sentinel_thread = thread.start_new_thread(self._sentinel_watch,())
+        if self.device_model.find('stubdom-dm') > -1 :
+            from xen.xend import XendDomain
+            domains = XendDomain.instance()
+            domains.domains_lock.release()
+
+            count = 0
+            while True:
+                orig_state = 
xstransact.Read("/local/domain/0/device-model/%i/state"
+                                    % self.vm.getDomid())
+                # This can occur right after start-up
+                if orig_state != None:
+                    break
+
+                log.debug('createDeviceModel %i: orig_state is None, retrying' 
% self.vm.getDomid())
+
+                time.sleep(0.1)
+                count += 1
+                if count < 100:
+                    continue
+
+            domains.domains_lock.acquire()
 
     def signalDeviceModel(self, cmd, ret, par = None):
         if self.device_model is None:
diff -r 76d4f12e0790 -r 9ead82c46efd tools/python/xen/xend/server/pciif.py
--- a/tools/python/xen/xend/server/pciif.py     Wed Oct 21 08:50:23 2009 +0100
+++ b/tools/python/xen/xend/server/pciif.py     Wed Oct 21 08:51:10 2009 +0100
@@ -73,11 +73,16 @@ def get_assigned_pci_devices(domid):
         dev_str_list = dev_str_list + [dev_str]
     return dev_str_list
 
-def get_all_assigned_pci_devices():
+def get_all_assigned_pci_devices(domid = 0):
     dom_list = xstransact.List('/local/domain')
     pci_str_list = []
+    ti = 0
+    ts = xstransact.Read('/local/domain/' + str(domid) + '/target')
+    if ts is not None :
+        ti = int(ts)
     for d in dom_list:
-        if xstransact.Read('/local/domain/' + d + '/target') is None :
+        target = xstransact.Read('/local/domain/' + d + '/target')
+        if int(d) is not ti and target is None :
             pci_str_list = pci_str_list + get_assigned_pci_devices(int(d))
     return pci_str_list
 

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.