hotplug/Linux: fix same_vm check in block script
authorWei Liu <wei.liu2@citrix.com>
Wed, 13 Apr 2016 17:02:36 +0000 (18:02 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 15 Apr 2016 11:02:28 +0000 (12:02 +0100)
The original same_vm check has two bugs. When stubdom is in use because
it relies on numeric domid to check if two domains are in fact the same
one.  Another one is that the check would fail when two stubdoms are
checked against each other.

The first bug is fixed by using uuid to identify a domain. The second
bug is fixed by comparing the domains two stubdoms serve.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
tools/hotplug/Linux/block-common.sh

index 35110b47b4c2b1632e205fd6873f2672f015aa52..f86a88c4ebce21036a3e029223099ef9501fad21 100644 (file)
@@ -112,14 +112,17 @@ same_vm()
                   "$FRONTEND_UUID")
   local target=$(xenstore_read_default  "/local/domain/$FRONTEND_ID/target"   \
                  "-1")
+  local targetvm=$(xenstore_read_default "/local/domain/$target/vm" "-1")
   local otarget=$(xenstore_read_default  "/local/domain/$otherdom/target"   \
                  "-1")
   local otvm=$(xenstore_read_default  "/local/domain/$otarget/vm"   \
                  "-1")
   otvm=${otvm%-1}
   othervm=${othervm%-1}
+  targetvm=${targetvm%-1}
   local frontend_uuid=${FRONTEND_UUID%-1}
   
-  [ "$frontend_uuid" = "$othervm" -o "$target" = "$otherdom" -o "$frontend_uuid" = "$otvm" ]
+  [ "$frontend_uuid" = "$othervm" -o "$targetvm" = "$othervm" -o \
+    "$frontend_uuid" = "$otvm" -o "$targetvm" = "$otvm" ]
 }