From patchwork Sun May 31 16:38:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 187344 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2341850ilb; Sun, 31 May 2020 09:51:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzV2CkraG88bUpgaHCl984rcGUnpiXHUwJ+B2bFIMyY3M4WmzGDfGglBVJDkHgacXC5GrT8 X-Received: by 2002:a25:83c1:: with SMTP id v1mr20509084ybm.280.1590943892072; Sun, 31 May 2020 09:51:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590943892; cv=none; d=google.com; s=arc-20160816; b=NlXr1F6iz/aJJ4dOFGJwnch3X5ST2zRYtik8T9KXZL+DIDU/O9CLbLdcj8EURw4b7B AF00mftjoDPgRbQyUMLAamIOYmrnRtJdUl5a4PJ8dpEgTrCUIg+SRu6K+cDfEsXjQ9QJ 6mc29DbSP6ngiAlkYruCkYmn7MKEDptxQFGDGOsQ/UUj+92HJ2lAKHn8ijRkV/oJjo+y 0TM7phN1C8eGVmy98OPNFGOd/8zevOJUXaJ3oBbMA1GnQx4vxfBX0+l6OThGuFXxDwJr 50Vq4OkIcalRJB3wUs3qP8lCzH93NETjJTsgV+hpA4RZJfBQzgi6DYnHte5lvp1Y0CDV WCPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=s8Rk2ct1SwmXVJV/wHXYbsX6rV3XnYQXBZW0Chu6BIg=; b=QJz8F+dTF/C/nalfbhK6kmlzc7RD7XpIllNC8MvfyLtjKxoDlrrBq0w//vxlqDZyDF d3md5CdK4yZ3FI9fe3OjtcS3aeT9NCi1mVioHCQYVs8TVLOdviOmVwV0ofgWJV3b6sh/ psUp7l9xla+Dc/+xoivBOvAX/xm6tvvXdnPmCIAIcWve5crzyKOTnWye6gYUbs+tOW6v T8UkK5iKYuk+OnnKqKvn5zUwvPpT6oXXNfNWn8utrt1/2Jwqi6bvqEl6Rj9llYGuvGNo O2fL3YX3O2AJa3/LqUt1xCiskLarycWhOXrtrWj5R93kP4BVgKpdyOKtCoGQ+znAp6cS /Hbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=fhf4PI9v; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b143si4243340ybg.70.2020.05.31.09.51.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 31 May 2020 09:51:32 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=fhf4PI9v; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:33146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jfRBL-0002vp-DX for patch@linaro.org; Sun, 31 May 2020 12:51:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jfR0m-0003fU-1C for qemu-devel@nongnu.org; Sun, 31 May 2020 12:40:36 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:46318 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jfR0h-00074l-MF for qemu-devel@nongnu.org; Sun, 31 May 2020 12:40:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590943230; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s8Rk2ct1SwmXVJV/wHXYbsX6rV3XnYQXBZW0Chu6BIg=; b=fhf4PI9vs31LS+Iorxow1wFT3sP1epGkjO9aNJLC/M80DKYrIFjn/+9HdF9s4TAEH5WGtq 9w67YAWh3r9qKmQNBay4nCzaev6+qPmmkH4Wz2fFHdtTgyABd1drMQeUljGAh5jZphjYyL fuHmNQ+bEVlfS6yyuw7Ee/0IRYurVLU= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-276-rwSre_RkM3u_yhMWRe1QpQ-1; Sun, 31 May 2020 12:40:27 -0400 X-MC-Unique: rwSre_RkM3u_yhMWRe1QpQ-1 Received: by mail-wr1-f71.google.com with SMTP id c14so3604197wrm.15 for ; Sun, 31 May 2020 09:40:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s8Rk2ct1SwmXVJV/wHXYbsX6rV3XnYQXBZW0Chu6BIg=; b=FAXGJek6jaDPCo0056xRg9/SufTADAbQJdcto7y+/pd1Taam6+A/JvR+TEl+nA+qQn TUCyfmO/WlLBHt7Q05l39Off7Y2gYIsda871n8+Z1qlsGc79obMfC3XKUvGcTBwie+eY xqrKtGvtpGKxGYzStKN7HjzwwBHdUVubzIAEPTPddMOmKzC+x3qEO+ZaqUAZinYfG8OA 3XpJEmJVv82EF2uXlm0MrD1OAOaKmuuNY1DKtRjUVRhKf35d+2xUDRcKZYKZcIlpKkUW 1SbawOF7nMHoGltahuCoV3L3SI+MKZCibnZfquAwQxEQzzpdzdG/mC9eLSQ1QmoUXgr0 r7NA== X-Gm-Message-State: AOAM531B2GVo/bsNITlEjnH9nhKDqjMDj3MqtXfiPPpqul6M84uyO4Fr ctocKF7I3rhTND3+F2klr1Nz16BIkJI1zKyjvxAnkToTuoIy5YELzUB9MdGQhwo/AQhmt8Dl8dD nRpiEtBLXf+9KzMY= X-Received: by 2002:adf:fb0f:: with SMTP id c15mr19211122wrr.410.1590943226362; Sun, 31 May 2020 09:40:26 -0700 (PDT) X-Received: by 2002:adf:fb0f:: with SMTP id c15mr19211104wrr.410.1590943226147; Sun, 31 May 2020 09:40:26 -0700 (PDT) Received: from localhost.localdomain (43.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.43]) by smtp.gmail.com with ESMTPSA id y25sm9023876wmi.2.2020.05.31.09.40.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 May 2020 09:40:25 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 19/25] tests/vm: Add ability to select QEMU from current build Date: Sun, 31 May 2020 18:38:40 +0200 Message-Id: <20200531163846.25363-20-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200531163846.25363-1-philmd@redhat.com> References: <20200531163846.25363-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=205.139.110.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/31 11:09:45 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , Robert Foley , Eduardo Habkost , kvm@vger.kernel.org, Peter Puhov , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Marcelo Tosatti , Markus Armbruster , Max Reitz , Stefan Hajnoczi , Cleber Rosa , Paolo Bonzini , qemu-block@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Robert Foley Added a new special variable QEMU_LOCAL=1, which will indicate to take the QEMU binary from the current build. Signed-off-by: Robert Foley Reviewed-by: Peter Puhov Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Message-Id: <20200529203458.1038-6-robert.foley@linaro.org> Signed-off-by: Philippe Mathieu-Daudé --- tests/vm/Makefile.include | 4 ++++ tests/vm/basevm.py | 28 +++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) -- 2.21.3 diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include index 80f7f6bdee..a253aba457 100644 --- a/tests/vm/Makefile.include +++ b/tests/vm/Makefile.include @@ -41,6 +41,7 @@ endif @echo " J=[0..9]* - Override the -jN parameter for make commands" @echo " DEBUG=1 - Enable verbose output on host and interactive debugging" @echo " V=1 - Enable verbose ouput on host and guest commands" + @echo " QEMU_LOCAL=1 - Use QEMU binary local to this build." @echo " QEMU=/path/to/qemu - Change path to QEMU binary" @echo " QEMU_IMG=/path/to/qemu-img - Change path to qemu-img tool" @@ -57,6 +58,7 @@ $(IMAGES_DIR)/%.img: $(SRC_PATH)/tests/vm/% \ $(PYTHON) $< \ $(if $(V)$(DEBUG), --debug) \ $(if $(GENISOIMAGE),--genisoimage $(GENISOIMAGE)) \ + $(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \ --image "$@" \ --force \ --build-image $@, \ @@ -71,6 +73,7 @@ vm-build-%: $(IMAGES_DIR)/%.img $(if $(DEBUG), --interactive) \ $(if $(J),--jobs $(J)) \ $(if $(V),--verbose) \ + $(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \ --image "$<" \ $(if $(BUILD_TARGET),--build-target $(BUILD_TARGET)) \ --snapshot \ @@ -92,6 +95,7 @@ vm-boot-ssh-%: $(IMAGES_DIR)/%.img $(PYTHON) $(SRC_PATH)/tests/vm/$* \ $(if $(J),--jobs $(J)) \ $(if $(V)$(DEBUG), --debug) \ + $(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \ --image "$<" \ --interactive \ false, \ diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index a2d4054d72..5a3ce42281 100644 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -61,9 +61,11 @@ class BaseVM(object): # 4 is arbitrary, but greater than 2, # since we found we need to wait more than twice as long. tcg_ssh_timeout_multiplier = 4 - def __init__(self, debug=False, vcpus=None, genisoimage=None): + def __init__(self, debug=False, vcpus=None, genisoimage=None, + build_path=None): self._guest = None self._genisoimage = genisoimage + self._build_path = build_path self._tmpdir = os.path.realpath(tempfile.mkdtemp(prefix="vm-test-", suffix=".tmp", dir=".")) @@ -184,15 +186,15 @@ def boot(self, img, extra_args=[]): "-device", "virtio-blk,drive=drive0,bootindex=0"] args += self._data_args + extra_args logging.debug("QEMU args: %s", " ".join(args)) - qemu_bin = os.environ.get("QEMU", "qemu-system-" + self.arch) - guest = QEMUMachine(binary=qemu_bin, args=args) + qemu_path = get_qemu_path(self.arch, self._build_path) + guest = QEMUMachine(binary=qemu_path, args=args) guest.set_machine('pc') guest.set_console() try: guest.launch() except: logging.error("Failed to launch QEMU, command line:") - logging.error(" ".join([qemu_bin] + args)) + logging.error(" ".join([qemu_path] + args)) logging.error("Log:") logging.error(guest.get_log()) logging.error("QEMU version >= 2.10 is required") @@ -391,6 +393,19 @@ def gen_cloud_init_iso(self): return os.path.join(cidir, "cloud-init.iso") +def get_qemu_path(arch, build_path=None): + """Fetch the path to the qemu binary.""" + # If QEMU environment variable set, it takes precedence + if "QEMU" in os.environ: + qemu_path = os.environ["QEMU"] + elif build_path: + qemu_path = os.path.join(build_path, arch + "-softmmu") + qemu_path = os.path.join(qemu_path, "qemu-system-" + arch) + else: + # Default is to use system path for qemu. + qemu_path = "qemu-system-" + arch + return qemu_path + def parse_args(vmcls): def get_default_jobs(): @@ -421,6 +436,9 @@ def get_default_jobs(): help="build QEMU from source in guest") parser.add_option("--build-target", help="QEMU build target", default="check") + parser.add_option("--build-path", default=None, + help="Path of build directory, "\ + "for using build tree QEMU binary. ") parser.add_option("--interactive", "-I", action="store_true", help="Interactively run command") parser.add_option("--snapshot", "-s", action="store_true", @@ -439,7 +457,7 @@ def main(vmcls): logging.basicConfig(level=(logging.DEBUG if args.debug else logging.WARN)) vm = vmcls(debug=args.debug, vcpus=args.jobs, - genisoimage=args.genisoimage) + genisoimage=args.genisoimage, build_path=args.build_path) if args.build_image: if os.path.exists(args.image) and not args.force: sys.stderr.writelines(["Image file exists: %s\n" % args.image,