diff mbox

x86-run: Print a meaningful message if the qemu binary isn't found

Message ID jpg384j1rkm.fsf@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bandan Das April 1, 2015, 9:12 p.m. UTC
Before:
./x86-run ./x86/msr.flat
QEMU binary has no support for test device. Exiting.

After:
./x86-run ./x86/msr.flat
A QEMU binary was not found, You can set a custom
location by using the QEMU=<path> environment variable

Signed-off-by: Bandan Das <bsd@redhat.com>
---
 x86/run | 37 ++++++++++++++++++++++++++-----------
 1 file changed, 26 insertions(+), 11 deletions(-)

Comments

Paolo Bonzini April 2, 2015, 12:47 p.m. UTC | #1
On 01/04/2015 23:12, Bandan Das wrote:
> 
> Before:
> ./x86-run ./x86/msr.flat
> QEMU binary has no support for test device. Exiting.
> 
> After:
> ./x86-run ./x86/msr.flat
> A QEMU binary was not found, You can set a custom
> location by using the QEMU=<path> environment variable
> 
> Signed-off-by: Bandan Das <bsd@redhat.com>
> ---
>  x86/run | 37 ++++++++++++++++++++++++++-----------
>  1 file changed, 26 insertions(+), 11 deletions(-)
> 
> diff --git a/x86/run b/x86/run
> index af37eb4..d5adf8d 100755
> --- a/x86/run
> +++ b/x86/run
> @@ -1,20 +1,35 @@
>  #!/bin/bash
> +NOTFOUND=1
> +TESTDEVNOTSUPP=2
>  
>  qemukvm="${QEMU:-qemu-kvm}"
>  qemusystem="${QEMU:-qemu-system-x86_64}"
> -if
> -	${qemukvm} -device '?' 2>&1 | grep -F -e \"testdev\" -e \"pc-testdev\" > /dev/null;
> +
> +if      ! [ -z "${QEMU}" ]
>  then
> -	qemu="${qemukvm}"
> +	qemu="${QEMU}"
>  else
> -	if
> -		${qemusystem} -device '?' 2>&1 | grep -F -e \"testdev\" -e \"pc-testdev\" > /dev/null;
> -	then
> -		qemu="${qemusystem}"
> -	else
> -		echo QEMU binary ${QEMU} has no support for test device. Exiting.
> -		exit 2
> -	fi
> +	for qemucmds in ${qemukvm} ${qemusystem}
> +	do
> +		unset QEMUFOUND
> +		unset qemu
> +		if ! [ -z "${QEMUFOUND=$(${qemucmds} --help 2>/dev/null | grep "QEMU")}" ] &&
> +		       ${qemucmds} -device '?' 2>&1 | grep -F -e \"testdev\" -e \"pc-testdev\" > /dev/null;
> +		then
> +		    qemu="${qemucmds}"
> +		    break
> +		fi
> +	done
> +fi
> +
> +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 ${NOTFOUND}
> +elif    [ -z "${qemu}" ]
> +then
> +	echo "No Qemu test device support found"
> +	exit ${TESTDEVNOTSUPP}
>  fi
>  
>  if
> 

Thanks, applied.

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/x86/run b/x86/run
index af37eb4..d5adf8d 100755
--- a/x86/run
+++ b/x86/run
@@ -1,20 +1,35 @@ 
 #!/bin/bash
+NOTFOUND=1
+TESTDEVNOTSUPP=2
 
 qemukvm="${QEMU:-qemu-kvm}"
 qemusystem="${QEMU:-qemu-system-x86_64}"
-if
-	${qemukvm} -device '?' 2>&1 | grep -F -e \"testdev\" -e \"pc-testdev\" > /dev/null;
+
+if      ! [ -z "${QEMU}" ]
 then
-	qemu="${qemukvm}"
+	qemu="${QEMU}"
 else
-	if
-		${qemusystem} -device '?' 2>&1 | grep -F -e \"testdev\" -e \"pc-testdev\" > /dev/null;
-	then
-		qemu="${qemusystem}"
-	else
-		echo QEMU binary ${QEMU} has no support for test device. Exiting.
-		exit 2
-	fi
+	for qemucmds in ${qemukvm} ${qemusystem}
+	do
+		unset QEMUFOUND
+		unset qemu
+		if ! [ -z "${QEMUFOUND=$(${qemucmds} --help 2>/dev/null | grep "QEMU")}" ] &&
+		       ${qemucmds} -device '?' 2>&1 | grep -F -e \"testdev\" -e \"pc-testdev\" > /dev/null;
+		then
+		    qemu="${qemucmds}"
+		    break
+		fi
+	done
+fi
+
+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 ${NOTFOUND}
+elif    [ -z "${qemu}" ]
+then
+	echo "No Qemu test device support found"
+	exit ${TESTDEVNOTSUPP}
 fi
 
 if