diff --git a/provisioning_scripts/fibre_channel/fc_commands.sh b/provisioning_scripts/fibre_channel/fc_commands.sh index dbf5bef..534507d 100755 --- a/provisioning_scripts/fibre_channel/fc_commands.sh +++ b/provisioning_scripts/fibre_channel/fc_commands.sh @@ -33,6 +33,7 @@ ALLOWED_CMDS=" ^source keystonerc_jenkins \&\& nova list$ ^source keystonerc_jenkins \&\& nova show [a-f0-9]+-[a-f0-9]+-[a-f0-9]+-[a-f0-9]+-[a-f0-9]+$ ^virsh nodedev-dettach pci_0000_[02][51]_00_[23]$ +^virsh nodedev-reattach pci_0000_[02][51]_00_[23]$ ^scp -t /tmp/$ ^virsh attach-device instance-[0-9a-f]* /tmp/tmp.*_fcoe.xml$ ^echo \\\$fc_pci_device$" diff --git a/provisioning_scripts/fibre_channel/invoke_fc_passthrough.sh b/provisioning_scripts/fibre_channel/invoke_fc_passthrough.sh index 20ca57e..fae4256 100644 --- a/provisioning_scripts/fibre_channel/invoke_fc_passthrough.sh +++ b/provisioning_scripts/fibre_channel/invoke_fc_passthrough.sh @@ -143,6 +143,8 @@ for pci in $fc_pci_device; do fcoe=`mktemp --suffix=_fcoe.xml` echo $XML > $fcoe + fc_virsh_device="pci_0000_${BUS}_${SLOT}_${FUNCTION}" + scp -i $PROVIDER_KEY $fcoe $PROVIDER_USER@$HYPERVISOR:/tmp/ # Run passthrough and clean up. @@ -150,12 +152,23 @@ for pci in $fc_pci_device; do # will need to do this cleanup at the end of the job and not *before* attaching # since we won't know which ones are still in use echo $(sudo lspci | grep -i fib) - ssh -i $PROVIDER_KEY $PROVIDER_USER@$HYPERVISOR "virsh nodedev-dettach pci_0000_${BUS}_${SLOT}_${FUNCTION}" + ssh -i $PROVIDER_KEY $PROVIDER_USER@$HYPERVISOR "virsh nodedev-dettach $fc_virsh_device" detach_result=$? echo "Detach result: $detach_result" if [[ $detach_result -ne 0 ]]; then - echo "Detach failed. Trying next device..." + echo "Detach failed ($detach_result). Trying next device..." + continue + fi + + # Reattach the device to the host. + # This will hopefully reset the device + echo $(sudo lspci | grep -i fib) + ssh -i $PROVIDER_KEY $PROVIDER_USER@$HYPERVISOR "virsh nodedev-reattach $fc_virsh_device" + reattach_result=$? + echo "reattach result: $reattach_result" + if [[ $reattach_result -ne 0 ]]; then + echo "Reattach failed ($reattach_result). Trying next device..." continue fi