ia64/xen-unstable

changeset 13871:ed9dba8e2c67

Improve hotplug script error reporting via xenstore.

Use this to detect and report up-front in vif-bridge script whether
the bridge device exists or not.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
author kfraser@localhost.localdomain
date Wed Feb 07 16:22:55 2007 +0000 (2007-02-07)
parents b83a81b99f20
children ce97d6714be4
files tools/examples/vif-bridge tools/examples/xen-hotplug-common.sh tools/python/xen/xend/server/DevController.py
line diff
     1.1 --- a/tools/examples/vif-bridge	Wed Feb 07 16:20:28 2007 +0000
     1.2 +++ b/tools/examples/vif-bridge	Wed Feb 07 16:22:55 2007 +0000
     1.3 @@ -46,6 +46,13 @@ then
     1.4    fi
     1.5  fi
     1.6  
     1.7 +RET=0
     1.8 +ip link show $bridge 1>/dev/null 2>&1 || RET=1
     1.9 +if [ "$RET" -eq 1 ]
    1.10 +then
    1.11 +    fatal "Could not find bridge device $bridge"
    1.12 +fi
    1.13 +
    1.14  case "$command" in
    1.15      online)
    1.16  	setup_bridge_port "$vif"
     2.1 --- a/tools/examples/xen-hotplug-common.sh	Wed Feb 07 16:20:28 2007 +0000
     2.2 +++ b/tools/examples/xen-hotplug-common.sh	Wed Feb 07 16:22:55 2007 +0000
     2.3 @@ -28,14 +28,15 @@ export LANG="POSIX"
     2.4  unset $(set | grep ^LC_ | cut -d= -f1)
     2.5  
     2.6  fatal() {
     2.7 -  xenstore_write "$XENBUS_PATH"/hotplug-status error
     2.8 +  xenstore_write "$XENBUS_PATH/hotplug-error" "$*" \
     2.9 +                 "$XENBUS_PATH/hotplug-status" error
    2.10    log err "$@"
    2.11    exit 1
    2.12  }
    2.13  
    2.14  success() {
    2.15    # Tell DevController that backend is "connected"
    2.16 -  xenstore_write "$XENBUS_PATH"/hotplug-status connected
    2.17 +  xenstore_write "$XENBUS_PATH/hotplug-status" connected
    2.18  }
    2.19  
    2.20  do_or_die() {
     3.1 --- a/tools/python/xen/xend/server/DevController.py	Wed Feb 07 16:20:28 2007 +0000
     3.2 +++ b/tools/python/xen/xend/server/DevController.py	Wed Feb 07 16:22:55 2007 +0000
     3.3 @@ -153,9 +153,9 @@ class DevController:
     3.4          log.debug("Waiting for %s.", devid)
     3.5  
     3.6          if not self.hotplug:
     3.7 -            return 
     3.8 -        
     3.9 -        status = self.waitForBackend(devid)
    3.10 +            return
    3.11 +
    3.12 +        (status, err) = self.waitForBackend(devid)
    3.13  
    3.14          if status == Timeout:
    3.15              self.destroyDevice(devid, False)
    3.16 @@ -165,25 +165,22 @@ class DevController:
    3.17  
    3.18          elif status == Error:
    3.19              self.destroyDevice(devid, False)
    3.20 -            raise VmError("Device %s (%s) could not be connected. "
    3.21 -                          "Backend device not found." %
    3.22 -                          (devid, self.deviceClass))
    3.23 -
    3.24 +            if err is None:
    3.25 +                raise VmError("Device %s (%s) could not be connected. "
    3.26 +                              "Backend device not found." %
    3.27 +                              (devid, self.deviceClass))
    3.28 +            else:
    3.29 +                raise VmError("Device %s (%s) could not be connected. "
    3.30 +                              "%s" % (devid, self.deviceClass, err))
    3.31          elif status == Missing:
    3.32              # Don't try to destroy the device; it's already gone away.
    3.33              raise VmError("Device %s (%s) could not be connected. "
    3.34                            "Device not found." % (devid, self.deviceClass))
    3.35  
    3.36          elif status == Busy:
    3.37 -            err = None
    3.38 -            frontpath = self.frontendPath(devid)
    3.39 -            backpath = xstransact.Read(frontpath, "backend")
    3.40 -            if backpath:
    3.41 -                err = xstransact.Read(backpath, HOTPLUG_ERROR_NODE)
    3.42 -            if not err:
    3.43 +            self.destroyDevice(devid, False)
    3.44 +            if err is None:
    3.45                  err = "Busy."
    3.46 -                
    3.47 -            self.destroyDevice(devid, False)
    3.48              raise VmError("Device %s (%s) could not be connected.\n%s" %
    3.49                            (devid, self.deviceClass, err))
    3.50  
    3.51 @@ -478,17 +475,21 @@ class DevController:
    3.52          frontpath = self.frontendPath(devid)
    3.53          backpath = xstransact.Read(frontpath, "backend")
    3.54  
    3.55 +
    3.56          if backpath:
    3.57              statusPath = backpath + '/' + HOTPLUG_STATUS_NODE
    3.58              ev = Event()
    3.59              result = { 'status': Timeout }
    3.60 -            
    3.61 +
    3.62              xswatch(statusPath, hotplugStatusCallback, ev, result)
    3.63  
    3.64              ev.wait(DEVICE_CREATE_TIMEOUT)
    3.65 -            return result['status']
    3.66 +
    3.67 +            err = xstransact.Read(backpath, HOTPLUG_ERROR_NODE)
    3.68 +
    3.69 +            return (result['status'], err)
    3.70          else:
    3.71 -            return Missing
    3.72 +            return (Missing, None)
    3.73  
    3.74  
    3.75      def backendPath(self, backdom, devid):