From patchwork Wed Jun 24 14:04:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 191660 Delivered-To: patch@linaro.org Received: by 2002:a92:1f07:0:0:0:0:0 with SMTP id i7csp627269ile; Wed, 24 Jun 2020 07:08:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9qBOcEkLBBDvVesLGONVw8GUTMVuYY80Sebcjm45YjicxrGM6lMG0w0QwVbCHP8gwmIZz X-Received: by 2002:a5b:b49:: with SMTP id b9mr40608553ybr.343.1593007699539; Wed, 24 Jun 2020 07:08:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593007699; cv=none; d=google.com; s=arc-20160816; b=RGVD55yM7z+p965GVzXagLHQEiv+3fisvCdfMNII/VWcFJ/xedi3/DOa/n5qO86Ckc qZBBDY4O4skOLH70RUcxMpzlkL3nOHdNf6JDFNIFnFf6kfhyQNmTZU6ECcRDQwS+S0qO 9+L6ELEmQQ4qyx9UkjRkKtAu/NmY98MgTJFj4KwQ8Ahegk5ZtFfkY4Q9QWyLIt7JAQkk SvhG0qrqel6rKFTZn9YMZ1TofMObOwkInbY0gp2xXwoVqdH/bIFfip7VduojRjRCV0YE d5hDR5E+hcu414cxVCKDh9LXeqi3S8JzpplDas2Pplkhif00CsfZJbiHAKLxgM5whvRF vo6Q== 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=5xSn2L6kzBKcKjTR8zPwxbT757SBhdGuGZ/3k/jBdz8=; b=IrE/iIL+9eieVv9wfV+hC+M9ATaVnxfpa0YjmFlsxm35u5jbG06FqYCd+ws5VVmxNm Eu206NoCozXuGmbWU9tEQnmoLJnOA65nGKrvczv7AOvTkQTp6xK2hRyA4fFJdNXmYloz hg2tVxrfP6nno7PYXYhg93RLfIbHzq6SXgl+RR+xuQq46rcMNVqNomXsQiIOzZ9Azivf yWJ7F6czTrCyuRXe0RWuhrdf2hXfiwsFqb1utVLVMfixWaL8G5v9hzYWERDb06Rb1AAN GH3j9BRUA/J6l1sSWotps/R2GJYODM01UTQnnEqQgeZUNZFBdruHSGhT9KX5eUPvytBG D9qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="stLkwgi/"; 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=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e70si19609381yba.125.2020.06.24.07.08.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Jun 2020 07:08:19 -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=@linaro.org header.s=google header.b="stLkwgi/"; 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=linaro.org Received: from localhost ([::1]:47292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jo64Y-0003yN-UW for patch@linaro.org; Wed, 24 Jun 2020 10:08:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jo61N-0004vS-8D for qemu-devel@nongnu.org; Wed, 24 Jun 2020 10:05:01 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:55384) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jo61K-0003VM-9j for qemu-devel@nongnu.org; Wed, 24 Jun 2020 10:05:00 -0400 Received: by mail-wm1-x343.google.com with SMTP id g75so2435444wme.5 for ; Wed, 24 Jun 2020 07:04:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5xSn2L6kzBKcKjTR8zPwxbT757SBhdGuGZ/3k/jBdz8=; b=stLkwgi/ueBYCoZNMDFasbFrfEB3RKeBudIM3YKlcDrgHLPWVWK5ouOMmNfFSV48ks BtxR1AZMtI+btE5adAcEOuOi0b8DTaTc77DS1QCuLlPU4Wd2Zs82XGRynnbNdC5pnK5w XXLmc/W+8VhXcPlsGKu+l6cyNVDFqe/py6JwzEkrVQKo8IUup2p4/0mACMFtZldUnj1r 9uCKIXIe8WldmyPrQ84vipeC5PIOf1HusiRaC7r5ZZSfdbhj9KGbJ5DY8RgV9fRK3va9 /fmx3iQRRHevyNzzkkixTIyKqwgAUOkhzMjmzwu7VL5llfOu7VW7Y9NHvXJ6sRHYUVyk OKlg== 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=5xSn2L6kzBKcKjTR8zPwxbT757SBhdGuGZ/3k/jBdz8=; b=GgXD8M8fALajjj2Z7Jh1UMqy0ceRVlqb6Akqr5R5+EoxGlFmlIXMa9X2fHljYFkpCn 132ezZodOEzFqgYdGg18azhBtitv02UzggXQ6mHnYqY9S9BLFqfq5DXRkSfm6JT3dhUA nhuysq+6WBF/i46JcPwJfsJHmLJnEBlLNO+6N1OJ4S25jN1LauziHXfHgOM+HF7+3hTo bRA35SN5D3CThV9zuQYT//fnFuXafUsQkxqTB6lsMFvSG8exURjPZqiD8ZRnAKNgGdC5 Y9x3RjrjaF8b6pCR0c/+OXoVIDu7kWPIWDv5tiF6WpEbisRK547vtM7bbFqT9VOQZZd1 X4zA== X-Gm-Message-State: AOAM532wUJLQ0kaKDh1+Ib/FVu5+gpH9dVwOKmMh+Jn+jit0ohIimGAa 7Xt1GWO8DOWptOPi+khJyqAhcw== X-Received: by 2002:a1c:e209:: with SMTP id z9mr5757339wmg.153.1593007496890; Wed, 24 Jun 2020 07:04:56 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id n5sm3827122wmi.34.2020.06.24.07.04.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 07:04:56 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 568931FF9A; Wed, 24 Jun 2020 15:04:47 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 11/25] tests/vm: Add workaround to consume console Date: Wed, 24 Jun 2020 15:04:32 +0100 Message-Id: <20200624140446.15380-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200624140446.15380-1-alex.bennee@linaro.org> References: <20200624140446.15380-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::343; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x343.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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: fam@euphon.net, berrange@redhat.com, Robert Foley , =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, f4bug@amsat.org, =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= , cota@braap.org, Peter Puhov , aurelien@aurel32.net Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Robert Foley This adds support to basevm.py so that we always drain the console chars. This makes use of support added in an earlier commit that allows QEMUMachine to use the ConsoleSocket. This is a workaround we found was needed since there is a known issue where QEMU will hang waiting for console characters to be consumed. We also added the option of logging the console to a file. LOG_CONSOLE=1 will now log the output to a file. Signed-off-by: Robert Foley Reviewed-by: Peter Puhov Acked-by: Alex Bennée Signed-off-by: Alex Bennée Message-Id: <20200601211421.1277-10-robert.foley@linaro.org> --- tests/vm/Makefile.include | 4 ++++ tests/vm/basevm.py | 21 +++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include index 39f918a430a..f21948c46a5 100644 --- a/tests/vm/Makefile.include +++ b/tests/vm/Makefile.include @@ -49,6 +49,7 @@ endif @echo ' EXTRA_CONFIGURE_OPTS="..."' @echo " J=[0..9]* - Override the -jN parameter for make commands" @echo " DEBUG=1 - Enable verbose output on host and interactive debugging" + @echo " LOG_CONSOLE=1 - Log console to file in: ~/.cache/qemu-vm " @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" @@ -75,6 +76,7 @@ $(IMAGES_DIR)/%.img: $(SRC_PATH)/tests/vm/% \ $(if $(GENISOIMAGE),--genisoimage $(GENISOIMAGE)) \ $(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \ $(if $(EFI_AARCH64),--efi-aarch64 $(EFI_AARCH64)) \ + $(if $(LOG_CONSOLE),--log-console) \ --image "$@" \ --force \ --build-image $@, \ @@ -91,6 +93,7 @@ vm-build-%: $(IMAGES_DIR)/%.img $(if $(V),--verbose) \ $(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \ $(if $(EFI_AARCH64),--efi-aarch64 $(EFI_AARCH64)) \ + $(if $(LOG_CONSOLE),--log-console) \ --image "$<" \ $(if $(BUILD_TARGET),--build-target $(BUILD_TARGET)) \ --snapshot \ @@ -114,6 +117,7 @@ vm-boot-ssh-%: $(IMAGES_DIR)/%.img $(if $(V)$(DEBUG), --debug) \ $(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \ $(if $(EFI_AARCH64),--efi-aarch64 $(EFI_AARCH64)) \ + $(if $(LOG_CONSOLE),--log-console) \ --image "$<" \ --interactive \ false, \ diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index f716798b405..04d083409a5 100644 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -117,6 +117,11 @@ class BaseVM(object): "w").write(self._config['ssh_pub_key']) self.debug = args.debug + self._console_log_path = None + if args.log_console: + self._console_log_path = \ + os.path.join(os.path.expanduser("~/.cache/qemu-vm"), + "{}.install.log".format(self.name)) self._stderr = sys.stderr self._devnull = open(os.devnull, "w") if self.debug: @@ -271,7 +276,13 @@ class BaseVM(object): args += self._data_args + extra_args + self._config['extra_args'] logging.debug("QEMU args: %s", " ".join(args)) qemu_path = get_qemu_path(self.arch, self._build_path) - guest = QEMUMachine(binary=qemu_path, args=args) + + # Since console_log_path is only set when the user provides the + # log_console option, we will set drain_console=True so the + # console is always drained. + guest = QEMUMachine(binary=qemu_path, args=args, + console_log=self._console_log_path, + drain_console=True) guest.set_machine(self._config['machine']) guest.set_console() try: @@ -285,6 +296,8 @@ class BaseVM(object): raise atexit.register(self.shutdown) self._guest = guest + # Init console so we can start consuming the chars. + self.console_init() usernet_info = guest.qmp("human-monitor-command", command_line="info usernet") self.ssh_port = None @@ -296,7 +309,9 @@ class BaseVM(object): raise Exception("Cannot find ssh port from 'info usernet':\n%s" % \ usernet_info) - def console_init(self, timeout = 120): + def console_init(self, timeout = None): + if timeout == None: + timeout = self.socket_timeout vm = self._guest vm.console_socket.settimeout(timeout) self.console_raw_path = os.path.join(vm._temp_dir, @@ -578,6 +593,8 @@ def parse_args(vmcls): parser.add_option("--efi-aarch64", default="/usr/share/qemu-efi-aarch64/QEMU_EFI.fd", help="Path to efi image for aarch64 VMs.") + parser.add_option("--log-console", action="store_true", + help="Log console to file.") parser.disable_interspersed_args() return parser.parse_args()