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-3.0.5-testing] xend: Fix race in vfb/vkbd device se

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-3.0.5-testing] xend: Fix race in vfb/vkbd device setup.
From: "Xen patchbot-3.0.5-testing" <patchbot-3.0.5-testing@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 25 Apr 2007 08:40:52 -0700
Delivery-date: Wed, 25 Apr 2007 08:41:27 -0700
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 kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1177490660 -3600
# Node ID 8ca89a9e54a7973e36787878b1fddab436bf003f
# Parent  4677ee247aa9a94ddf787077be12e022a38dd99f
xend: Fix race in vfb/vkbd device setup.

 1. XendDomainInfo._createDevices() gets a list of devices to be
    created from XendConfig.ordered_device_refs().
    On a simple guest, this has 4 devices, vfb, vbd, vif, vkbd - in
    that order.

 2. It iterates over those devices, creating the appropriate
    DevController subclass instance, and then calling createDevice()
    on that object.

 3. When createDevice() is called on the vfb  device, it spawns
    xen-vncfb daemon.

 4. During startup xen-vncfb writes into the backend paths
            /local/domain/0/backend/vfb/0
     And
            /local/domain/0/backend/vkbd/0

 5. When createDevice() is called on the vkbd device in XenD, if the
    2nd xenstore path write from step 4 has occurred, then you'll hit
    the 'Device 0 (vkbd) is already connected' error. If the 2nd path
    write didn't complete yet then everything is fine.

I think the reason it often works once after boot is that loading
xen-vncfb from disk the first time around is just enough of a slow
down to ensure step 5 occurs before the 2nd xenstore write in step 4
has occurred.

The key seems to be to ensure the vkbd device is initialized in
xenstore before the vfb device - this ensures all the xenstored setup
from XenD is complete before the xen-vncfb daemon starts. I'm now able
to create & destroy a domain many times over with this patch & never
hit the error message any more.

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 tools/python/xen/xend/XendConfig.py |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diff -r 4677ee247aa9 -r 8ca89a9e54a7 tools/python/xen/xend/XendConfig.py
--- a/tools/python/xen/xend/XendConfig.py       Wed Apr 25 09:40:02 2007 +0100
+++ b/tools/python/xen/xend/XendConfig.py       Wed Apr 25 09:44:20 2007 +0100
@@ -1278,10 +1278,21 @@ class XendConfig(dict):
         return sxpr
 
     def ordered_device_refs(self):
-        result = (self['console_refs'] +
-                  self['vbd_refs'] +
-                  self['vif_refs'] +
-                  self['vtpm_refs'])
+        result = []
+        # vkbd devices *must* be before vfb devices, otherwise
+        # there is a race condition when setting up devices
+        # where the daemon spawned for the vfb may write stuff
+        # into xenstore vkbd backend, before DevController has
+        # setup permissions on the vkbd backend path. This race
+        # results in domain creation failing with 'device already
+        # connected' messages
+        result.extend([u for u in self['devices'].keys() if 
self['devices'][u][0] == 'vkbd'])
+
+        result.extend(self['console_refs'] +
+                      self['vbd_refs'] +
+                      self['vif_refs'] +
+                      self['vtpm_refs'])
+
         result.extend([u for u in self['devices'].keys() if u not in result])
         return result
 

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-3.0.5-testing] xend: Fix race in vfb/vkbd device setup., Xen patchbot-3.0.5-testing <=