]> xenbits.xensource.com Git - xen.git/commitdiff
xend: Fix removing /vm/UUID/device paths when device cannot be disconnected
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 12 Mar 2009 15:08:08 +0000 (15:08 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 12 Mar 2009 15:08:08 +0000 (15:08 +0000)
This is a corrected version of a patch commited as c/s 19250 and
reverted by c/s 19314. Thanks to "trap sigerr ERR" in
xen-hotplug-common.sh the xen-hotplug-cleanup would exit when reading
/local/domain/ID/vm fails thus skipping all the xenstore-rm lines in
the rest of the script.

Change deviceDestroy behavior to remove /vm/UUID/device/...
path only when force was used (as it already does so for both frontend
and backend) and do the removing from xen-hotplug-cleanup script when
we are sure the device is really not attached to the guest any more.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
tools/hotplug/Linux/xen-hotplug-cleanup
tools/python/xen/xend/server/DevController.py

index f7337e45bfa0c52d6fcddd8eeead4dd222bcf9f1..706359d03a3d6f6a81bbe1a51147534a19a973b9 100644 (file)
@@ -11,6 +11,17 @@ dir=$(dirname "$0")
 # This is pretty horrible, but there's not really a nicer way of solving this.
 claim_lock "block"
 
+# split backend/DEVCLASS/VMID/DEVID on slashes
+path_array=( ${XENBUS_PATH//\// } )
+# get /vm/UUID path
+vm=$(xenstore_read_default "/local/domain/${path_array[2]}/vm" "")
+# construct /vm/UUID/device/DEVCLASS/DEVID
+if [ "$vm" != "" ]; then
+  vm_dev="$vm/device/${path_array[1]}/${path_array[3]}"
+else
+  vm_dev=
+fi
+
 # remove device frontend store entries
 xenstore-rm -t \
   $(xenstore-read "$XENBUS_PATH/frontend" 2>/dev/null) 2>/dev/null || true
@@ -19,4 +30,7 @@ xenstore-rm -t \
 xenstore-rm -t "$XENBUS_PATH"        2>/dev/null || true
 xenstore-rm -t "error/$XENBUS_PATH"  2>/dev/null || true
 
+# remove device path from /vm/UUID
+[ "$vm_dev" != "" ] && xenstore-rm -t "$vm_dev" 2>/dev/null || true
+
 release_lock "block"
index 67ca78ff797f7b2b0a9fc67baeb175534893cf0a..6c2bb09ca638419681591e3c7b1ebdb9a58a802c 100644 (file)
@@ -235,8 +235,8 @@ class DevController:
                 xstransact.Remove(backpath)
             xstransact.Remove(frontpath)
 
-        # xstransact.Remove(self.devicePath()) ?? Below is the same ?
-        self.vm._removeVm("device/%s/%d" % (self.deviceClass, dev))
+            # xstransact.Remove(self.devicePath()) ?? Below is the same ?
+            self.vm._removeVm("device/%s/%d" % (self.deviceClass, dev))
 
     def configurations(self, transaction = None):
         return map(lambda x: self.configuration(x, transaction), self.deviceIDs(transaction))