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] From Murillo Fernandes Bernardes <mfb@xxxxxxxxxx>:

# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID 286946489e5d78433e02670b00eacf56b226162d
# Parent  a7129a40f239518d50b95beb751b6a27196e36c0
>From Murillo Fernandes Bernardes <mfb@xxxxxxxxxx>:

The problem is: There is no mechanism to detect block device setup failure

Network devices have the same problem, and are fixed with this too.

I handling this problem in the way suggested by aliguori:
- hotplug scripts write a "hotplug-status" node on store
- Xend DevController.createDevice() check verify this node and return success
or throw an exception on failure.
- If no changes in "hotplug-status" node after DEVICE_CREATE_TIMEOUT seconds
Xend throw an exception showing the problem with hotplug scripts.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>

diff -r a7129a40f239 -r 286946489e5d tools/examples/block-common.sh
--- a/tools/examples/block-common.sh    Mon Oct 31 16:03:13 2005
+++ b/tools/examples/block-common.sh    Mon Oct 31 16:10:57 2005
@@ -42,10 +42,17 @@
   local major
   local minor
   local pdev
-       
+  
   major=$(stat -L -c %t "$1")
   minor=$(stat -L -c %T "$1")
+ 
+  if [ -z $major  -o -z $minor ]; then
+    fatal "Backend device does not exist"
+  fi
+ 
   pdev=$(printf "0x%02x%02x" "0x$major" "0x$minor")
   xenstore_write "$XENBUS_PATH"/physical-device "$pdev" \
                  "$XENBUS_PATH"/node "$1"
+
+  success
 }
diff -r a7129a40f239 -r 286946489e5d tools/examples/vif-bridge
--- a/tools/examples/vif-bridge Mon Oct 31 16:03:13 2005
+++ b/tools/examples/vif-bridge Mon Oct 31 16:10:57 2005
@@ -58,6 +58,7 @@
           fatal "brctl addif $bridge $vif failed"
 
         ifconfig "$vif" up || fatal "ifconfig $vif up failed"
+        success
         ;;
     down)
         # vifs are auto-removed from bridge.
diff -r a7129a40f239 -r 286946489e5d tools/examples/vif-nat
--- a/tools/examples/vif-nat    Mon Oct 31 16:03:13 2005
+++ b/tools/examples/vif-nat    Mon Oct 31 16:10:57 2005
@@ -54,3 +54,5 @@
 ip r ${ipcmd} ${ip} dev ${vif} src ${main_ip}
 
 handle_iptable()
+
+success
diff -r a7129a40f239 -r 286946489e5d tools/examples/vif-route
--- a/tools/examples/vif-route  Mon Oct 31 16:03:13 2005
+++ b/tools/examples/vif-route  Mon Oct 31 16:10:57 2005
@@ -46,3 +46,5 @@
 fi
 
 handle_iptable()
+
+success
diff -r a7129a40f239 -r 286946489e5d tools/examples/xen-hotplug-common.sh
--- a/tools/examples/xen-hotplug-common.sh      Mon Oct 31 16:03:13 2005
+++ b/tools/examples/xen-hotplug-common.sh      Mon Oct 31 16:10:57 2005
@@ -30,8 +30,14 @@
 }
 
 fatal() {
+  xenstore_write "$XENBUS_PATH"/hotplug-status error
   log err "$@"
   exit 1
+}
+
+success() {
+  # Tell DevController that backend is "connected"
+  xenstore_write "$XENBUS_PATH"/hotplug-status connected
 }
 
 ##
diff -r a7129a40f239 -r 286946489e5d 
tools/python/xen/xend/server/DevController.py
--- a/tools/python/xen/xend/server/DevController.py     Mon Oct 31 16:03:13 2005
+++ b/tools/python/xen/xend/server/DevController.py     Mon Oct 31 16:10:57 2005
@@ -16,12 +16,18 @@
 # Copyright (C) 2005 XenSource Ltd
 #============================================================================
 
+from threading import Event
 
 from xen.xend import sxp
 from xen.xend.XendError import VmError
 from xen.xend.XendLogging import log
+
 from xen.xend.xenstore.xstransact import xstransact
-
+from xen.xend.xenstore.xswatch import xswatch
+
+DEVICE_CREATE_TIMEOUT = 120
+HOTPLUG_STATUS_NODE = "hotplug-status"
+HOTPLUG_STATUS_ERROR = "error"
 
 class DevController:
     """Abstract base class for a device controller.  Device controllers create
@@ -54,6 +60,18 @@
 
         self.writeDetails(config, devid, back, front)
 
+        status, fn_ret = self.waitForBackend(devid)
+        if status:
+            self.destroyDevice(devid)
+            raise VmError( ("Device %s (%s) could not be connected. "
+                            "Hotplug scripts not working") 
+                            % (devid, self.deviceClass))
+
+        elif fn_ret == HOTPLUG_STATUS_ERROR:
+            self.destroyDevice(devid)
+            raise VmError( ("Device %s (%s) could not be connected. "
+                            "Backend device not found!") 
+                            % (devid, self.deviceClass))
         return devid
 
 
@@ -242,6 +260,29 @@
         xstransact.Write(frontpath, frontDetails)
         xstransact.Write(backpath, backDetails)
 
+    def waitForBackend(self,devid):
+        ev = Event()
+
+        def hotplugStatus():
+            status = self.readBackend(devid, HOTPLUG_STATUS_NODE)
+            if status is not None:
+                watch.xs.unwatch(backpath, watch)
+                hotplugStatus.value = status
+                ev.set()
+
+        hotplugStatus.value = None
+        frontpath = self.frontendPath(devid)
+        backpath = xstransact.Read(frontpath, "backend")
+
+        watch = xswatch(backpath, hotplugStatus)
+
+        ev.wait(DEVICE_CREATE_TIMEOUT)
+        if ev.isSet():
+            return (0, hotplugStatus.value)
+        else:
+            return (-1, hotplugStatus.value)
+
+
 
     def backendPath(self, backdom, devid):
         """@param backdom [XendDomainInfo] The backend domain info."""

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] From Murillo Fernandes Bernardes <mfb@xxxxxxxxxx>:, Xen patchbot -unstable <=