arch-run: more qemu binary search cleanup
PATCH 1/1 arch-run: more qemu binary search cleanup
We use tabs in scripts/arch-run.bash, which the import of the function forgot to convert to. Also, while touching all lines to add the tabs, apply some more cleanups and simplifications.
--- scripts/arch-run.bash | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-)
scripts/arch-run.bash +18 -21
@@ -134,27 +134,24 @@ migration_cmd () fi } -# qemu binary search function for all arches search_qemu_binary () { - local save_path=$PATH - local qemucmd QEMUFOUND qemu - export PATH=$PATH:/usr/libexec - for qemucmd in ${QEMU:-qemu-system-$ARCH_NAME qemu-kvm} - do - unset QEMUFOUND - unset qemu - if ! [ -z "${QEMUFOUND=$(${qemucmd} --help 2>/dev/null | grep "QEMU")}" ] - then - qemu="${qemucmd}" - break - fi - done - - if [ -z "${QEMUFOUND}" ]; then - echo "A QEMU binary was not found, You can set a custom location by using the QEMU=<path> environment variable" - exit 2 - fi - which $qemu - export PATH=$save_path + local save_path=$PATH + local qemucmd qemu + + export PATH=$PATH:/usr/libexec + for qemucmd in ${QEMU:-qemu-system-$ARCH_NAME qemu-kvm}; do + if $qemucmd --help 2>/dev/null | grep -q 'QEMU'; then + qemu="$qemucmd" + break + fi + done + + if [ -z "$qemu" ]; then + echo "A QEMU binary was not found." + echo "You can set a custom location by using the QEMU=<path> environment variable." + exit 2 + fi + command -v $qemu + export PATH=$save_path }
Signature · 1 line
2.9.3
It looks good and I have tested this patch in x86 and PowerPC.
I tried to use git am <patch> but it fails with,
# git am ./test.patch Patch format detection failed.
so I did git apply and tested. Henceforth I will use tabs for indentation.
Regards,
Bala
Quoted 62 lines · Andrew Jones
We use tabs in
scripts/arch-run.bash, which the import of the function forgot to convert to. Also, while touching all lines to add the tabs, apply some more cleanups and simplifications.Signed-off-by Andrew Jones <[email protected]>--- scripts/arch-run.bash | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-)scripts/arch-run.bash +18
-21@@ -134,27 +134,24 @@ migration_cmd () fi } -# qemu binary search function for all arches search_qemu_binary () { - local save_path=$PATH - local qemucmd QEMUFOUND qemu - export PATH=$PATH:/usr/libexec - for qemucmd in ${QEMU:-qemu-system-$ARCH_NAME qemu-kvm} - do - unset QEMUFOUND - unset qemu - if ! [ -z "${QEMUFOUND=$(${qemucmd} --help 2>/dev/null | grep "QEMU")}" ] - then - qemu="${qemucmd}" - break - fi - done - - if [ -z "${QEMUFOUND}" ]; then - echo "A QEMU binary was not found, You can set a custom location by using the QEMU=<path> environment variable" - exit 2 - fi - which $qemu - export PATH=$save_path + local save_path=$PATH + local qemucmd qemu + + export PATH=$PATH:/usr/libexec + for qemucmd in ${QEMU:-qemu-system-$ARCH_NAME qemu-kvm}; do + if $qemucmd --help 2>/dev/null | grep -q 'QEMU'; then + qemu="$qemucmd" + break + fi + done + + if [ -z "$qemu" ]; then + echo "A QEMU binary was not found." + echo "You can set a custom location by using the QEMU=<path> environment variable." + exit 2 + fi + command -v $qemu + export PATH=$save_path }Signature · 1 line
2.9.3
Quoted 8 lines · Balamuruhan S
It looks good and I have tested this patch in x86 and PowerPC.
I tried to use git am <patch> but it fails with,
# git am ./test.patch Patch format detection failed.so I did git apply and tested.
Thanks for the testing.
Quoted 1 line
Henceforth I will use tabs for indentation.
We never officially decided on a bash coding standard (we should probably do that, as we have over 500 lines of bash now). Original files are spaces (or mostly, occasionally you'll find a tab...), but when I wrote a couple new bash files I used tabs, and scripts/arch-run.bash is one of those files. While tabs might not have been the right choice, I'd prefer that at least per file consistency is maintained.
Thanks,
drew
Quoted 68 lines
Regards,
BalaQuoted 62 lines · Andrew Jones
We use tabs in
scripts/arch-run.bash, which the import of the function forgot to convert to. Also, while touching all lines to add the tabs, apply some more cleanups and simplifications.Signed-off-by Andrew Jones <[email protected]>--- scripts/arch-run.bash | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-)scripts/arch-run.bash +18
-21@@ -134,27 +134,24 @@ migration_cmd () fi } -# qemu binary search function for all arches search_qemu_binary () { - local save_path=$PATH - local qemucmd QEMUFOUND qemu - export PATH=$PATH:/usr/libexec - for qemucmd in ${QEMU:-qemu-system-$ARCH_NAME qemu-kvm} - do - unset QEMUFOUND - unset qemu - if ! [ -z "${QEMUFOUND=$(${qemucmd} --help 2>/dev/null | grep "QEMU")}" ] - then - qemu="${qemucmd}" - break - fi - done - - if [ -z "${QEMUFOUND}" ]; then - echo "A QEMU binary was not found, You can set a custom location by using the QEMU=<path> environment variable" - exit 2 - fi - which $qemu - export PATH=$save_path + local save_path=$PATH + local qemucmd qemu + + export PATH=$PATH:/usr/libexec + for qemucmd in ${QEMU:-qemu-system-$ARCH_NAME qemu-kvm}; do + if $qemucmd --help 2>/dev/null | grep -q 'QEMU'; then + qemu="$qemucmd" + break + fi + done + + if [ -z "$qemu" ]; then + echo "A QEMU binary was not found." + echo "You can set a custom location by using the QEMU=<path> environment variable." + exit 2 + fi + command -v $qemu + export PATH=$save_path }Signature · 1 line
2.9.3
Quoted 12 lines · Andrew Jones
Quoted 8 lines · Balamuruhan S
It looks good and I have tested this patch in x86 and PowerPC.
I tried to use git am <patch> but it fails with,
# git am ./test.patch Patch format detection failed.so I did git apply and tested.
Thanks for the testing.
Quoted 8 lines
Quoted 1 line
Henceforth I will use tabs for indentation.
We never officially decided on a bash coding standard (we should probably do that, as we have over 500 lines of bash now). Original files are spaces (or mostly, occasionally you'll find a tab...), but when I wrote a couple new bash files I used tabs, and
scripts/arch-run.bashis one of those files. While tabs might not have been the right choice, I'd prefer that at least per file consistency is maintained.
Sure drew.
Thanks,
Bala
Quoted 73 lines
Thanks,
drewQuoted 68 lines
Regards,
BalaQuoted 62 lines · Andrew Jones
We use tabs in
scripts/arch-run.bash, which the import of the function forgot to convert to. Also, while touching all lines to add the tabs, apply some more cleanups and simplifications.Signed-off-by Andrew Jones <[email protected]>--- scripts/arch-run.bash | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-)scripts/arch-run.bash +18
-21@@ -134,27 +134,24 @@ migration_cmd () fi } -# qemu binary search function for all arches search_qemu_binary () { - local save_path=$PATH - local qemucmd QEMUFOUND qemu - export PATH=$PATH:/usr/libexec - for qemucmd in ${QEMU:-qemu-system-$ARCH_NAME qemu-kvm} - do - unset QEMUFOUND - unset qemu - if ! [ -z "${QEMUFOUND=$(${qemucmd} --help 2>/dev/null | grep "QEMU")}" ] - then - qemu="${qemucmd}" - break - fi - done - - if [ -z "${QEMUFOUND}" ]; then - echo "A QEMU binary was not found, You can set a custom location by using the QEMU=<path> environment variable" - exit 2 - fi - which $qemu - export PATH=$save_path + local save_path=$PATH + local qemucmd qemu + + export PATH=$PATH:/usr/libexec + for qemucmd in ${QEMU:-qemu-system-$ARCH_NAME qemu-kvm}; do + if $qemucmd --help 2>/dev/null | grep -q 'QEMU'; then + qemu="$qemucmd" + break + fi + done + + if [ -z "$qemu" ]; then + echo "A QEMU binary was not found." + echo "You can set a custom location by using the QEMU=<path> environment variable." + exit 2 + fi + command -v $qemu + export PATH=$save_path }Signature · 1 line
2.9.3
Quoted 5 lines · Andrew Jones
We use tabs in
scripts/arch-run.bash, which the import of the function forgot to convert to. Also, while touching all lines to add the tabs, apply some more cleanups and simplifications.Signed-off-by Andrew Jones <[email protected]>
Queued, thanks.
Paolo
Quoted 55 lines
--- scripts/arch-run.bash | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-)scripts/arch-run.bash +18
-21@@ -134,27 +134,24 @@ migration_cmd () fi } -# qemu binary search function for all arches search_qemu_binary () { - local save_path=$PATH - local qemucmd QEMUFOUND qemu - export PATH=$PATH:/usr/libexec - for qemucmd in ${QEMU:-qemu-system-$ARCH_NAME qemu-kvm} - do - unset QEMUFOUND - unset qemu - if ! [ -z "${QEMUFOUND=$(${qemucmd} --help 2>/dev/null | grep "QEMU")}" ] - then - qemu="${qemucmd}" - break - fi - done - - if [ -z "${QEMUFOUND}" ]; then - echo "A QEMU binary was not found, You can set a custom location by using the QEMU=<path> environment variable" - exit 2 - fi - which $qemu - export PATH=$save_path + local save_path=$PATH + local qemucmd qemu + + export PATH=$PATH:/usr/libexec + for qemucmd in ${QEMU:-qemu-system-$ARCH_NAME qemu-kvm}; do + if $qemucmd --help 2>/dev/null | grep -q 'QEMU'; then + qemu="$qemucmd" + break + fi + done + + if [ -z "$qemu" ]; then + echo "A QEMU binary was not found." + echo "You can set a custom location by using the QEMU=<path> environment variable." + exit 2 + fi + command -v $qemu + export PATH=$save_path }