From patchwork Fri Oct 26 14:15:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 10657419 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B5D415A7 for ; Fri, 26 Oct 2018 14:20:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 550982C7C1 for ; Fri, 26 Oct 2018 14:20:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 490412C7ED; Fri, 26 Oct 2018 14:20:38 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E7F5C2C7C1 for ; Fri, 26 Oct 2018 14:20:37 +0000 (UTC) Received: from localhost ([::1]:60338 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gG2yb-0005gP-6K for patchwork-qemu-devel@patchwork.kernel.org; Fri, 26 Oct 2018 10:20:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52148) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gG2u7-0001yR-JU for qemu-devel@nongnu.org; Fri, 26 Oct 2018 10:16:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gG2u6-00062x-Jm for qemu-devel@nongnu.org; Fri, 26 Oct 2018 10:15:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41406) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gG2u6-0005qV-9c for qemu-devel@nongnu.org; Fri, 26 Oct 2018 10:15:58 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2AEB088E4A; Fri, 26 Oct 2018 14:15:41 +0000 (UTC) Received: from magic.redhat.com (ovpn-116-212.ams2.redhat.com [10.36.116.212]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA3A5605FA; Fri, 26 Oct 2018 14:15:36 +0000 (UTC) From: Fam Zheng To: qemu-devel@nongnu.org Date: Fri, 26 Oct 2018 22:15:22 +0800 Message-Id: <20181026141529.4305-3-famz@redhat.com> In-Reply-To: <20181026141529.4305-1-famz@redhat.com> References: <20181026141529.4305-1-famz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 26 Oct 2018 14:15:41 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/9] tests/vm: Extract the kvm_available() handy function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20181013004034.6968-2-f4bug@amsat.org> Reviewed-by: Richard Henderson Signed-off-by: Fam Zheng --- scripts/qemu.py | 4 ++++ tests/vm/basevm.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/qemu.py b/scripts/qemu.py index f099ce7278..9fc0be4828 100644 --- a/scripts/qemu.py +++ b/scripts/qemu.py @@ -26,6 +26,10 @@ import tempfile LOG = logging.getLogger(__name__) +def kvm_available(target_arch=None): + return os.access("/dev/kvm", os.R_OK | os.W_OK) + + #: Maps machine types to the preferred console device types CONSOLE_DEV_TYPES = { r'^clipper$': 'isa-serial', diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index cafbc6b3a5..834bc90cc1 100755 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -18,7 +18,7 @@ import logging import time import datetime sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "scripts")) -from qemu import QEMUMachine +from qemu import QEMUMachine, kvm_available import subprocess import hashlib import optparse @@ -72,7 +72,7 @@ class BaseVM(object): "-serial", "file:%s" % os.path.join(self._tmpdir, "serial.out")] if vcpus: self._args += ["-smp", str(vcpus)] - if os.access("/dev/kvm", os.R_OK | os.W_OK): + if kvm_available(): self._args += ["-enable-kvm"] else: logging.info("KVM not available, not using -enable-kvm")