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

RE: [Xen-devel] [PATCH] implement pci coldplug for stubdoms

To: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: RE: [Xen-devel] [PATCH] implement pci coldplug for stubdoms
From: "Kay, Allen M" <allen.m.kay@xxxxxxxxx>
Date: Wed, 28 Oct 2009 17:38:56 -0700
Accept-language: en-US
Acceptlanguage: en-US
Cc:
Delivery-date: Wed, 28 Oct 2009 17:39:20 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <alpine.DEB.2.00.0910201601230.13442@kaball-desktop>
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: <alpine.DEB.2.00.0910201601230.13442@kaball-desktop>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcpRmIXFBgdIbfQLR+q4DOG3BW1AywGlz9dw
Thread-topic: [Xen-devel] [PATCH] implement pci coldplug for stubdoms
Stefano,

Have you tested multiple PCI passthrough with this patch?

When I tried to passthrough multiple PCI devices to a HVM domain, I got "Device 
0 is already connected" error.

I don't get this error with cs#20347.

Allen

-----Original Message-----
From: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx 
[mailto:xen-devel-bounces@xxxxxxxxxxxxxxxxxxx] On Behalf Of Stefano Stabellini
Sent: Tuesday, October 20, 2009 8:18 AM
To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] implement pci coldplug for stubdoms

Hi all,
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>

---

diff -r 1355ca322c38 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Wed Oct 14 16:43:22 2009 +0100
+++ b/tools/python/xen/xend/XendDomainInfo.py   Tue Oct 20 15:48:39 2009 +0100
@@ -687,7 +687,7 @@
         # 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)
@@ -905,7 +905,7 @@
                 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
 
@@ -2252,11 +2253,12 @@
             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)
-                
-                # store devid in XendConfig for caching reasons
-                if dev_uuid in self.info['devices']:
-                    self.info['devices'][dev_uuid][1]['devid'] = devid
+                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
 
             elif devclass == 'vscsi':
                 vscsi_config = config.get('devs', [])[0]
diff -r 1355ca322c38 tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py    Wed Oct 14 16:43:22 2009 +0100
+++ b/tools/python/xen/xend/image.py    Tue Oct 20 15:48:39 2009 +0100
@@ -460,6 +460,27 @@
         # 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 1355ca322c38 tools/python/xen/xend/server/pciif.py
--- a/tools/python/xen/xend/server/pciif.py     Wed Oct 14 16:43:22 2009 +0100
+++ b/tools/python/xen/xend/server/pciif.py     Tue Oct 20 15:48:39 2009 +0100
@@ -73,11 +73,16 @@
         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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

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

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