From patchwork Fri Apr 21 11:07:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 9692479 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 468B360328 for ; Fri, 21 Apr 2017 11:07:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3694827FC0 for ; Fri, 21 Apr 2017 11:07:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B1C728607; Fri, 21 Apr 2017 11:07:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98B1F2861F for ; Fri, 21 Apr 2017 11:07:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1038461AbdDULHt (ORCPT ); Fri, 21 Apr 2017 07:07:49 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:33767 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1038323AbdDULHa (ORCPT ); Fri, 21 Apr 2017 07:07:30 -0400 Received: by mail-wm0-f66.google.com with SMTP id o81so4228465wmb.0 for ; Fri, 21 Apr 2017 04:07:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=nhetnz87BvnF8ZvyBIjtX7B0rQWRc9cNRr1LqSLC7vo=; b=Qpw9cVmTiAExOpt1D4L7rJsP7bZjv7OVwTFVhiJ4sCUsqPGlxHJVhARRo7Xj3zBer7 qNpskKfBM7q1suRxUrq8ChM6XcoktFbtYJ3STkSTRur050/TOhx0yc0GqN/wQmMhyu0j E2O3rZZ+USa0ZE/QDQiXJz6qQXsjv+XY+GLNU26qBUx4vz67sJa+8Iafh8W3ClcVSf0n mojMU5Sb1Qs8npGN6nv2sPtCThTkF5c+Nijn0URiqOKbYpokRlyFbisblMQyMtNzkJ/I CqGwBaxMfeucDeaRhP5slqXYrddpVg9TX+nHB61lfw3HAIHZSfTMHTILAQtmPWq8qo7u lfiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:references:cc:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=nhetnz87BvnF8ZvyBIjtX7B0rQWRc9cNRr1LqSLC7vo=; b=CWqlQa2pHz1+mnb32VhyWm4q0+hq+brGiHCwUf2qY+pI9qkkhKp8B3QYzgskZIYa2e RTYvOBI4nBMFuLkZH8/3TG7eUGMPvmqvopnouOVWvnTsV2IVWLk8KSfxWzKy9NFydhQp 3KoBE/9n9u7YzMWEy7dQTqhAC+h+NR+jgVacD2C2CCX+ujGOifkzTLfBPnqn5ulIrumw cQ8yXQHq+HO4iRCyuc8k9557cS4j4AcJ/oT2BTOFYGfoSP6zCOfN5irswBCCL4xZKbmg 3o8WtWLRvj+AbCwQRGJ19DBNe0Cb7OoKu4XFrmnAnv4urNpXDqHjneKtxsXPoY6F65bH oNyA== X-Gm-Message-State: AN3rC/52g4q4y35FMsgJTnx1+LLXSRLdKzFbLzLqN6WHUNtkoq3gjxCW 9yVGgzzdYpTEPw== X-Received: by 10.28.143.135 with SMTP id r129mr7206084wmd.54.1492772848386; Fri, 21 Apr 2017 04:07:28 -0700 (PDT) Received: from [192.168.10.165] (94-39-149-222.adsl-ull.clienti.tiscali.it. [94.39.149.222]) by smtp.googlemail.com with ESMTPSA id o9sm1598827wmd.4.2017.04.21.04.07.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Apr 2017 04:07:26 -0700 (PDT) Subject: Re: [kvm-unit-tests PATCH 1/4] scripts/arch-run: function to search qemu binary To: Balamuruhan S , kvm@vger.kernel.org References: <1492629251-23267-1-git-send-email-bala24@linux.vnet.ibm.com> Cc: drjones@redhat.com From: Paolo Bonzini Message-ID: <23638b58-5c0c-6f7c-1ffe-c8a918f6a14b@redhat.com> Date: Fri, 21 Apr 2017 13:07:25 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1492629251-23267-1-git-send-email-bala24@linux.vnet.ibm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Series applied with some cleanups: On 19/04/2017 21:14, Balamuruhan S wrote: > qemu_binary function to seach qemu binary similar to x86/run does > so that it can be reused for all arches > > Signed-off-by: Balamuruhan S > --- > scripts/arch-run.bash | 22 ++++++++++++++++++++++ > 1 file changed, 22 insertions(+) > > diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash > index 94c50f3..404a4c0 100644 > --- a/scripts/arch-run.bash > +++ b/scripts/arch-run.bash > @@ -133,3 +133,25 @@ migration_cmd () > echo "run_migration" > fi > } > + > +# qemu binary search function for all arches > +qemu_binary () > +{ > + PATH=$PATH:/usr/libexec > + qemubinarysearch="${QEMU:-qemu-system-$ARCH_NAME qemu-kvm}" > + for qemucmd in ${qemubinarysearch} > + 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= environment variable" > + exit 2 > + fi > +} > diff --git a/arm/run b/arm/run index 696228e..bae43fd 100755 --- a/arm/run +++ b/arm/run @@ -31,13 +31,10 @@ if [ -z "$ACCEL" ]; then fi fi -# qemu_binary () defined in scripts/arch-run.bash -qemu_binary - -qpath=$(which $qemu 2>/dev/null) +qemu=$(search_qemu_binary) if ! $qemu -machine '?' 2>&1 | grep 'ARM Virtual Machine' > /dev/null; then - echo "$qpath doesn't support mach-virt ('-machine virt'). Exiting." + echo "$qemu doesn't support mach-virt ('-machine virt'). Exiting." exit 2 fi @@ -56,13 +53,13 @@ if [ "$ACCEL" = "kvm" ]; then fi if ! $qemu $M -device '?' 2>&1 | grep virtconsole > /dev/null; then - echo "$qpath doesn't support virtio-console for chr-testdev. Exiting." + echo "$qemu doesn't support virtio-console for chr-testdev. Exiting." exit 2 fi if $qemu $M -chardev testdev,id=id -initrd . 2>&1 \ | grep backend > /dev/null; then - echo "$qpath doesn't support chr-testdev. Exiting." + echo "$qemu doesn't support chr-testdev. Exiting." exit 2 fi diff --git a/powerpc/run b/powerpc/run index 4302fe2..69d2b53 100755 --- a/powerpc/run +++ b/powerpc/run @@ -28,13 +28,10 @@ if [ -z "$ACCEL" ]; then fi fi -# qemu_binary () defined in scripts/arch-run.bash -qemu_binary - -qpath=$(which $qemu 2>/dev/null) +qemu=$(search_qemu_binary) if ! $qemu -machine '?' 2>&1 | grep 'pseries' > /dev/null; then - echo "$qpath doesn't support pSeries ('-machine pseries'). Exiting." + echo "$qemu doesn't support pSeries ('-machine pseries'). Exiting." exit 2 fi diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash index 404a4c0..fb5fd7d 100644 --- a/scripts/arch-run.bash +++ b/scripts/arch-run.bash @@ -135,11 +135,12 @@ migration_cmd () } # qemu binary search function for all arches -qemu_binary () +search_qemu_binary () { - qemubinarysearch="${QEMU:-qemu-system-$ARCH_NAME qemu-kvm}" - for qemucmd in ${qemubinarysearch} + PATH=$PATH:/usr/libexec + 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 @@ -154,4 +155,6 @@ qemu_binary () echo "A QEMU binary was not found, You can set a custom location by using the QEMU= environment variable" exit 2 fi + which $qemu + export PATH=$save_path } diff --git a/x86/run b/x86/run index eebfef9..b4db2a9 100755 --- a/x86/run +++ b/x86/run @@ -2,8 +2,7 @@ [ -z "$STANDALONE" ] && source scripts/arch-run.bash -# qemu_binary () defined in scripts/arch-run.bash -qemu_binary +qemu=$(search_qemu_binary) if ! ${qemu} -device '?' 2>&1 | grep -F -e \"testdev\" -e \"pc-testdev\" > /dev/null; then