All of lore.kernel.org
 help / color / mirror / Atom feed
From: Murillo Fernandes Bernardes <mfb@br.ibm.com>
To: xen-devel@lists.xensource.com, aliguori@us.ibm.com
Subject: [PATCH] Add a mechanism to detect block device setup failure
Date: Fri, 28 Oct 2005 16:42:10 -0200	[thread overview]
Message-ID: <200510281642.11257.mfb@br.ibm.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 576 bytes --]

Hi

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.

Comments?

Regards

-- 
Murillo Fernandes Bernardes

[-- Attachment #2: DevController_device_create_check.patch --]
[-- Type: text/x-diff, Size: 4398 bytes --]

diff -r 20d1a79ebe31 tools/examples/block-common.sh
--- a/tools/examples/block-common.sh	Wed Oct 26 15:59:13 2005
+++ b/tools/examples/block-common.sh	Thu Oct 27 20:15:02 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 20d1a79ebe31 tools/examples/vif-bridge
--- a/tools/examples/vif-bridge	Wed Oct 26 15:59:13 2005
+++ b/tools/examples/vif-bridge	Thu Oct 27 20:15:02 2005
@@ -45,6 +45,7 @@
           fatal "brctl addif $bridge $vif failed"
 
         ifconfig "$vif" up || fatal "ifconfig $vif up failed"
+        success
         ;;
     down)
         # vifs are auto-removed from bridge.
@@ -55,3 +56,4 @@
 handle_iptable
 
 log debug "vif-bridge operation for $vif successful."
+
diff -r 20d1a79ebe31 tools/examples/vif-nat
--- a/tools/examples/vif-nat	Wed Oct 26 15:59:13 2005
+++ b/tools/examples/vif-nat	Thu Oct 27 20:15:02 2005
@@ -54,3 +54,5 @@
 ip r ${ipcmd} ${ip} dev ${vif} src ${main_ip}
 
 handle_iptable()
+
+success
diff -r 20d1a79ebe31 tools/examples/vif-route
--- a/tools/examples/vif-route	Wed Oct 26 15:59:13 2005
+++ b/tools/examples/vif-route	Thu Oct 27 20:15:02 2005
@@ -46,3 +46,5 @@
 fi
 
 handle_iptable()
+
+success
diff -r 20d1a79ebe31 tools/examples/xen-hotplug-common.sh
--- a/tools/examples/xen-hotplug-common.sh	Wed Oct 26 15:59:13 2005
+++ b/tools/examples/xen-hotplug-common.sh	Thu Oct 27 20:15:02 2005
@@ -29,8 +29,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
 }
 
 xenstore_read() {
diff -r 20d1a79ebe31 tools/python/xen/xend/server/DevController.py
--- a/tools/python/xen/xend/server/DevController.py	Wed Oct 26 15:59:13 2005
+++ b/tools/python/xen/xend/server/DevController.py	Thu Oct 27 20:15:02 2005
@@ -16,12 +16,19 @@
 # Copyright (C) 2005 XenSource Ltd
 #============================================================================
 
+import time
+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 +61,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
 
 
@@ -234,6 +253,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."""

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

             reply	other threads:[~2005-10-28 18:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-28 18:42 Murillo Fernandes Bernardes [this message]
  -- strict thread matches above, loose matches on Subject: below --
2005-10-29  3:11 [PATCH] Add a mechanism to detect block device setup failure Murillo Fernandes Bernardes
2005-10-31 16:16 ` Ewan Mellor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200510281642.11257.mfb@br.ibm.com \
    --to=mfb@br.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.