[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging-4.17] block-common: Fix same_vm for no targets



commit 20443648649a499f1f5fcbe991a4ff35d31630f0
Author:     Jason Andryuk <jandryuk@xxxxxxxxx>
AuthorDate: Tue May 21 11:53:54 2024 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Tue May 21 11:53:54 2024 +0200

    block-common: Fix same_vm for no targets
    
    same_vm is broken when the two main domains do not have targets.  otvm
    and targetvm are both missing, which means they get set to -1 and then
    converted to empty strings:
    
    ++10697+ local targetvm=-1
    ++10697+ local otvm=-1
    ++10697+ otvm=
    ++10697+ othervm=/vm/cc97bc2f-3a91-43f7-8fbc-4cb92f90b4e4
    ++10697+ targetvm=
    ++10697+ local frontend_uuid=/vm/844dea4e-44f8-4e3e-8145-325132a31ca5
    
    The final comparison returns true since the two empty strings match:
    
    ++10697+ '[' /vm/844dea4e-44f8-4e3e-8145-325132a31ca5 = 
/vm/cc97bc2f-3a91-43f7-8fbc-4cb92f90b4e4 -o '' = 
/vm/cc97bc2f-3a91-43f7-8fbc-4cb92f90b4e4 -o 
/vm/844dea4e-44f8-4e3e-8145-325132a31ca5 = '' -o '' = '' ']'
    
    Replace -1 with distinct strings indicating the lack of a value and
    remove the collescing to empty stings.  The strings themselves will no
    longer match, and that is correct.
    
    ++12364+ '[' /vm/844dea4e-44f8-4e3e-8145-325132a31ca5 = 
/vm/cc97bc2f-3a91-43f7-8fbc-4cb92f90b4e4 -o 'No target' = 
/vm/cc97bc2f-3a91-43f7-8fbc-4cb92f90b4e4 -o 
/vm/844dea4e-44f8-4e3e-8145-325132a31ca5 = 'No other target' -o 'No target' = 
'No other target' ']'
    
    Signed-off-by: Jason Andryuk <jandryuk@xxxxxxxxx>
    Reviewed-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
    master commit: e8f1bb803fdf44db708991593568a9e3e6b3d130
    master date: 2024-02-07 13:46:52 +0100
---
 tools/hotplug/Linux/block-common.sh | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/tools/hotplug/Linux/block-common.sh 
b/tools/hotplug/Linux/block-common.sh
index f86a88c4eb..5c80237d99 100644
--- a/tools/hotplug/Linux/block-common.sh
+++ b/tools/hotplug/Linux/block-common.sh
@@ -112,14 +112,12 @@ 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 targetvm=$(xenstore_read_default "/local/domain/$target/vm" "No 
Target")
   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}
+                 "No Other Target")
+
   local frontend_uuid=${FRONTEND_UUID%-1}
   
   [ "$frontend_uuid" = "$othervm" -o "$targetvm" = "$othervm" -o \
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.17



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.