From f4e427216e8b7dd0166fbb4ba6dc533b7f11d24f Mon Sep 17 00:00:00 2001 From: "Walter A. Boring IV" Date: Wed, 18 Nov 2015 10:52:52 -0800 Subject: [PATCH] Move HBA online check This patch moves the test for the HBA to after it's been reattached to the host driver. The current check will always fail, because it will never see it. The host driver will never see the HBA until after the virsh reattach command runs. Change-Id: I74255576e2b7f31dcb35c87bbf7fc270d6d736b0 --- .../fibre_channel/invoke_fc_passthrough.sh | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/provisioning_scripts/fibre_channel/invoke_fc_passthrough.sh b/provisioning_scripts/fibre_channel/invoke_fc_passthrough.sh index 1f43e21..5a532af 100644 --- a/provisioning_scripts/fibre_channel/invoke_fc_passthrough.sh +++ b/provisioning_scripts/fibre_channel/invoke_fc_passthrough.sh @@ -146,22 +146,12 @@ function is_device_online() { exit_code=1 errexit=$(set +o | grep errexit) -#Ignore errors +# Ignore errors set +e let num_attached=0 for pci in $fc_pci_device; do echo "Trying passthrough for $pci" - is_device_online $pci - online=$? - if [ $online -eq 1 ]; then - echo "Device($pci) is Online" - else - echo "Device($pci) is NOT Online" - # It does no good to passthrough an HBA that isn't Online. - # When an HBA goes into 'Linkdown' or 'Offline' mode, the - # host typically needs to get rebooted. - continue - fi + BUS=$(echo $pci | cut -d : -f2) SLOT=$(echo $pci | cut -d : -f3 | cut -d . -f1) FUNCTION=$(echo $pci | cut -d : -f3 | cut -d . -f2) @@ -199,6 +189,20 @@ for pci in $fc_pci_device; do continue fi + # Now that the device has been re-attached to it's host device driver + # systool should be able to see it. Make sure it's online. + is_device_online $pci + online=$? + if [ $online -eq 1 ]; then + echo "Device($pci) is Online" + else + echo "Device($pci) is NOT Online" + # It does no good to passthrough an HBA that isn't Online. + # When an HBA goes into 'Linkdown' or 'Offline' mode, the + # host typically needs to get rebooted. + continue + fi + echo $(sudo lspci | grep -i fib) ssh -i $PROVIDER_KEY $PROVIDER_USER@$HYPERVISOR "virsh attach-device $VIRSH_NAME $fcoe" attach_result=$?