From patchwork Fri May 29 20:34:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187321 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp928479ilb; Fri, 29 May 2020 13:43:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJndv6L/kr7AD6dv1Fhwho0thQjooeezqtNeRCy5UPI86SQTsxWoeRq6NzDY9Tm8D2rltu X-Received: by 2002:a5b:f4d:: with SMTP id y13mr17773344ybr.50.1590785028499; Fri, 29 May 2020 13:43:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590785028; cv=none; d=google.com; s=arc-20160816; b=ZVjAU8w8aApqR8HfvhEgBgqkT81jVErgClDmmCHLuWjtu75fIsAaX91+EMbnjqieHh h+bL7ekl59V56zRE8aVRW26HN+K33z+iHKdqTR9CLRNnFG0JJHGieAvTJOkcnVlVwUyT Zi6n32O6bCIrKyYPKidlQkDvNFfuqgI4mED4rnIBRRUoto0h2IOF0NZvgR0eTE9ne3K3 vUcXl7plJqbcJlbTuXY3j6JLT8dEEntWMs7Q/3TfZTIUNHvlXx7tS0K7auWNmnBbWqI2 oy5VDQuPIuQTRFC1Z0kXEcGVvWS6WlXgLuYAGoNTY1lvPwYpo8BuS3NPc/gM6DLhEu6V 8B8Q== 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=w1W80LI37XifJiBdMXsN+sad+Phr9kWINJYefaK6VIg=; b=MzDzm6jEZrdIzjsYRSYDsWicvlxZCXfBdk1SeukhYYBdfETSz5VepcNHVgh79/vr5Y P0rq3TdQ9FLVRcdgfYNNp2WLF9BhY13euuzDOTBwQc26nqB3AyWcYPuJWPgTMu3wSNaT yn4NECzZwW7rgqoLRJJp+Yw8bxiDx59Xq1HyavcdunGHt30zhuSN8WdRxPEM6Yf8VXvb pQznXFK8rgTDGAe09GUNzQNzjAiHZmMtsUEZoE05ZAzXbXG5TBjVrdlcwsLW7XHDSzSq NM846oneBdKgidQEg8+FdhuJiVvdnZygKvNT9cApyatCq1YH23j6w37gQlQaKGypuGgL 0f0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="YIFsw/93"; 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 x8si8737361ybl.28.2020.05.29.13.43.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 May 2020 13:43:48 -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="YIFsw/93"; 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]:38902 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jelr1-0006Ay-Vb for patch@linaro.org; Fri, 29 May 2020 16:43:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jelqX-0005hX-43 for qemu-devel@nongnu.org; Fri, 29 May 2020 16:43:18 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]:35677) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jelqV-0000e7-S3 for qemu-devel@nongnu.org; Fri, 29 May 2020 16:43:16 -0400 Received: by mail-pl1-x62b.google.com with SMTP id q16so1705757plr.2 for ; Fri, 29 May 2020 13:43:15 -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=w1W80LI37XifJiBdMXsN+sad+Phr9kWINJYefaK6VIg=; b=YIFsw/933SZGKHjIxCRowbAJrjVgXRPOYxhX6ZRqwZ8uZ7cZxDC2y2f6LVKf39hU+6 wI+VBa6CtG4f2xT++AlnSDuSq0Opp7KvccvCVOmhjqYbcfT/Eo1wuV7vnfpXN2QIDVdu CT4UooXQULl/y9Un94ZTYsgisJxz4Uvh1NemLeRMATbzB++P8AVyFEJZJ6xB+XYCaXJK L8ImYoqEJC+xRv2tkitiz7bwQ3REGTzcei9ZHKBAd/dPxI7RhqsS6ctMOFfLlRGlXriN kJVdSGmHDgrEZmnQOXZR03qAD91LWqWPdt+V0sw7xziI6IeMiDOFr2LlfdX5ylycCU5A heoQ== 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=w1W80LI37XifJiBdMXsN+sad+Phr9kWINJYefaK6VIg=; b=f0CUAfFL+Vb6oaDQOaDxsv3cyFYJh5k+wB8Fjw9n25L63nAzYGBTfO6RnJevYQsXdS L9vgI1A+oiBoKuMfystKPqRVfiO7WBsNy2kj2/5Wy7BH0W0NeuPk+UoEZOylEpdpubH4 cluXMTucWqzj1bQBPUuiW6M36w5+mpKqSRdRq7G47OlyklK7BtikaU3yU5U/QWpL0Tax fQ/vKDIKFdxNTvm9KZ9/LDDB+Tm6zweVmQhe7NGyDFFwTB90mUMQESBI1OdIDKXtot2z z0sIRPZj+/Pw3P2547equXC9+LL7LejEJqzVVk6rGByyiGHwCfuzoQcHndERf9ABvIW4 KcxQ== X-Gm-Message-State: AOAM5330vTMx8/gpa3ChSX0oDPcXrQl38dQIJTXaMG6O/LxaPTbEiX0m rGH7w2ETD18N5WHsRpyVHhZRhR2pS5y34A== X-Received: by 2002:a17:902:6b4b:: with SMTP id g11mr10668820plt.9.1590784994156; Fri, 29 May 2020 13:43:14 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:75ac:d268:da04:dde4]) by smtp.gmail.com with ESMTPSA id t12sm282839pjf.3.2020.05.29.13.43.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2020 13:43:13 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v8 01/12] tests/vm: pass args through to BaseVM's __init__ Date: Fri, 29 May 2020 16:34:47 -0400 Message-Id: <20200529203458.1038-2-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200529203458.1038-1-robert.foley@linaro.org> References: <20200529203458.1038-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=robert.foley@linaro.org; helo=mail-pl1-x62b.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_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 Zheng , philmd@redhat.com, alex.bennee@linaro.org, robert.foley@linaro.org, peter.puhov@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Adding the args parameter to BaseVM's __init__. We will shortly need to pass more parameters to the class so let's just pass args rather than growing the parameter list. Signed-off-by: Robert Foley Reviewed-by: Alex Bennée --- tests/vm/basevm.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) -- 2.17.1 Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index a2d4054d72..fbefda0595 100644 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -61,9 +61,9 @@ 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, args): self._guest = None - self._genisoimage = genisoimage + self._genisoimage = args.genisoimage self._tmpdir = os.path.realpath(tempfile.mkdtemp(prefix="vm-test-", suffix=".tmp", dir=".")) @@ -76,7 +76,7 @@ class BaseVM(object): self._ssh_pub_key_file = os.path.join(self._tmpdir, "id_rsa.pub") open(self._ssh_pub_key_file, "w").write(SSH_PUB_KEY) - self.debug = debug + self.debug = args.debug self._stderr = sys.stderr self._devnull = open(os.devnull, "w") if self.debug: @@ -90,8 +90,8 @@ class BaseVM(object): (",ipv6=no" if not self.ipv6 else ""), "-device", "virtio-net-pci,netdev=vnet", "-vnc", "127.0.0.1:0,to=20"] - if vcpus and vcpus > 1: - self._args += ["-smp", "%d" % vcpus] + if args.jobs and args.jobs > 1: + self._args += ["-smp", "%d" % args.jobs] if kvm_available(self.arch): self._args += ["-enable-kvm"] else: @@ -438,8 +438,7 @@ def main(vmcls): return 1 logging.basicConfig(level=(logging.DEBUG if args.debug else logging.WARN)) - vm = vmcls(debug=args.debug, vcpus=args.jobs, - genisoimage=args.genisoimage) + vm = vmcls(args) if args.build_image: if os.path.exists(args.image) and not args.force: sys.stderr.writelines(["Image file exists: %s\n" % args.image, From patchwork Fri May 29 20:34:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187322 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp929345ilb; Fri, 29 May 2020 13:45:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydu689mTITNbVWYuL+sTSi2wQVuvTj3dGmvykW89qPxOaGxxwOBg1U/lJl0GyjnFvOPuuv X-Received: by 2002:a25:db06:: with SMTP id g6mr15226303ybf.401.1590785120318; Fri, 29 May 2020 13:45:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590785120; cv=none; d=google.com; s=arc-20160816; b=qcVtcT3iXRtb7DF1CtS9bs2gkgojvA2UIJKOEuUB1vzvri6wOlesy8pirl6gEzDm96 tAt6jn2czSV6Du8p6j9do2lqJ0QzNdtUln0SD3g02+YEvR2UwO1GwYUxe/5h1qBoc1za k8cbrb1IleI+lvx5n4sQU/fSdID1I2ReW7F5T+js4cdXznh8Tg95tOuC71dyqPe47LkB WAqSqUREhwHxDS5MlM4mlLmtoYjq0iyCpU66ngRGWXIhD7mmKNBAjy+y2tRcxZyuUK/1 YFvvWWf+0//MDdvvjCg+X+WfeyhlxE/g2gxXKe0HHNZY3fvy11X3SKecH+NR3Q4lpd3z ah5g== 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=8yFiq7oj5Jysxn79LgqzGqasvEs+ukSRcPl37MjQOiQ=; b=t/cM27C+rjkEUgjAQKTwA9AHj5UG9dSjtOx+O/81cK2v914jepy8AA9aDtwhYEtw71 qljI/0C61Tk6U/mzsn1sCbqU1jkSjsGKD5dfcXvv1e/KTKckY2OuPMBpWnU6wdeHaTtF B6J89XeC+3V5RkwZwOCUEIUJzYchNkhp8PwsEnfCBw9CLZcqVCRcjtGOE1NDhDBMBy+j UcwWHDpV7gVXR0xc0GubE0bYBfJC1i/Ax41vep5FIZtbh//67dW6HuYMZ1JxnvvxrO/L AbBXkFWqPcaY4Q8tNiUz9c7KuR9wQg5ppqyJM0GCZNwEQOhF6hdhA+tAhB0KI5h03aHm jH6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bPypazbt; 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 p198si3000523yba.481.2020.05.29.13.45.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 May 2020 13:45:20 -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=bPypazbt; 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]:45024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jelsV-0000BB-Kx for patch@linaro.org; Fri, 29 May 2020 16:45:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46504) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jelqa-0005j3-3u for qemu-devel@nongnu.org; Fri, 29 May 2020 16:43:21 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:38666) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jelqY-0000h9-Ij for qemu-devel@nongnu.org; Fri, 29 May 2020 16:43:19 -0400 Received: by mail-pf1-x430.google.com with SMTP id q8so413619pfu.5 for ; Fri, 29 May 2020 13:43:18 -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=8yFiq7oj5Jysxn79LgqzGqasvEs+ukSRcPl37MjQOiQ=; b=bPypazbtWWlRzonqB/axMO7n9IjKfvL2tRX6wHzpFZYVWHuDrPCjmPYbWI51Je8s6M ynb9yCj0GD5IDPcjhTSIXwuZSEu5GXm6ZB+UFM/zaFC4VzSxSQTmv2TrJfuIUJEMq/7/ IlOFoFHhunxUACVH+MhMMMOD2K0ahdf+S71sfuOXO8F41lVaitJk8ZxwNjbVeArs6t0I DqyJkODRfVf1eDk6FmbT5xZKEFkgv0hMzbqUlzmgYWI99GyQcH9s6VnaBFCbYRGdN62s /QhoWeE5rw+7NTJi5dYduU+FOk030aXDRXA0inS7GJIQTXkOm5xVTcJvBZh+7KR2tcZS 1MeA== 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=8yFiq7oj5Jysxn79LgqzGqasvEs+ukSRcPl37MjQOiQ=; b=CA0ljSTpYd4J7ATIRBqJZJNjKjSDln6+Ug8aN8uLBz8npfonoLZsiDFj7tFZOjAjIa /mvr6Z4RQiE/GDr0tP0u4mB9FbfpvjKCwWPmz1wAWgCuob7wO76qX3eCcc1px1hhXwXH ZU7+gE92LVF6i/A57sbKR7Yz88r+7aO5sUH6761roRDwSQPG3Gab2IC0TKmcmXESrdkx Kfaj4NcOr0vXJsXeLvmpUZJ3NxaPXZ45VsYCvCp1cLVnCPGehymj7TtAl/0uLtmKBdap Jyzv2FSFjpdaJ+pi4+0DZXM98fVhREZpYbp/zsROe87A3MHMZXdi0//9noL2fdno/ZWA 7fxw== X-Gm-Message-State: AOAM532bp6wgjzM0H2e7MNAKe4q2+i1Kex3myopFzRJmzMu6ydcbsQiu zIpeD6NL9db2QDGtNdciSKNKOXJh9MNlNQ== X-Received: by 2002:a62:fc52:: with SMTP id e79mr10734111pfh.297.1590784996128; Fri, 29 May 2020 13:43:16 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:75ac:d268:da04:dde4]) by smtp.gmail.com with ESMTPSA id t12sm282839pjf.3.2020.05.29.13.43.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2020 13:43:15 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v8 02/12] tests/vm: Add configuration to basevm.py Date: Fri, 29 May 2020 16:34:48 -0400 Message-Id: <20200529203458.1038-3-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200529203458.1038-1-robert.foley@linaro.org> References: <20200529203458.1038-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=robert.foley@linaro.org; helo=mail-pf1-x430.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_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 Zheng , philmd@redhat.com, alex.bennee@linaro.org, robert.foley@linaro.org, peter.puhov@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Added use of a configuration to tests/vm/basevm.py. The configuration provides parameters used to configure a VM. This allows for providing alternate configurations to the VM being created/launched. cpu, machine, memory, and NUMA configuration are all examples of configuration which we might want to vary on the VM being created or launched. This will for example allow for creating an aarch64 vm. Signed-off-by: Robert Foley Reviewed-by: Peter Puhov Reviewed-by: Alex Bennée --- tests/vm/basevm.py | 172 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 133 insertions(+), 39 deletions(-) -- 2.17.1 diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index fbefda0595..c33cf7436d 100644 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -29,16 +29,41 @@ import tempfile import shutil import multiprocessing import traceback - -SSH_KEY = open(os.path.join(os.path.dirname(__file__), - "..", "keys", "id_rsa")).read() -SSH_PUB_KEY = open(os.path.join(os.path.dirname(__file__), - "..", "keys", "id_rsa.pub")).read() - +import shlex + +SSH_KEY_FILE = os.path.join(os.path.dirname(__file__), + "..", "keys", "id_rsa") +SSH_PUB_KEY_FILE = os.path.join(os.path.dirname(__file__), + "..", "keys", "id_rsa.pub") + +# This is the standard configuration. +# Any or all of these can be overridden by +# passing in a config argument to the VM constructor. +DEFAULT_CONFIG = { + 'cpu' : "max", + 'machine' : 'pc', + 'guest_user' : "qemu", + 'guest_pass' : "qemupass", + 'root_pass' : "qemupass", + 'ssh_key_file' : SSH_KEY_FILE, + 'ssh_pub_key_file': SSH_PUB_KEY_FILE, + 'memory' : "4G", + 'extra_args' : [], + 'qemu_args' : "", + 'dns' : "", + 'ssh_port' : 0, + 'install_cmds' : "", + 'boot_dev_type' : "block", + 'ssh_timeout' : 1, +} +BOOT_DEVICE = { + 'block' : "-drive file={},if=none,id=drive0,cache=writeback "\ + "-device virtio-blk,drive=drive0,bootindex=0", + 'scsi' : "-device virtio-scsi-device,id=scsi "\ + "-drive file={},format=raw,if=none,id=hd0 "\ + "-device scsi-hd,drive=hd0,bootindex=0", +} class BaseVM(object): - GUEST_USER = "qemu" - GUEST_PASS = "qemupass" - ROOT_PASS = "qemupass" envvars = [ "https_proxy", @@ -57,24 +82,37 @@ class BaseVM(object): poweroff = "poweroff" # enable IPv6 networking ipv6 = True + # This is the timeout on the wait for console bytes. + socket_timeout = 120 # Scale up some timeouts under TCG. # 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, args): + def __init__(self, args, config=None): self._guest = None self._genisoimage = args.genisoimage + # Allow input config to override defaults. + self._config = DEFAULT_CONFIG.copy() + if config != None: + self._config.update(config) + self.validate_ssh_keys() self._tmpdir = os.path.realpath(tempfile.mkdtemp(prefix="vm-test-", suffix=".tmp", dir=".")) atexit.register(shutil.rmtree, self._tmpdir) - - self._ssh_key_file = os.path.join(self._tmpdir, "id_rsa") - open(self._ssh_key_file, "w").write(SSH_KEY) - subprocess.check_call(["chmod", "600", self._ssh_key_file]) - - self._ssh_pub_key_file = os.path.join(self._tmpdir, "id_rsa.pub") - open(self._ssh_pub_key_file, "w").write(SSH_PUB_KEY) + # Copy the key files to a temporary directory. + # Also chmod the key file to agree with ssh requirements. + self._config['ssh_key'] = \ + open(self._config['ssh_key_file']).read().rstrip() + self._config['ssh_pub_key'] = \ + open(self._config['ssh_pub_key_file']).read().rstrip() + self._ssh_tmp_key_file = os.path.join(self._tmpdir, "id_rsa") + open(self._ssh_tmp_key_file, "w").write(self._config['ssh_key']) + subprocess.check_call(["chmod", "600", self._ssh_tmp_key_file]) + + self._ssh_tmp_pub_key_file = os.path.join(self._tmpdir, "id_rsa.pub") + open(self._ssh_tmp_pub_key_file, + "w").write(self._config['ssh_pub_key']) self.debug = args.debug self._stderr = sys.stderr @@ -83,11 +121,14 @@ class BaseVM(object): self._stdout = sys.stdout else: self._stdout = self._devnull + netdev = "user,id=vnet,hostfwd=:127.0.0.1:{}-:22" self._args = [ \ - "-nodefaults", "-m", "4G", - "-cpu", "max", - "-netdev", "user,id=vnet,hostfwd=:127.0.0.1:0-:22" + - (",ipv6=no" if not self.ipv6 else ""), + "-nodefaults", "-m", self._config['memory'], + "-cpu", self._config['cpu'], + "-netdev", + netdev.format(self._config['ssh_port']) + + (",ipv6=no" if not self.ipv6 else "") + + (",dns=" + self._config['dns'] if self._config['dns'] else ""), "-device", "virtio-net-pci,netdev=vnet", "-vnc", "127.0.0.1:0,to=20"] if args.jobs and args.jobs > 1: @@ -98,6 +139,55 @@ class BaseVM(object): logging.info("KVM not available, not using -enable-kvm") self._data_args = [] + if self._config['qemu_args'] != None: + qemu_args = self._config['qemu_args'] + qemu_args = qemu_args.replace('\n',' ').replace('\r','') + # shlex groups quoted arguments together + # we need this to keep the quoted args together for when + # the QEMU command is issued later. + args = shlex.split(qemu_args) + self._config['extra_args'] = [] + for arg in args: + if arg: + # Preserve quotes around arguments. + # shlex above takes them out, so add them in. + if " " in arg: + arg = '"{}"'.format(arg) + self._config['extra_args'].append(arg) + + def validate_ssh_keys(self): + """Check to see if the ssh key files exist.""" + if 'ssh_key_file' not in self._config or\ + not os.path.exists(self._config['ssh_key_file']): + raise Exception("ssh key file not found.") + if 'ssh_pub_key_file' not in self._config or\ + not os.path.exists(self._config['ssh_pub_key_file']): + raise Exception("ssh pub key file not found.") + + def wait_boot(self, wait_string=None): + """Wait for the standard string we expect + on completion of a normal boot. + The user can also choose to override with an + alternate string to wait for.""" + if wait_string is None: + if self.login_prompt is None: + raise Exception("self.login_prompt not defined") + wait_string = self.login_prompt + # Intentionally bump up the default timeout under TCG, + # since the console wait below takes longer. + timeout = self.socket_timeout + if not kvm_available(self.arch): + timeout *= 8 + self.console_init(timeout=timeout) + self.console_wait(wait_string) + + def __getattr__(self, name): + # Support direct access to config by key. + # for example, access self._config['cpu'] by self.cpu + if name.lower() in self._config.keys(): + return self._config[name.lower()] + return object.__getattribute__(self, name) + def _download_with_cache(self, url, sha256sum=None, sha512sum=None): def check_sha256sum(fname): if not sha256sum: @@ -129,8 +219,9 @@ class BaseVM(object): "-t", "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=" + os.devnull, - "-o", "ConnectTimeout=1", - "-p", self.ssh_port, "-i", self._ssh_key_file] + "-o", + "ConnectTimeout={}".format(self._config["ssh_timeout"]), + "-p", self.ssh_port, "-i", self._ssh_tmp_key_file] # If not in debug mode, set ssh to quiet mode to # avoid printing the results of commands. if not self.debug: @@ -179,14 +270,14 @@ class BaseVM(object): "virtio-blk,drive=%s,serial=%s,bootindex=1" % (name, name)] def boot(self, img, extra_args=[]): - args = self._args + [ - "-drive", "file=%s,if=none,id=drive0,cache=writeback" % img, - "-device", "virtio-blk,drive=drive0,bootindex=0"] - args += self._data_args + extra_args + boot_dev = BOOT_DEVICE[self._config['boot_dev_type']] + boot_params = boot_dev.format(img) + args = self._args + boot_params.split(' ') + args += self._data_args + extra_args + self._config['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) - guest.set_machine('pc') + guest.set_machine(self._config['machine']) guest.set_console() try: guest.launch() @@ -300,7 +391,8 @@ class BaseVM(object): self.console_send(command) def console_ssh_init(self, prompt, user, pw): - sshkey_cmd = "echo '%s' > .ssh/authorized_keys\n" % SSH_PUB_KEY.rstrip() + sshkey_cmd = "echo '%s' > .ssh/authorized_keys\n" \ + % self._config['ssh_pub_key'].rstrip() self.console_wait_send("login:", "%s\n" % user) self.console_wait_send("Password:", "%s\n" % pw) self.console_wait_send(prompt, "mkdir .ssh\n") @@ -359,23 +451,23 @@ class BaseVM(object): "local-hostname: {}-guest\n".format(name)]) mdata.close() udata = open(os.path.join(cidir, "user-data"), "w") - print("guest user:pw {}:{}".format(self.GUEST_USER, - self.GUEST_PASS)) + print("guest user:pw {}:{}".format(self._config['guest_user'], + self._config['guest_pass'])) udata.writelines(["#cloud-config\n", "chpasswd:\n", " list: |\n", - " root:%s\n" % self.ROOT_PASS, - " %s:%s\n" % (self.GUEST_USER, - self.GUEST_PASS), + " root:%s\n" % self._config['root_pass'], + " %s:%s\n" % (self._config['guest_user'], + self._config['guest_pass']), " expire: False\n", "users:\n", - " - name: %s\n" % self.GUEST_USER, + " - name: %s\n" % self._config['guest_user'], " sudo: ALL=(ALL) NOPASSWD:ALL\n", " ssh-authorized-keys:\n", - " - %s\n" % SSH_PUB_KEY, + " - %s\n" % self._config['ssh_pub_key'], " - name: root\n", " ssh-authorized-keys:\n", - " - %s\n" % SSH_PUB_KEY, + " - %s\n" % self._config['ssh_pub_key'], "locale: en_US.UTF-8\n"]) proxy = os.environ.get("http_proxy") if not proxy is None: @@ -430,15 +522,17 @@ def parse_args(vmcls): parser.disable_interspersed_args() return parser.parse_args() -def main(vmcls): +def main(vmcls, config=None): try: + if config == None: + config = {} args, argv = parse_args(vmcls) if not argv and not args.build_qemu and not args.build_image: print("Nothing to do?") return 1 logging.basicConfig(level=(logging.DEBUG if args.debug else logging.WARN)) - vm = vmcls(args) + vm = vmcls(args, config=config) if args.build_image: if os.path.exists(args.image) and not args.force: sys.stderr.writelines(["Image file exists: %s\n" % args.image, From patchwork Fri May 29 20:34:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187323 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp929713ilb; Fri, 29 May 2020 13:45:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybM6G+93aGpkhoSLCeDl33i8/PwkRjRqnKttZybE+pIyEfRqeVFcTFIUjEH5Bg0zSsCqzF X-Received: by 2002:a25:f508:: with SMTP id a8mr16931654ybe.513.1590785148308; Fri, 29 May 2020 13:45:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590785148; cv=none; d=google.com; s=arc-20160816; b=BhX3JJZWvNReuv2TQxG8JuyejoRkGhLJAn6owU2z7C8QrtosvYKgYRDr9rnIJPTvAa brLFu6T/qEdGAKNIt3yVH+afyzp9QPC5ptu8YKi3znqZKiS0Tn8cLJra450F/XEz1G5A lV9Dz2zY+0Y9xBWIpCwXMA5Qo/dgGIYdxNneZsqG+ndFDp9ssZQFSskrD3oh7dvmzp60 aLc+EMBVd5arhdG4FQvsY+ORyV63n5wkdhaQQSqL4CLI3Sctse7qPhCLKRoUqhauL5xY 8LfPwjAS94B+4NdVdBmZwA+N3b8QhIuXfp1GHVvEUfAXeZLq/9VsYRVJaG5FaviKrRVf VWfg== 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=HdbTuhOrmKMOPWsO8VlGzoeyTa4YjsV9wzweLaGDTJQ=; b=BDH7+QeIvOH3JSu2tuCYHfQOtIdMM6KY8lhQ0wRvVYJzQZyGKOrSmQhXRZosmw2G6f eXC8v0X83QGmD0Xjf7fLWLcwaYFq2lIqO4RJ0Y61BgRvSUtNa6TMRLUc5CluGYBlTMPR L0JSaHHJIrTmAC2G0YLYhW3VnhtiWuhsaEYoSWkDS+oLgUrx7pe69ph6ZyU67K59xINw m/Cl21dEuqU2B0PJkohuqBq9TpIeJeZNOH4HoC7xfwtITYylbpdIdKQr9BU+laBwYv3P mBs6TAP/8XssMKHPAuaz47zooAD9kfRbtIX+lNyKdarzSKYVIwkD7bWhMpM0E4UEx0Wu dd9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PrGUwx42; 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 j205si1603188ybj.432.2020.05.29.13.45.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 May 2020 13:45:48 -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=PrGUwx42; 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]:46714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jelsx-0000xq-Oi for patch@linaro.org; Fri, 29 May 2020 16:45:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jelqb-0005lI-SH for qemu-devel@nongnu.org; Fri, 29 May 2020 16:43:21 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:37549) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jelqa-0000jt-Ap for qemu-devel@nongnu.org; Fri, 29 May 2020 16:43:21 -0400 Received: by mail-pg1-x536.google.com with SMTP id d10so478046pgn.4 for ; Fri, 29 May 2020 13:43:19 -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=HdbTuhOrmKMOPWsO8VlGzoeyTa4YjsV9wzweLaGDTJQ=; b=PrGUwx42/pCUvGqKjbBDJV7CNJoSKgQPHj+w1W3MqDBb7X0gMnk9f3CFdohj3BRVac Nf5bh2lGhtRq8HeP7va70yIf6bCAhMY/53lP9IBRbQPhK5Mm4lDGBGmQARx7yG5V3Jsy w/Fsl3UVLyIFowXFyHzlNvK+mYumIiNIIQ98v4YsnrJr1Y31zfnOXEYFGQslBmfRcA9b LbD5gu4v0m9lv0bUPW01AdPSyO164XqfsI8/YaAU2y/7yFiS5jp3biRKq4PfWx6lBJrE oI3fOnmbs+ZScxvmBQdYPIDZTXh05qY7CBvxdbB52WH6pY0LKw/dTy6stNsYftAgh1O5 z0BQ== 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=HdbTuhOrmKMOPWsO8VlGzoeyTa4YjsV9wzweLaGDTJQ=; b=Sy9MAgs7LYa13twthjVBJE5kXgr4Uvs2l0iaccD5EemFz8TIp9zZM4ICvdmvGjYeJU 2XaYhs/AswxqParBrmOPGsXEBBP7Wm9kuSp3Fzk1Dg3x7G3eNY83VaPUh/VX00ndA9Vq E1404QpN3tEgDYl/Wpz7wuN/lNbUbuDhSNhXbf5pVTWIQz/Hja5K+uTtVXL5MnGvVkyE e5VgON1YgH4d6fU+VY9P6bTwL8nl1zfFl0+qLDhfjSTsvSu5togpAI5vbu2knzmFOZ08 oL310ScS+ou3vTLiTcMw6cATgU2EvSLVaJex+09VlkClv6ju+83YvvNOwJD9ArTnOZt9 2lhg== X-Gm-Message-State: AOAM533hqPRcpbsdhZ6TAO2bJSeoX1syKy98YB1p0mb6U2Hpl+LzOdxb Oh12TTyt595fLp2OLx27pYuulQywWtb4VQ== X-Received: by 2002:a62:cdc7:: with SMTP id o190mr10891372pfg.9.1590784998337; Fri, 29 May 2020 13:43:18 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:75ac:d268:da04:dde4]) by smtp.gmail.com with ESMTPSA id t12sm282839pjf.3.2020.05.29.13.43.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2020 13:43:17 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v8 03/12] tests/vm: Added configuration file support Date: Fri, 29 May 2020 16:34:49 -0400 Message-Id: <20200529203458.1038-4-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200529203458.1038-1-robert.foley@linaro.org> References: <20200529203458.1038-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=robert.foley@linaro.org; helo=mail-pg1-x536.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_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 Zheng , philmd@redhat.com, alex.bennee@linaro.org, robert.foley@linaro.org, peter.puhov@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Changes to tests/vm/basevm.py to allow accepting a configuration file as a parameter. Allows for specifying VM options such as cpu, machine, memory, and arbitrary qemu arguments for specifying options such as NUMA configuration. Also added an example conf_example_aarch64.yml and conf_example_x86.yml. Signed-off-by: Robert Foley Reviewed-by: Peter Puhov Reviewed-by: Alex Bennée --- configure | 9 ++++++ tests/vm/Makefile.include | 6 ++++ tests/vm/basevm.py | 40 +++++++++++++++++++++++- tests/vm/conf_example_aarch64.yml | 51 +++++++++++++++++++++++++++++++ tests/vm/conf_example_x86.yml | 50 ++++++++++++++++++++++++++++++ 5 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 tests/vm/conf_example_aarch64.yml create mode 100644 tests/vm/conf_example_x86.yml -- 2.17.1 diff --git a/configure b/configure index af2ba83f0e..d82de47fdd 100755 --- a/configure +++ b/configure @@ -950,6 +950,13 @@ do fi done +# Check for existence of python3 yaml, needed to +# import yaml config files into vm-build. +python_yaml="no" +if $(python3 -c "import yaml" 2> /dev/null); then + python_yaml="yes" +fi + : ${smbd=${SMBD-/usr/sbin/smbd}} # Default objcc to clang if available, otherwise use CC @@ -6597,6 +6604,7 @@ if test "$docs" != "no"; then echo "sphinx-build $sphinx_build" fi echo "genisoimage $genisoimage" +echo "python_yaml $python_yaml" echo "slirp support $slirp $(echo_version $slirp $slirp_version)" if test "$slirp" != "no" ; then echo "smbd $smbd" @@ -7659,6 +7667,7 @@ echo "PYTHON=$python" >> $config_host_mak echo "SPHINX_BUILD=$sphinx_build" >> $config_host_mak echo "SPHINX_WERROR=$sphinx_werror" >> $config_host_mak echo "GENISOIMAGE=$genisoimage" >> $config_host_mak +echo "PYTHON_YAML=$python_yaml" >> $config_host_mak echo "CC=$cc" >> $config_host_mak if $iasl -h > /dev/null 2>&1; then echo "IASL=$iasl" >> $config_host_mak diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include index 74ab522c55..d9b34eae63 100644 --- a/tests/vm/Makefile.include +++ b/tests/vm/Makefile.include @@ -43,6 +43,12 @@ endif @echo " V=1 - Enable verbose ouput on host and guest commands" @echo " QEMU=/path/to/qemu - Change path to QEMU binary" @echo " QEMU_IMG=/path/to/qemu-img - Change path to qemu-img tool" +ifeq ($(PYTHON_YAML),yes) + @echo " QEMU_CONFIG=/path/conf.yml - Change path to VM configuration .yml file." +else + @echo " (install python3-yaml to enable support for yaml file to configure a VM.)" +endif + @echo " See conf_example_*.yml for file format details." vm-build-all: $(addprefix vm-build-, $(IMAGES)) diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index c33cf7436d..7d23ae279b 100644 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -480,9 +480,43 @@ class BaseVM(object): cwd=cidir, stdin=self._devnull, stdout=self._stdout, stderr=self._stdout) - return os.path.join(cidir, "cloud-init.iso") +def parse_config(config, args): + """ Parse yaml config and populate our config structure. + The yaml config allows the user to override the + defaults for VM parameters. In many cases these + defaults can be overridden without rebuilding the VM.""" + if args.config: + config_file = args.config + elif 'QEMU_CONFIG' in os.environ: + config_file = os.environ['QEMU_CONFIG'] + else: + return config + if not os.path.exists(config_file): + raise Exception("config file {} does not exist".format(config_file)) + # We gracefully handle importing the yaml module + # since it might not be installed. + # If we are here it means the user supplied a .yml file, + # so if the yaml module is not installed we will exit with error. + try: + import yaml + except ImportError: + print("The python3-yaml package is needed "\ + "to support config.yaml files") + # Instead of raising an exception we exit to avoid + # a raft of messy (expected) errors to stdout. + exit(1) + with open(config_file) as f: + yaml_dict = yaml.safe_load(f) + + if 'qemu-conf' in yaml_dict: + config.update(yaml_dict['qemu-conf']) + else: + raise Exception("config file {} is not valid"\ + " missing qemu-conf".format(config_file)) + return config + def parse_args(vmcls): def get_default_jobs(): @@ -519,6 +553,9 @@ def parse_args(vmcls): help="run tests with a snapshot") parser.add_option("--genisoimage", default="genisoimage", help="iso imaging tool") + parser.add_option("--config", "-c", default=None, + help="Provide config yaml for configuration. "\ + "See config_example.yaml for example.") parser.disable_interspersed_args() return parser.parse_args() @@ -530,6 +567,7 @@ def main(vmcls, config=None): if not argv and not args.build_qemu and not args.build_image: print("Nothing to do?") return 1 + config = parse_config(config, args) logging.basicConfig(level=(logging.DEBUG if args.debug else logging.WARN)) vm = vmcls(args, config=config) diff --git a/tests/vm/conf_example_aarch64.yml b/tests/vm/conf_example_aarch64.yml new file mode 100644 index 0000000000..9d44ae356f --- /dev/null +++ b/tests/vm/conf_example_aarch64.yml @@ -0,0 +1,51 @@ +# +# Example yaml for use by any of the scripts in tests/vm. +# Can be provided as an environment variable QEMU_CONFIG +# +qemu-conf: + + # If any of the below are not provided, we will just use the qemu defaults. + + # Login username and password(has to be sudo enabled) + guest_user: qemu + guest_pass: "qemupass" + + # Password for root user can be different from guest. + root_pass: "qemupass" + + # If one key is provided, both must be provided. + #ssh_key: /complete/path/of/your/keyfile/id_rsa + #ssh_pub_key: /complete/path/of/your/keyfile/id_rsa.pub + + cpu: max + machine: virt,gic-version=max + memory: 16G + + # The below is a example for how to configure NUMA topology with + # 4 NUMA nodes and 2 different NUMA distances. + qemu_args: "-smp cpus=16,sockets=2,cores=8 + -numa node,cpus=0-3,nodeid=0 -numa node,cpus=4-7,nodeid=1 + -numa node,cpus=8-11,nodeid=2 -numa node,cpus=12-15,nodeid=3 + -numa dist,src=0,dst=1,val=15 -numa dist,src=2,dst=3,val=15 + -numa dist,src=0,dst=2,val=20 -numa dist,src=0,dst=3,val=20 + -numa dist,src=1,dst=2,val=20 -numa dist,src=1,dst=3,val=20" + + # By default we do not set the DNS. + # You override the defaults by setting the below. + #dns: 1.234.567.89 + + # By default we will use a "block" device, but + # you can also boot from a "scsi" device. + # Just keep in mind your scripts might need to change + # As you will have /dev/sda instead of /dev/vda (for block device) + boot_dev_type: "block" + + # By default the ssh port is not fixed. + # A fixed ssh port makes it easier for automated tests. + #ssh_port: 5555 + + # To install a different set of packages, provide a command to issue + #install_cmds: "apt-get update ; apt-get build-dep -y qemu" + + # Or to skip the install entirely, just provide "" + #install_cmds: "" diff --git a/tests/vm/conf_example_x86.yml b/tests/vm/conf_example_x86.yml new file mode 100644 index 0000000000..78d3f5830f --- /dev/null +++ b/tests/vm/conf_example_x86.yml @@ -0,0 +1,50 @@ +# +# Example yaml for use by any of the x86 based scripts in tests/vm. +# Can be provided as an environment variable QEMU_CONFIG +# +qemu-conf: + + # If any of the below are not provided, we will just use the qemu defaults. + + # Login username and password(has to be sudo enabled) + guest_user: "qemu" + guest_pass: "qemupass" + + # Password for root user can be different from guest. + root_pass: "qemupass" + + # Provide default ssh keys of current user. + # You need to edit the below for your user. + #ssh_key_file: /home//.ssh/id_rsa + #ssh_pub_key_file: /home//.ssh/id_rsa.pub + + cpu: max + machine: pc + memory: 8G + + # The below is a example for how to configure NUMA topology with + # 4 NUMA nodes and 2 different NUMA distances. + qemu_args: "-smp cpus=8,sockets=2,cores=4 + -object memory-backend-ram,size=4G,policy=bind,host-nodes=0,id=ram-node0 + -object memory-backend-ram,size=4G,policy=bind,host-nodes=0,id=ram-node1 + -object memory-backend-ram,size=4G,policy=bind,host-nodes=1,id=ram-node2 + -object memory-backend-ram,size=4G,policy=bind,host-nodes=1,id=ram-node3 + -numa node,cpus=0-1,nodeid=0 -numa node,cpus=2-3,nodeid=1 + -numa node,cpus=4-5,nodeid=2 -numa node,cpus=6-7,nodeid=3 + -numa dist,src=0,dst=1,val=15 -numa dist,src=2,dst=3,val=15 + -numa dist,src=0,dst=2,val=20 -numa dist,src=0,dst=3,val=20 + -numa dist,src=1,dst=2,val=20 -numa dist,src=1,dst=3,val=20" + + # By default we do not set the DNS. + # You override the defaults by setting the below. + #dns: "1.234.567.89" + + # By default we will use a "block" device, but + # you can also boot from a "scsi" device. + # Just keep in mind your scripts might need to change + # As you will have /dev/sda instead of /dev/vda (for block device) + boot_dev_type: "block" + + # By default the ssh port is not fixed. + # A fixed ssh port makes it easier for automated tests. + ssh_port: 5555 From patchwork Fri May 29 20:34:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187325 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp930944ilb; Fri, 29 May 2020 13:47:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgQ3t7HLeLO0w0xWVaz85ArwQMpY3sLm269yiqbvVrdnoX002Mq2d0yqgTBhBi8L2wvGRx X-Received: by 2002:a25:2488:: with SMTP id k130mr16471806ybk.241.1590785269643; Fri, 29 May 2020 13:47:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590785269; cv=none; d=google.com; s=arc-20160816; b=UwFhT/taQKb+eAXWNdLNpek6pz+hGRjXJJRkVBDCTndtLvIsZrURfxQXLxdND/lpYw dDggCVO/qUUAYvLvdx8rsEVMH5Kn6f484h6amoTd5Obo4RGB6BpUYEpHRRJqU14d6asW UDggsNQXY/0ZssDM5vpkwrwDv7ctK/1bGYbUuE32Fo6RbcV/XfgOXGGaRgeo/OI5Y3bU w2C8ZfRoyxqnuSUROYH5Hdn978ja2dZFwlHTcevr+fH0PUpFJ3F1hg2jmloCwm3xINyf OVPw4A/f10qc7vaNb3RugpuL5CZRFjIwzD4a1mKIVkr8Etn18GdsUWb9sWvHGtNpFrjk VBrQ== 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=DpQu0u1B+To4merP8lGd0wuHe3HC8iNvo+aly+1/stk=; b=LiyaSjIhw6Z5Y5W2JkVvin07VDKCUaepwHx94c+KWbEVz75pk2wdoJTtrsgoftyZEz fnjapX6WHRu2VJk3Ue+OGiFszTsC1iCLwTUQDf1ZnlrQyGgKU1GCtjLqxGTy4RbMX8Mk WSxbOI4R6McdzRMgkdV3lzpmLkCkeh+fQEbuGkUj+Q9Of8WbUpp96jbAgq0VqSQcQhGD 7xRgMZMN8PMvsWr9SrXkiMizWBMwvtvv+/Mi1MA8Lobh4+VyhtqCEwJdTXfBKD9hrkJB eMryJ8ldOpP3xfgDu2ZT7IjJa/BdECVu9G+QXrSDPq0k/Z6r6WvWOoTBpYdMq5ls25OX b6Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=deB9D2dE; 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 d16si7872031yba.107.2020.05.29.13.47.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 May 2020 13:47:49 -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=deB9D2dE; 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]:50996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jeluv-0003a1-3K for patch@linaro.org; Fri, 29 May 2020 16:47:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jelqc-0005nQ-Um for qemu-devel@nongnu.org; Fri, 29 May 2020 16:43:22 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:39565) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jelqc-0000mx-0j for qemu-devel@nongnu.org; Fri, 29 May 2020 16:43:22 -0400 Received: by mail-pl1-x644.google.com with SMTP id x18so1700764pll.6 for ; Fri, 29 May 2020 13:43:21 -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=DpQu0u1B+To4merP8lGd0wuHe3HC8iNvo+aly+1/stk=; b=deB9D2dEZRN/05bruWGmXhgcY0DHErO5T+ACOihxGcQryLJ+7JjPG5ZIAzZ3J816sM +14nSd8e46tqP5FPUoX+wYXMZppW+5PFlF8xhx1mwXhYfW9+Qh7GVHzou3/d5/map5bB JYfsfEFuiYJceVBpCB8xp1pkPdvsF6ryVHZHzLmWTSbmtR+rPgQd+fufIyzU1UQeSSor /zN6UfCGgqz9BLUJ8lCZAHg6u6vpI3NiJPN7ZnMWwzTrsr+VMWsNcQI0jLYw5/ii3LC8 bpBrYUJSt0cPQZ3CvVJDAv3QglKRU2zKmstnzBt7kpj99k3YI4Q3Pe3LQSL+uV/0jgZv 1F/g== 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=DpQu0u1B+To4merP8lGd0wuHe3HC8iNvo+aly+1/stk=; b=fGfQ0kTUpmGRVgedt6STFjG4VV5/Qm0jEwNo9SlJ2fBcviI+nxNjQZonXtVu3ybGXn AVz5gSU99LhZH2hqBhPL/J0bS+AW2IrMY6f+7NQzv45gzWRyRgqxqvk+x0RSy/eGZJmg QUHCWo5aIcrQ/TRJ8CKwcZsXUCU9d30ZzBH0cna52ABdxI+DEhviYXvaI+QOhVMkMsos 2vzQTUd101dIxU7dnRoj1uL15Be4cTQRKZ4ImyGhKYGBGQRArjOzuyc51m9skfMkJmTj r24scv9ZKfnviZwpAkudks6zm8YQqlD2QnxKvxfBPX/MA57hbRt6pYsTW98kCu2LNOZ7 bNNA== X-Gm-Message-State: AOAM533ALc0cbRkqFHnisoqwaLv6ehvXVznnO50Ift9MKBh93b6LM1aL Q+jyud4C51IQuOTW0PWg9RAfzr0arHVBQA== X-Received: by 2002:a17:90a:e54d:: with SMTP id ei13mr9298411pjb.126.1590785000395; Fri, 29 May 2020 13:43:20 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:75ac:d268:da04:dde4]) by smtp.gmail.com with ESMTPSA id t12sm282839pjf.3.2020.05.29.13.43.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2020 13:43:19 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v8 04/12] tests/vm: Pass --debug through for vm-boot-ssh. Date: Fri, 29 May 2020 16:34:50 -0400 Message-Id: <20200529203458.1038-5-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200529203458.1038-1-robert.foley@linaro.org> References: <20200529203458.1038-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::644; envelope-from=robert.foley@linaro.org; helo=mail-pl1-x644.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_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 Zheng , philmd@redhat.com, alex.bennee@linaro.org, robert.foley@linaro.org, peter.puhov@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This helps debug issues that occur during the boot sequence. Signed-off-by: Robert Foley Reviewed-by: Peter Puhov Reviewed-by: Alex Bennée --- tests/vm/Makefile.include | 1 + 1 file changed, 1 insertion(+) -- 2.17.1 diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include index d9b34eae63..e22c391a2a 100644 --- a/tests/vm/Makefile.include +++ b/tests/vm/Makefile.include @@ -97,6 +97,7 @@ vm-boot-ssh-%: $(IMAGES_DIR)/%.img $(call quiet-command, \ $(PYTHON) $(SRC_PATH)/tests/vm/$* \ $(if $(J),--jobs $(J)) \ + $(if $(V)$(DEBUG), --debug) \ --image "$<" \ --interactive \ false, \ From patchwork Fri May 29 20:34:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187324 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp930562ilb; Fri, 29 May 2020 13:47:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxC/02yN1JN1FjHkFc1mg/USWzZI29+F8YEnYs0onPxtWkHFFk9+6JoCJJo5CG/tktPq396 X-Received: by 2002:a25:5804:: with SMTP id m4mr16224445ybb.488.1590785227337; Fri, 29 May 2020 13:47:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590785227; cv=none; d=google.com; s=arc-20160816; b=mNcwHVwQaIntj6isoe7www//zoZO837aFguR7Poem8wM0VND/sQ9ZM3oqLZlDKxeG8 iCD9hqxFsj7stOe3krxx5JN0eUBGgaPFtEZ2toLIx+4fLBgHl3BrWy4V52V8tdU9dGfR 0QCsTAzVtQ+VUlzsMvFR9mMnLi+uwJl1l/9Cdr8gVOp4YKjR8mCE19vM9OIiw5a3oSxF qqxf8ruoXPMtXJmrMBV4OaA8ttCH5+EIhfO5y4EFYH7q7MmDS7521zlHw5E/v72OAk9A iAKilK+nP83a1FDPMpjzc8GM6m1IyzP93Vgwy+AqAHfjFK2imp63AoAzDB5myrmesN+v 3XVA== 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=5VM4/GB0V2/UozGr03LttV9zgjDgk37jEZ21y8bUQhs=; b=ZmJKafnd9DFinVS9Goee9u8kEn5yKq87i4ieoMNZDlvkZYatgEiNHcZljCqXZ90GMm 0V3ozusyP3XDsPRa+dvr7JHh9ui3EzR+/XtO1WkDgD7uIxsx9isVz3r9eT5E58mRRPpW maPxsJn8FBwiQN36YmLLmt1hAewdeQxUiRF/mPg+dOUg7XbqHmKy6Mjqprvk4NuoSYEp KPqyiee1T9yxYeguC9K3O1xobXKZKQoKv+e3JpZiCuYn8yKnYJZmyVjD/C823kiyMphB ooedJJ92JQmBO8/5vzThv96KzuqfudvS5tdtpW2AxSLt1t9wo29CjvaYy3aq0GHuAWSV HFXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=mymBIW2m; 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 187si8656006ybc.263.2020.05.29.13.47.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 May 2020 13:47:07 -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=mymBIW2m; 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]:49890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jeluE-0002Vs-PI for patch@linaro.org; Fri, 29 May 2020 16:47:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46532) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jelqf-0005rn-Dg for qemu-devel@nongnu.org; Fri, 29 May 2020 16:43:25 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]:33764) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jelqe-0000pc-7a for qemu-devel@nongnu.org; Fri, 29 May 2020 16:43:25 -0400 Received: by mail-pl1-x62f.google.com with SMTP id t7so1711484plr.0 for ; Fri, 29 May 2020 13:43:23 -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=5VM4/GB0V2/UozGr03LttV9zgjDgk37jEZ21y8bUQhs=; b=mymBIW2mfA6EOafEbHSHcS39wUajelqY8+VZ8P2AllsgDOFJagjOK1JWA3g7jhBCCo V2YATSdKQYocRyfgVtdlRXKE0ANUyaLmdGeKet+k23LFKaaoU5xW94qyVJtAGUh699eT xfxz92+Xr7jfwDItXyk/5ay/KV2kzm52cYldtn0JAmv+kIIHdeUEhvjhwNJINuimEbGi r1Zsny2Ccei1Sp9OwsE4hOGoU6KKWErwei8mkZde5Hnhsfj20/FkMfnRjkx/JwNCXp61 YTvUVuvUrBcUi/st1Mfc/O6cNteZoYc+VtMrX6xetB87jk6jE29DUlWr4Wtyaqd/w+Br QsbQ== 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=5VM4/GB0V2/UozGr03LttV9zgjDgk37jEZ21y8bUQhs=; b=Esl6DA+pqw+NLjOsAOYQd9JIhdHsve1SqVLjlb+zpCIl+DlfrWdG2/EYT7HnFW9r2d qSxqsLjmLJ0j+WcYG7pcpkKGxwqO7XRU0xLcIVqYeHtuA80FFPIfcOHfLlDPV7TPG2z5 1p/GYl9uj3PpT2QsF6BDjPSZIJdW5nMNyQX4/P5h93X6/09skXJ+sRYSwkBjgXqpU3Bi qdKJRSMS8Yai8PXyWzsHBMqXcf0xbJ2s/AfEGV57xJXz9My7CE9Ux6YU5kIFLSz7LWdn jhqjebREYvi2BofzIK1ioeONSX/06Im4h7V9X2hDU+DxJ6f4KHwPqWAfKgx8KG7O+Esa ZNkg== X-Gm-Message-State: AOAM532/QUKQMOZSk40HEF3ddHXPk0AGCiK3v6xHpaXN9yrjZeioPVfU yFDPizU4CeX90Z5Vf2WI5LLZQaiB2o7qXw== X-Received: by 2002:a17:90a:ba18:: with SMTP id s24mr11724757pjr.192.1590785002460; Fri, 29 May 2020 13:43:22 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:75ac:d268:da04:dde4]) by smtp.gmail.com with ESMTPSA id t12sm282839pjf.3.2020.05.29.13.43.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2020 13:43:21 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v8 05/12] tests/vm: Add ability to select QEMU from current build. Date: Fri, 29 May 2020 16:34:51 -0400 Message-Id: <20200529203458.1038-6-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200529203458.1038-1-robert.foley@linaro.org> References: <20200529203458.1038-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=robert.foley@linaro.org; helo=mail-pl1-x62f.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_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 Zheng , philmd@redhat.com, alex.bennee@linaro.org, robert.foley@linaro.org, peter.puhov@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- tests/vm/Makefile.include | 4 ++++ tests/vm/basevm.py | 23 ++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) -- 2.17.1 Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include index e22c391a2a..f6c3892bb2 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" ifeq ($(PYTHON_YAML),yes) @@ -63,6 +64,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 $@, \ @@ -77,6 +79,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 \ @@ -98,6 +101,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 7d23ae279b..75a7ac2bd3 100644 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -91,6 +91,7 @@ class BaseVM(object): def __init__(self, args, config=None): self._guest = None self._genisoimage = args.genisoimage + self._build_path = args.build_path # Allow input config to override defaults. self._config = DEFAULT_CONFIG.copy() if config != None: @@ -275,15 +276,15 @@ class BaseVM(object): args = self._args + boot_params.split(' ') args += self._data_args + extra_args + self._config['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(self._config['machine']) 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") @@ -482,6 +483,19 @@ class BaseVM(object): stderr=self._stdout) 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_config(config, args): """ Parse yaml config and populate our config structure. The yaml config allows the user to override the @@ -556,6 +570,9 @@ def parse_args(vmcls): parser.add_option("--config", "-c", default=None, help="Provide config yaml for configuration. "\ "See config_example.yaml for example.") + parser.add_option("--build-path", default=None, + help="Path of build directory, "\ + "for using build tree QEMU binary. ") parser.disable_interspersed_args() return parser.parse_args() From patchwork Fri May 29 20:34:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187327 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp931545ilb; Fri, 29 May 2020 13:48:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrXhjqOJfF3X+bCdfd66+NULJFnrtw9ITICuLGiD3cHlnVhGaXQ0oohzoAAr+iJskitXNZ X-Received: by 2002:a25:785:: with SMTP id 127mr14421668ybh.115.1590785332556; Fri, 29 May 2020 13:48:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590785332; cv=none; d=google.com; s=arc-20160816; b=0ctjfnzcWRf/9PMdEUKM/Jp4+hiJJLTeJ//DKd4MjA/uqY8RmGXXFvAgnepk9bNXhT pqZ7kAVTtk5dYUiOW28RBX37Rnr79jJVoERmv016mqlNc9jG6HVO0yoLkh8AOG2UeCvy 01i0shl5e/+iBcfU5HC7ihcrH6tnI9zeqQEHs61sI6TJRiOwt42R8kVjsSRTBvmWdglH aFX34jrQ5r+sBcE0/6aJkWrCozZE4cUUsOOttBFOyKvYxuWnOpiCzfvxoEaERLTHivA1 sbx0a+jLntxi4F5N+3m7SOMkzNcPPctAJA4b/IHZ+VutQu4JmoSmVas5IpCMd8OwrcpO 5kNQ== 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=I57f4z5ddl8Jgj2XC06LWOjtbgtg/rXwxyMqaFaoBAM=; b=pOJJYj/YKP/R1TJMuNloiG2VPlx0zh6ZQG4zD84Sq05N8qJ+4FO4MGJEMWxYLFTwK9 Oi/t8G8E8rEV7guXZL7I3fmcuZwdzwubAwfFz1f4j8GU4vcXB9rnpSMu2+lYhnmddLw7 QEs5LzwTMNNzNcbw+n1L1gLtB25cuSigCmvdAK+JnnP57eOZgDsIqDGc8tChppNk7wSq H//YUeQ/obYg60wZsXbcHYJ8eE5X1z/zktEs/tmrzGhHa9nUPlemFdgw5tqGuIuB3FS7 TTiN4gTLWa/7jcMMC+waYEqnAiOPTBxXxMnjAbQkM/aqa3laV4q08aICZZjR1nimph7D KNvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=d8NarI4a; 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 y1si9203134ybh.171.2020.05.29.13.48.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 May 2020 13:48:52 -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=d8NarI4a; 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]:55690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jelvw-0005je-1R for patch@linaro.org; Fri, 29 May 2020 16:48:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46550) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jelqh-0005uF-CL for qemu-devel@nongnu.org; Fri, 29 May 2020 16:43:27 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:44519) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jelqg-0000rq-Cu for qemu-devel@nongnu.org; Fri, 29 May 2020 16:43:27 -0400 Received: by mail-pl1-x631.google.com with SMTP id bh7so1696374plb.11 for ; Fri, 29 May 2020 13:43:25 -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=I57f4z5ddl8Jgj2XC06LWOjtbgtg/rXwxyMqaFaoBAM=; b=d8NarI4a5bR1b0jOmT4mpBXTixvltA5AycOdlCe0wkJGSJ1L1nvwx8iYL8ts3Ii55B CMBxeMX6Y1TNUSsRk0O1niUCjEpwxqUFZY2/rswBF1I86yaHxnmr+b+z/VLEoN6YAp/q 5hyS2uBQAYQqAmLNIndz12LbB5zGrCSNSI0ZoJ0MvzW+pff+vw+Ocq4DwGgSSdMSBUxS JngFdR1D1M+tUFzXRI9qNMFCUJyaY6CoTiFj1ctcxspc8NqHz44mnKQGjYbmVSqkSEKM Wrbeq3Hn0EZlQCQgGVbNqg1Wx/qI93IVEDjC/AQNnuRclXfbpAS7MCsE2MFsGn70Q2yd wu4A== 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=I57f4z5ddl8Jgj2XC06LWOjtbgtg/rXwxyMqaFaoBAM=; b=hUJtKQCB5gIMU91VsaeWHT/KPKpRinT6I8YPZoo4YwHlVA2W6JM/J2XTEPuDs1E3UM NtQBWC5N0SYk+IsNVUEvDC7qo7B45Y0Lr4n1WhfTE/yXqUSHhq9P8qE61OVITHI2BQjs PN+j+JsNOFTbFaEllh0j3xJgrfmT+48lS+Id0+nndO4RiZCWukP9mnTrUxGcIv9/pAJy taZ9wKJH+KpV5dBpoet20d6m07ajDpZdhut19q5mLqYE2aK5HiMYqnMeAoaKr9dcS+pT p3bHjNuqQpGJYo/sIiw4KgjKwXsDt6XB7PwMBf6nb5pLyIEhfwqlvZI2MDhYbtdWSqA5 I/6g== X-Gm-Message-State: AOAM533AwTKL2Q6Ul/pFY531Z6enAY7ljTIc670n8XWzzprAh0HZDPkL RLCvXEZ8I/OnnvL9q2lQUYq7Gx3O+qbB/A== X-Received: by 2002:a17:90a:a884:: with SMTP id h4mr11578316pjq.82.1590785004522; Fri, 29 May 2020 13:43:24 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:75ac:d268:da04:dde4]) by smtp.gmail.com with ESMTPSA id t12sm282839pjf.3.2020.05.29.13.43.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2020 13:43:23 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v8 06/12] tests/vm: allow wait_ssh() to specify command Date: Fri, 29 May 2020 16:34:52 -0400 Message-Id: <20200529203458.1038-7-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200529203458.1038-1-robert.foley@linaro.org> References: <20200529203458.1038-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=robert.foley@linaro.org; helo=mail-pl1-x631.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_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 Zheng , philmd@redhat.com, alex.bennee@linaro.org, robert.foley@linaro.org, peter.puhov@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This allows for waiting for completion of arbitrary commands. Signed-off-by: Robert Foley Reviewed-by: Peter Puhov Reviewed-by: Alex Bennée --- tests/vm/basevm.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) -- 2.17.1 Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index 75a7ac2bd3..1aab9e3a24 100644 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -411,24 +411,24 @@ class BaseVM(object): def print_step(self, text): sys.stderr.write("### %s ...\n" % text) - def wait_ssh(self, wait_root=False, seconds=300): + def wait_ssh(self, wait_root=False, seconds=300, cmd="exit 0"): # Allow more time for VM to boot under TCG. if not kvm_available(self.arch): seconds *= self.tcg_ssh_timeout_multiplier starttime = datetime.datetime.now() endtime = starttime + datetime.timedelta(seconds=seconds) - guest_up = False + cmd_success = False while datetime.datetime.now() < endtime: - if wait_root and self.ssh_root("exit 0") == 0: - guest_up = True + if wait_root and self.ssh_root(cmd) == 0: + cmd_success = True break - elif self.ssh("exit 0") == 0: - guest_up = True + elif self.ssh(cmd) == 0: + cmd_success = True break seconds = (endtime - datetime.datetime.now()).total_seconds() logging.debug("%ds before timeout", seconds) time.sleep(1) - if not guest_up: + if not cmd_success: raise Exception("Timeout while waiting for guest ssh") def shutdown(self): From patchwork Fri May 29 20:34:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187320 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp928435ilb; Fri, 29 May 2020 13:43:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiozwcKffwMhOYC7RWtzxBIYpFDz6KpBPOBRQpCeW3y8PsjXahccRe2II66rPiDTqdxLsT X-Received: by 2002:a25:d04c:: with SMTP id h73mr16817891ybg.358.1590785024353; Fri, 29 May 2020 13:43:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590785024; cv=none; d=google.com; s=arc-20160816; b=FCNCXSgTpF9spspGjyD+aC0AA1B8hMcwogUhISvqGmsZXOHhDKiEHJWcUIKdtxcYBS OKiAKvZZ/dJcGL//HZTNoJ0klkkb58dOJUYhY2Wl2CGgOGBOZMQvFWvZ8Pv96r8+Hd7z 6wk2zZbtuk2fSRSvr3Wf6V8O6OmTnYZJL66N9frJDrztYze+MQ243WFvJWVaPf8tRq9w WDu9Nu8Y+1R1rwh0d7oiMpJ6rZ7Kbs/7IEnB5kHLgKnF1X8A7P2cFLeShvBA+eKiwbrD IGuzgbPYXn20QAox3fxt6i+Az7BD+3UjC2JMzHc9Na6PO8qonoLo2YCgn1cx78vNTsb6 cXTw== 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:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=U1T9E3y7ekxmt2kh9rxFnoBTMX0789LZtq9IU4HklTo=; b=aHUb9njIlRAwDhIPI0didp5zTy9kqmrHuE320ATWUSpOrA+9J4OMgaVY+hqatkdzYV SAyDo9rU9PqU6Fjj31vhWTcP5HrNvgQQaat11AgU4vWAYy+gIcq/5wjyeOS70niYhMA2 uY04tKBQ0JA+4kfhfXExXq6y4CQPyvONdoqesARlmawJdZQwTKPYO9pPEYHW5f/3UyiR TgP77w8RXhqZnS+h9JQpD/CRcj0fgUqOg+ZsY6zTSN4f7YwxYYNl4jVG1ZZkP/6UM1tr 13CgJxg05ATPicJ9vl8i3cVMr5L4Vl4+YQQUaTVmhpwB2AeW9jVItH4qLYCb2K2m1zwj I7Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xFlpEecq; 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 s94si5980128ybi.173.2020.05.29.13.43.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 May 2020 13:43:44 -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=xFlpEecq; 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]:38518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jelqx-000611-OR for patch@linaro.org; Fri, 29 May 2020 16:43:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46564) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jelqj-0005xr-HH for qemu-devel@nongnu.org; Fri, 29 May 2020 16:43:29 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]:42715) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jelqi-0000tb-9o for qemu-devel@nongnu.org; Fri, 29 May 2020 16:43:29 -0400 Received: by mail-pg1-x534.google.com with SMTP id 124so467915pgi.9 for ; Fri, 29 May 2020 13:43:27 -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; bh=U1T9E3y7ekxmt2kh9rxFnoBTMX0789LZtq9IU4HklTo=; b=xFlpEecq7Hxhem81IRvFJqh+Qzw2YtmPEIVdLFnD9zHwsU1HeuC6N523/xQ3ArH4Ve lle0XGDBWRWRfUvXiUhCdYHCwL7mqeOREDWDidmh0M8T9UEJ8z8diEPWCwDjq5LktLUx a1N290rOCByfoWpJhkwdDa7ow/3lE9mdaXj3eFEz1ykO6k+mveQMFH34pm53ziLG2jRL yQXE3jq2WMON9BBZxQQKw2uOs1FBWw776H3VcNJBqhbNnnzXzZ+mgX/I88QACIrDM/Q4 cci4b2P2a2YWF+Lt6ux5SI348ixM/jDzylwqDMVioVQ28VBZH7GcIuVRrRwaI1FvszHQ Ujvw== 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; bh=U1T9E3y7ekxmt2kh9rxFnoBTMX0789LZtq9IU4HklTo=; b=Lzzj/9kUWm/txfBlnaY+5/N5PhRQJ+Rp5V+q4FKuhruGEiP6RAV/JOoW1S9D91mKdp U5Ht8RnDRbNUA9RiJ/2Yl4xX90W4+7f2FWPq5k2yC+hLcTIduP42zfv4M0pQ9wGKOPMU jYW4hK3atDwGLot4SIeLbH3k5f4l8HLyONMxhp6mkxdM+P1LlU7ysMevtuvBTT8/LEVL ZxyMxRIuUFQwwnr6q0AAP7BntmtvefyLma/FFxX/h0OI1rLIsmuX4iHo/UJ0j+uCOTdG Fcd61Xa7JW3dWMM0+qfpwne8LKoRVIKdNokpSmCevtN7+NbYKt/EopYHiPc07q7KOT+B R4Iw== X-Gm-Message-State: AOAM530PuqHtAkXH7nEa22Mq2GsZnoKKUEzYghIRUVtq9AmYwsvIzyMQ FaHOxAhP5TdOOJ/I/jjGwgg4y+mkIcH1dA== X-Received: by 2002:a63:7052:: with SMTP id a18mr9831493pgn.39.1590785006450; Fri, 29 May 2020 13:43:26 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:75ac:d268:da04:dde4]) by smtp.gmail.com with ESMTPSA id t12sm282839pjf.3.2020.05.29.13.43.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2020 13:43:25 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v8 07/12] tests/vm: Add common Ubuntu python module Date: Fri, 29 May 2020 16:34:53 -0400 Message-Id: <20200529203458.1038-8-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200529203458.1038-1-robert.foley@linaro.org> References: <20200529203458.1038-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=robert.foley@linaro.org; helo=mail-pg1-x534.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_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 Zheng , philmd@redhat.com, alex.bennee@linaro.org, robert.foley@linaro.org, peter.puhov@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Add a common Ubuntu python module and make use of it with the ubuntu.i386 script. This is preparation for adding an Ubuntu script ubuntu.aarch64. Splitting out the common logic such as build_image() will reduce duplication. Signed-off-by: Robert Foley --- tests/vm/ubuntu.i386 | 46 +++++++++-------------------------- tests/vm/ubuntuvm.py | 58 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 34 deletions(-) create mode 100644 tests/vm/ubuntuvm.py -- 2.17.1 Tested-by: Philippe Mathieu-Daudé diff --git a/tests/vm/ubuntu.i386 b/tests/vm/ubuntu.i386 index 1570775335..c699eaf8d7 100755 --- a/tests/vm/ubuntu.i386 +++ b/tests/vm/ubuntu.i386 @@ -11,15 +11,22 @@ # the COPYING file in the top-level directory. # -import os import sys -import subprocess import basevm -import time +import ubuntuvm -class UbuntuX86VM(basevm.BaseVM): +DEFAULT_CONFIG = { + 'install_cmds' : "apt-get update,"\ + "apt-get build-dep -y qemu,"\ + "apt-get install -y libfdt-dev flex bison language-pack-en", +} + +class UbuntuX86VM(ubuntuvm.UbuntuVM): name = "ubuntu.i386" arch = "i386" + image_link="https://cloud-images.ubuntu.com/releases/bionic/"\ + "release-20191114/ubuntu-18.04-server-cloudimg-i386.img" + image_sha256="28969840626d1ea80bb249c08eef1a4533e8904aa51a327b40f37ac4b4ff04ef" BUILD_SCRIPT = """ set -e; cd $(mktemp -d); @@ -29,34 +36,5 @@ class UbuntuX86VM(basevm.BaseVM): make --output-sync {target} -j{jobs} {verbose}; """ - def build_image(self, img): - cimg = self._download_with_cache( - "https://cloud-images.ubuntu.com/releases/bionic/release-20191114/ubuntu-18.04-server-cloudimg-i386.img", - sha256sum="28969840626d1ea80bb249c08eef1a4533e8904aa51a327b40f37ac4b4ff04ef") - img_tmp = img + ".tmp" - subprocess.check_call(["cp", "-f", cimg, img_tmp]) - self.exec_qemu_img("resize", img_tmp, "50G") - self.boot(img_tmp, extra_args = [ - "-device", "VGA", - "-cdrom", self.gen_cloud_init_iso() - ]) - self.wait_ssh() - self.ssh_root_check("touch /etc/cloud/cloud-init.disabled") - self.ssh_root_check("apt-get update") - self.ssh_root_check("apt-get install -y cloud-initramfs-growroot") - # Don't check the status in case the guest hang up too quickly - self.ssh_root("sync && reboot") - time.sleep(5) - self.wait_ssh() - # The previous update sometimes doesn't survive a reboot, so do it again - self.ssh_root_check("sed -ie s/^#\ deb-src/deb-src/g /etc/apt/sources.list") - self.ssh_root_check("apt-get update") - self.ssh_root_check("apt-get build-dep -y qemu") - self.ssh_root_check("apt-get install -y libfdt-dev flex bison language-pack-en") - self.ssh_root("poweroff") - self.wait() - os.rename(img_tmp, img) - return 0 - if __name__ == "__main__": - sys.exit(basevm.main(UbuntuX86VM)) + sys.exit(basevm.main(UbuntuX86VM, DEFAULT_CONFIG)) diff --git a/tests/vm/ubuntuvm.py b/tests/vm/ubuntuvm.py new file mode 100644 index 0000000000..96f29dcc15 --- /dev/null +++ b/tests/vm/ubuntuvm.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 +# +# Ubuntu VM testing library +# +# Copyright 2020 Linaro +# +# Authors: +# Robert Foley +# +# This code is licensed under the GPL version 2 or later. See +# the COPYING file in the top-level directory. + +import os +import subprocess +import basevm + +class UbuntuVM(basevm.BaseVM): + + def __init__(self, args, config=None): + self.login_prompt = "ubuntu-{}-guest login:".format(self.arch) + basevm.BaseVM.__init__(self, args, config) + + def build_image(self, img): + """Build an Ubuntu VM image. The child class will + define the install_cmds to init the VM.""" + os_img = self._download_with_cache(self.image_link, + sha256sum=self.image_sha256) + img_tmp = img + ".tmp" + subprocess.check_call(["cp", "-f", os_img, img_tmp]) + self.exec_qemu_img("resize", img_tmp, "+50G") + ci_img = self.gen_cloud_init_iso() + + self.boot(img_tmp, extra_args = [ "-device", "VGA", "-cdrom", ci_img, ]) + + # First command we issue is fix for slow ssh login. + self.wait_ssh(wait_root=True, + cmd="chmod -x /etc/update-motd.d/*") + # Wait for cloud init to finish + self.wait_ssh(wait_root=True, + cmd="ls /var/lib/cloud/instance/boot-finished") + self.ssh_root("touch /etc/cloud/cloud-init.disabled") + # Disable auto upgrades. + # We want to keep the VM system state stable. + self.ssh_root('sed -ie \'s/"1"/"0"/g\' '\ + '/etc/apt/apt.conf.d/20auto-upgrades') + self.ssh_root("sed -ie s/^#\ deb-src/deb-src/g /etc/apt/sources.list") + + # If the user chooses not to do the install phase, + # then we will jump right to the graceful shutdown + if self._config['install_cmds'] != "": + # Issue the install commands. + # This can be overriden by the user in the config .yml. + install_cmds = self._config['install_cmds'].split(',') + for cmd in install_cmds: + self.ssh_root(cmd) + self.graceful_shutdown() + os.rename(img_tmp, img) + return 0 From patchwork Fri May 29 20:34:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187329 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp932782ilb; Fri, 29 May 2020 13:50:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySQrlHHw+hChe0XgRBV2indQE0Zqkgr9xy3qakFW7a18WHhDHBdbEe/thhYGPKspYQXPeo X-Received: by 2002:a25:ca82:: with SMTP id a124mr14973111ybg.310.1590785449974; Fri, 29 May 2020 13:50:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590785449; cv=none; d=google.com; s=arc-20160816; b=M28SK4Ik1GRnKvIwrWwjQkiYXZbW6dGKUKHUS4wMBFL2QLUYr9THBGgkxrQt5lP2Km /tUv65c7qKabwL274hOAmijU+oPY/4KJeUAo/z9Ejcf3Q6ISqev5c/0mohKJ1Cv7Yk0B ya0e5/GhhCMYTtBdnYVWkYBE8leWNOGvmau0Nuo3GnXIYaqVPN0sppg7s9W7US5MIPCz 17GkfC8s692f8u4ujo37EVtz6WGopIEpLy+FmoNYBlbCWtD9yAC2z7a2Q2EsUilWFFgn SP1u4fjGLtsvgkYI8frezrRe55FTCDK0QofmKLv3mm/EFK9U+Jd4F0ZwrcDPv76dVgBx //jQ== 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:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=1vkWlRUwahmUDZ44eD2vdqHLmuaKTxgx0yS9kGx9BF4=; b=I47AVHvkXqCEJZ6v04GqMdNDL5gUOkIf5tAGR9QC+pwfr02Zv/BPgmY+TOq7ZBku2z rUgVVmPN7IgIcjj2SvEOY7wBzgviF45ODEl42dW/twZBUXQiYk3FVebbs3hEGHmXF3uk zNNsJYV8DMnDwz2+pOEHKVJZCXbP3D86w4nafTMK1+Edxyls09WOw5sWo3tNvX5W/1Gi bCXcoOz0AICEV7bt133TgD1t29udSKTHAKrPeEwB7pHX7mmeIOQ1PrsUn6wFRYtugNB+ 1utuFv04Qs391dbpusrumYQsU/VmIXq9M6Rt8jTtS7qAZ4JDjK45wn9Zn8kEiIBIMRiI g1QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QcmTaF+M; 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 m82si6380278ybc.96.2020.05.29.13.50.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 May 2020 13:50:49 -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=QcmTaF+M; 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]:33288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jelxp-0008Ck-DK for patch@linaro.org; Fri, 29 May 2020 16:50:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jelqm-00062C-4y for qemu-devel@nongnu.org; Fri, 29 May 2020 16:43:32 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]:34091) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jelqk-0000ua-Hd for qemu-devel@nongnu.org; Fri, 29 May 2020 16:43:31 -0400 Received: by mail-pg1-x52d.google.com with SMTP id m1so484664pgk.1 for ; Fri, 29 May 2020 13:43:30 -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; bh=1vkWlRUwahmUDZ44eD2vdqHLmuaKTxgx0yS9kGx9BF4=; b=QcmTaF+Mr1zI/8EQ8GpcXwQ7RF8F5CD1mfKC9wPauQrDGvICjmc7Q5tP6mfz+DzxNm tUEKiRU+GeGWlL/H2XPfyNTc8dSYfWE1J2LfhTcTpLEGVRPc5h3BoCB3QaRSZFY1QLtC vInvCJc5VQ5ZCSJKCw2asWqCJw9ARG0zUl9FqZ8GR41tEQpWe8KGlG/uHE/mEHgkVID8 ZO6xfNGEOiUjFSfKjnDOgHrxK0b7xPpSN6jJkbBcwhH6BMa+9z2NdeJC6dt2vUTALnRz 9/NcGnDc49NmRmzOB4Zi29+g3L432IAiAbIyeWlxNSyzhuWRcXXzP7JQ0QQI9dLADgs0 7DvA== 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; bh=1vkWlRUwahmUDZ44eD2vdqHLmuaKTxgx0yS9kGx9BF4=; b=TmNcdJ0u//DQ8kioTrv1Z5dkwcwqVFosG3qL7U5smeNGL8Nn5agB+VfZgMWxTWY1PC m8IIfY1GWmB4M6yM0ofAEl1yQvxIEFGWtDbe+xeCsnDeIt8sX0NkZw052yER/ZL2Gv3C 5ZyRBDj6HEVgYeFPQPl9PB+VoUNblgnA/xCmThmRPIosm29ms4wGyiVPeYlR+eILNSZ+ pQ4PUcwpBR0fAZ/LXUFoFGIKvttT8G5YcF6MmJxRZlC/KW5oQaHnO0AIjRu4YSeUhE5K llgMbDHlTK9eoIlFJ0rWm3hg2K8r5tHpyE637PaXnaaOQQS/lCK6d6CQGT6jIMMijK+8 19vQ== X-Gm-Message-State: AOAM532oDmyXgXV2nLBlgQ2Q0adNYQjjL2oPvZdjLBABA4MOc2S1qV7H OqscK3LeERAuTe7LfWLLszdSFNZDNvV8Og== X-Received: by 2002:a63:2248:: with SMTP id t8mr9978749pgm.113.1590785008532; Fri, 29 May 2020 13:43:28 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:75ac:d268:da04:dde4]) by smtp.gmail.com with ESMTPSA id t12sm282839pjf.3.2020.05.29.13.43.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2020 13:43:27 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v8 08/12] tests/vm: Added a new script for ubuntu.aarch64. Date: Fri, 29 May 2020 16:34:54 -0400 Message-Id: <20200529203458.1038-9-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200529203458.1038-1-robert.foley@linaro.org> References: <20200529203458.1038-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=robert.foley@linaro.org; helo=mail-pg1-x52d.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_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 Zheng , philmd@redhat.com, alex.bennee@linaro.org, robert.foley@linaro.org, peter.puhov@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" ubuntu.aarch64 provides a script to create an Ubuntu 18.04 VM. Another new file is also added aarch64vm.py, which is a module with common methods used by aarch64 VMs, such as how to create the flash images. Signed-off-by: Robert Foley Reviewed-by: Peter Puhov --- configure | 20 +++++++ tests/vm/Makefile.include | 11 ++++ tests/vm/aarch64vm.py | 106 ++++++++++++++++++++++++++++++++++++++ tests/vm/basevm.py | 12 +++++ tests/vm/ubuntu.aarch64 | 68 ++++++++++++++++++++++++ 5 files changed, 217 insertions(+) create mode 100644 tests/vm/aarch64vm.py create mode 100755 tests/vm/ubuntu.aarch64 -- 2.17.1 diff --git a/configure b/configure index d82de47fdd..8a286e75a5 100755 --- a/configure +++ b/configure @@ -411,6 +411,7 @@ prefix="/usr/local" mandir="\${prefix}/share/man" datadir="\${prefix}/share" firmwarepath="\${prefix}/share/qemu-firmware" +efi_aarch64="" qemu_docdir="\${prefix}/share/doc/qemu" bindir="\${prefix}/bin" libdir="\${prefix}/lib" @@ -1099,6 +1100,8 @@ for opt do ;; --firmwarepath=*) firmwarepath="$optarg" ;; + --efi-aarch64=*) efi_aarch64="$optarg" + ;; --host=*|--build=*|\ --disable-dependency-tracking|\ --sbindir=*|--sharedstatedir=*|\ @@ -1753,6 +1756,7 @@ Advanced options (experts only): --sysconfdir=PATH install config in PATH$confsuffix --localstatedir=PATH install local state in PATH (set at runtime on win32) --firmwarepath=PATH search PATH for firmware files + --efi-aarch64=PATH PATH of efi file to use for aarch64 VMs. --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix] --with-pkgversion=VERS use specified string as sub-version of the package --enable-debug enable common debug build options @@ -3548,6 +3552,20 @@ EOF fi fi +############################################ +# efi-aarch64 probe +# Check for efi files needed by aarch64 VMs. +# By default we will use the efi included with QEMU. +# Allow user to override the path for efi also. +if ! test -f "$efi_aarch64"; then + if test -f $source_path/pc-bios/edk2-aaarch64-code.fd.bz2; then + # valid after build + efi_aarch64=$PWD/pc-bios/edk2-aarch64-code.fd + else + efi_aarch64="" + fi +fi + ########################################## # libcap-ng library probe if test "$cap_ng" != "no" ; then @@ -6604,6 +6622,7 @@ if test "$docs" != "no"; then echo "sphinx-build $sphinx_build" fi echo "genisoimage $genisoimage" +echo "efi_aarch64 $efi_aarch64" echo "python_yaml $python_yaml" echo "slirp support $slirp $(echo_version $slirp $slirp_version)" if test "$slirp" != "no" ; then @@ -7667,6 +7686,7 @@ echo "PYTHON=$python" >> $config_host_mak echo "SPHINX_BUILD=$sphinx_build" >> $config_host_mak echo "SPHINX_WERROR=$sphinx_werror" >> $config_host_mak echo "GENISOIMAGE=$genisoimage" >> $config_host_mak +echo "EFI_AARCH64=$efi_aarch64" >> $config_host_mak echo "PYTHON_YAML=$python_yaml" >> $config_host_mak echo "CC=$cc" >> $config_host_mak if $iasl -h > /dev/null 2>&1; then diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include index f6c3892bb2..cc71e6ed0a 100644 --- a/tests/vm/Makefile.include +++ b/tests/vm/Makefile.include @@ -5,6 +5,9 @@ IMAGES := freebsd netbsd openbsd centos fedora ifneq ($(GENISOIMAGE),) IMAGES += ubuntu.i386 centos +ifneq ($(EFI_AARCH64),) +IMAGES += ubuntu.aarch64 +endif endif IMAGES_DIR := $(HOME)/.cache/qemu-vm/images @@ -23,6 +26,11 @@ vm-help vm-test: ifneq ($(GENISOIMAGE),) @echo " vm-build-centos - Build QEMU in CentOS VM, with Docker" @echo " vm-build-ubuntu.i386 - Build QEMU in ubuntu i386 VM" +ifneq ($(EFI_AARCH64),) + @echo " vm-build-ubuntu.aarch64 - Build QEMU in ubuntu aarch64 VM" +else + @echo " (install qemu-efi-aarch64 to build centos/ubuntu aarch64 images.)" +endif else @echo " (install genisoimage to build centos/ubuntu images)" endif @@ -65,6 +73,7 @@ $(IMAGES_DIR)/%.img: $(SRC_PATH)/tests/vm/% \ $(if $(V)$(DEBUG), --debug) \ $(if $(GENISOIMAGE),--genisoimage $(GENISOIMAGE)) \ $(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \ + $(if $(EFI_AARCH64),--efi-aarch64 $(EFI_AARCH64)) \ --image "$@" \ --force \ --build-image $@, \ @@ -80,6 +89,7 @@ vm-build-%: $(IMAGES_DIR)/%.img $(if $(J),--jobs $(J)) \ $(if $(V),--verbose) \ $(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \ + $(if $(EFI_AARCH64),--efi-aarch64 $(EFI_AARCH64)) \ --image "$<" \ $(if $(BUILD_TARGET),--build-target $(BUILD_TARGET)) \ --snapshot \ @@ -102,6 +112,7 @@ vm-boot-ssh-%: $(IMAGES_DIR)/%.img $(if $(J),--jobs $(J)) \ $(if $(V)$(DEBUG), --debug) \ $(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \ + $(if $(EFI_AARCH64),--efi-aarch64 $(EFI_AARCH64)) \ --image "$<" \ --interactive \ false, \ diff --git a/tests/vm/aarch64vm.py b/tests/vm/aarch64vm.py new file mode 100644 index 0000000000..bb04cb19c9 --- /dev/null +++ b/tests/vm/aarch64vm.py @@ -0,0 +1,106 @@ +#!/usr/bin/env python3 +# +# VM testing aarch64 library +# +# Copyright 2020 Linaro +# +# Authors: +# Robert Foley +# +# This code is licensed under the GPL version 2 or later. See +# the COPYING file in the top-level directory. +# +import os +import sys +import subprocess +import basevm +from qemu.accel import kvm_available + +# This is the config needed for current version of QEMU. +# This works for both kvm and tcg. +CURRENT_CONFIG = { + 'cpu' : "max", + 'machine' : "virt,gic-version=max", +} + +# The minimum minor version of QEMU we will support with aarch64 VMs is 3. +# QEMU versions less than 3 have various issues running these VMs. +QEMU_AARCH64_MIN_VERSION = 3 + +# The DEFAULT_CONFIG will default to a version of +# parameters that works for backwards compatibility. +DEFAULT_CONFIG = {'kvm' : {'cpu' : "host", + 'machine' : "virt,gic-version=host"}, + 'tcg' : {'cpu' : "cortex-a57", + 'machine' : "virt"}, +} + +def get_config_defaults(vmcls, default_config): + """Fetch the configuration defaults for this VM, + taking into consideration the defaults for + aarch64 first, followed by the defaults for this VM.""" + config = default_config + config.update(aarch_get_config_defaults(vmcls)) + return config + +def aarch_get_config_defaults(vmcls): + """Set the defaults for current version of QEMU.""" + config = CURRENT_CONFIG + args, argv = basevm.parse_args(vmcls) + qemu_path = basevm.get_qemu_path(vmcls.arch, args.build_path) + qemu_version = basevm.get_qemu_version(qemu_path) + if qemu_version < QEMU_AARCH64_MIN_VERSION: + error = "\nThis major version of QEMU {} is to old for aarch64 VMs.\n"\ + "The major version must be at least {}.\n"\ + "To continue with the current build of QEMU, "\ + "please restart with QEMU_LOCAL=1 .\n" + print(error.format(qemu_version, QEMU_AARCH64_MIN_VERSION)) + exit(1) + if qemu_version == QEMU_AARCH64_MIN_VERSION: + # We have an older version of QEMU, + # set the config values for backwards compatibility. + if kvm_available('aarch64'): + config.update(DEFAULT_CONFIG['kvm']) + else: + config.update(DEFAULT_CONFIG['tcg']) + return config + +def create_flash_images(flash_dir="./", efi_img=""): + """Creates the appropriate pflash files + for an aarch64 VM.""" + flash0_path = get_flash_path(flash_dir, "flash0") + flash1_path = get_flash_path(flash_dir, "flash1") + fd_null = open(os.devnull, 'w') + subprocess.check_call(["dd", "if=/dev/zero", "of={}".format(flash0_path), + "bs=1M", "count=64"], + stdout=fd_null, stderr=subprocess.STDOUT) + # A reliable way to get the QEMU EFI image is via an installed package or + # via the bios included with qemu. + if not os.path.exists(efi_img): + sys.stderr.write("*** efi argument is invalid ({})\n".format(efi_img)) + sys.stderr.write("*** please check --efi-aarch64 argument or "\ + "install qemu-efi-aarch64 package\n") + exit(3) + subprocess.check_call(["dd", "if={}".format(efi_img), + "of={}".format(flash0_path), + "conv=notrunc"], + stdout=fd_null, stderr=subprocess.STDOUT) + subprocess.check_call(["dd", "if=/dev/zero", + "of={}".format(flash1_path), + "bs=1M", "count=64"], + stdout=fd_null, stderr=subprocess.STDOUT) + fd_null.close() + +def get_pflash_args(flash_dir="./"): + """Returns a string that can be used to + boot qemu using the appropriate pflash files + for aarch64.""" + flash0_path = get_flash_path(flash_dir, "flash0") + flash1_path = get_flash_path(flash_dir, "flash1") + pflash_args_str = "-drive file={},format=raw,if=pflash "\ + "-drive file={},format=raw,if=pflash" + pflash_args = pflash_args_str.format(flash0_path, flash1_path) + return pflash_args.split(" ") + +def get_flash_path(flash_dir, name): + return os.path.join(flash_dir, "{}.img".format(name)) diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index 1aab9e3a24..f406a20466 100644 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -92,6 +92,7 @@ class BaseVM(object): self._guest = None self._genisoimage = args.genisoimage self._build_path = args.build_path + self._efi_aarch64 = args.efi_aarch64 # Allow input config to override defaults. self._config = DEFAULT_CONFIG.copy() if config != None: @@ -496,6 +497,14 @@ def get_qemu_path(arch, build_path=None): qemu_path = "qemu-system-" + arch return qemu_path +def get_qemu_version(qemu_path): + """Get the version number from the current QEMU, + and return the major number.""" + output = subprocess.check_output([qemu_path, '--version']) + version_line = output.decode("utf-8") + version_num = re.split(' |\(', version_line)[3].split('.')[0] + return int(version_num) + def parse_config(config, args): """ Parse yaml config and populate our config structure. The yaml config allows the user to override the @@ -573,6 +582,9 @@ def parse_args(vmcls): parser.add_option("--build-path", default=None, help="Path of build directory, "\ "for using build tree QEMU binary. ") + parser.add_option("--efi-aarch64", + default="/usr/share/qemu-efi-aarch64/QEMU_EFI.fd", + help="Path to efi image for aarch64 VMs.") parser.disable_interspersed_args() return parser.parse_args() diff --git a/tests/vm/ubuntu.aarch64 b/tests/vm/ubuntu.aarch64 new file mode 100755 index 0000000000..6f903c029c --- /dev/null +++ b/tests/vm/ubuntu.aarch64 @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 +# +# Ubuntu aarch64 image +# +# Copyright 2020 Linaro +# +# Authors: +# Robert Foley +# Originally based on ubuntu.i386 Fam Zheng +# +# This code is licensed under the GPL version 2 or later. See +# the COPYING file in the top-level directory. +# + +import sys +import basevm +import aarch64vm +import ubuntuvm + +DEFAULT_CONFIG = { + 'cpu' : "cortex-a57", + 'machine' : "virt,gic-version=3", + 'install_cmds' : "apt-get update,"\ + "apt-get build-dep -y --arch-only qemu,"\ + "apt-get install -y libfdt-dev flex bison pkg-config", + # We increase beyond the default time since during boot + # it can take some time (many seconds) to log into the VM + # especially using softmmu. + 'ssh_timeout' : 60, +} + +class UbuntuAarch64VM(ubuntuvm.UbuntuVM): + name = "ubuntu.aarch64" + arch = "aarch64" + image_name = "ubuntu-18.04-server-cloudimg-arm64.img" + image_link = "https://cloud-images.ubuntu.com/releases/18.04/release/" + image_name + image_sha256="0fdcba761965735a8a903d8b88df8e47f156f48715c00508e4315c506d7d3cb1" + BUILD_SCRIPT = """ + set -e; + cd $(mktemp -d); + sudo chmod a+r /dev/vdb; + tar --checkpoint=.10 -xf /dev/vdb; + ./configure {configure_opts}; + make --output-sync {target} -j{jobs} {verbose}; + """ + def boot(self, img, extra_args=None): + aarch64vm.create_flash_images(self._tmpdir, self._efi_aarch64) + default_args = aarch64vm.get_pflash_args(self._tmpdir) + if extra_args: + extra_args.extend(default_args) + else: + extra_args = default_args + # We always add these performance tweaks + # because without them, we boot so slowly that we + # can time out finding the boot efi device. + if '-smp' not in extra_args and \ + '-smp' not in self._config['extra_args'] and \ + '-smp' not in self._args: + # Only add if not already there to give caller option to change it. + extra_args.extend(["-smp", "8"]) + + # We have overridden boot() since aarch64 has additional parameters. + # Call down to the base class method. + super(UbuntuAarch64VM, self).boot(img, extra_args=extra_args) + +if __name__ == "__main__": + defaults = aarch64vm.get_config_defaults(UbuntuAarch64VM, DEFAULT_CONFIG) + sys.exit(basevm.main(UbuntuAarch64VM, defaults)) From patchwork Fri May 29 20:34:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187326 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp931259ilb; Fri, 29 May 2020 13:48:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytaHbToY7QktYXAf2GUpb21Z7LwflNNNtkACj8L/SgJI8Kh0jOf/U/XC8/qchxDPzFU5/4 X-Received: by 2002:a25:ce4d:: with SMTP id x74mr16234475ybe.58.1590785301834; Fri, 29 May 2020 13:48:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590785301; cv=none; d=google.com; s=arc-20160816; b=nEAUJrOWXaxpOrZIYjplybOlipYnrRg+bpURW0bFdfF6+pM68yRzE47Hx7wMEwpr1K 6pPo46EIt19ZP5tM2AoaOmQHrvXxNHVrShGi/Vf/MqGaCFwYVtMtAc+crlsEKbZCpsU5 XYa6Sh68kAsV3uMnSvCGHwm6SSo0wQFru4gX2+gSkYlR+IZf4QIwuIuDg1U9vvltEvJ3 Td1Bujbk+4XNG/3UN1xumpLVOwlrooIpDvhe4YVOkJ/lfjIEJ6VcRiWypAxDIwlJ2Z23 jJmmxWVgnDM/CYyKplUcmTBJkFWdi3qkDerr5D0P6W0Mb9ceB1EUgpc/Eyu6LGOJpsbz ldKg== 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=lFhhMNHwSiIDPPWYqB+F5lFZw3zbpbsD8fGZ27DRWl4=; b=uwWDRULG/28knqayYQf3Mwc1Zdjl8BQWAFAz6odTfUo4g2BexssVbTtDlUAvYkZd4W lyTFiGlTRdsMnuCAJHp8Pog9ETWx4kyg3sBE004ZHtoq47JWbMix8JnEVo4wBWPMgtZ+ ptCJj3zuKjRhE/jEG7HTS4Rm0Q5BqtJvz/UIJJYpYBhKxMe2tFEqXm5TzOhzniTtPMbc WePRaxbOSAmdmROneL1ppVrglL317D4/ZfDoy64aT5pW8283Hw8RNW51IwAvshZaFqEj nr+KZIxV+Pe+RM5wENaFeaJY5GQWqI9tojnClUThbzNmBFIn5wOyHKSMYDTmtGSjBNhj 7A7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=m0Or8Vkf; 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 m8si9109510ybf.310.2020.05.29.13.48.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 May 2020 13:48:21 -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=m0Or8Vkf; 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]:54562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jelvR-0005Gd-89 for patch@linaro.org; Fri, 29 May 2020 16:48:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46584) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jelqo-00067F-IJ for qemu-devel@nongnu.org; Fri, 29 May 2020 16:43:34 -0400 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]:35707) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jelqm-0000wN-PP for qemu-devel@nongnu.org; Fri, 29 May 2020 16:43:34 -0400 Received: by mail-pg1-x529.google.com with SMTP id o6so480959pgh.2 for ; Fri, 29 May 2020 13:43:32 -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=lFhhMNHwSiIDPPWYqB+F5lFZw3zbpbsD8fGZ27DRWl4=; b=m0Or8VkfogD+wDMeGPuz9A3CkC3I1LEovf+vOt+Iyk4tHSJ4olji1R6SpjIW/jvVzp QIjYIjwMmFxP647sJTxpC7ZA5NWFVpGjoOuuIXHNhVB5mfDGfMLtvM9gb5DCK0xJcGcC c8dsfrSJlKPMk+lDuJTV7BW3VeSXXDggvhEmabudvMp+fQastJMx3oyvuBEWLrswMEp2 8mBa02y3PG/aM4f0fM4He24NFeUe0bAytZDz4ZthNAYCLqQvZJnmWDA9LCO2rBFDtnZG 143wi8eLZCzD3MEYVEZABGhkR5mAwgN35SY0Gqgsp0ll6Y6ZpZrvgAB1fMQMhy5LcvDs 1pGg== 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=lFhhMNHwSiIDPPWYqB+F5lFZw3zbpbsD8fGZ27DRWl4=; b=Uy5gjpMHyz4wFBTls5hz8+Cvjb1JDHvi/bFvguKgAVmQ75bhxlNQ9qGy5XngTrLqva 1tt1oaxroH9p71lVANTMucdFlvUnRcRxL/K2DiY8B1ekSZQorpiPAJQva8Ki8BfUS7XK OpWSeJtqLF8+udTPFKhIg88EVvfg4vaWliJozdVsl4xFHaDxBz3ub01SM8nYT6QKgYhg C4JVz1ULWUcu0vIgIntv2mz6sRKx/mtLBVEnBklK6QrhNkfsEc0vFFz5HUYFc7Qju3zc Eox1O3tNiAWMoOIAiFcHiAHIeXPO8wwaoigN5au6IQ587VvtSyuWsFyLe2TnrV+FGIoe v4Dw== X-Gm-Message-State: AOAM533IQvpNR0ACbg0xNqNMghQmCfbxoTeppXPHeZ2vvS6XjNCNB2n+ z3Wbw7bAiJO3VGEb8LAO4xjji7fBs2JfFQ== X-Received: by 2002:a65:56ca:: with SMTP id w10mr9858217pgs.69.1590785010629; Fri, 29 May 2020 13:43:30 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:75ac:d268:da04:dde4]) by smtp.gmail.com with ESMTPSA id t12sm282839pjf.3.2020.05.29.13.43.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2020 13:43:29 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v8 09/12] tests/vm: Added a new script for centos.aarch64. Date: Fri, 29 May 2020 16:34:55 -0400 Message-Id: <20200529203458.1038-10-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200529203458.1038-1-robert.foley@linaro.org> References: <20200529203458.1038-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=robert.foley@linaro.org; helo=mail-pg1-x529.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_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 Zheng , philmd@redhat.com, alex.bennee@linaro.org, robert.foley@linaro.org, peter.puhov@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" centos.aarch64 creates a CentOS 8 image. Also added a new kickstart script used to build the centos.aarch64 image. Signed-off-by: Robert Foley Reviewed-by: Peter Puhov Reviewed-by: Alex Bennée --- tests/vm/Makefile.include | 3 +- tests/vm/centos-8-aarch64.ks | 51 ++++++++ tests/vm/centos.aarch64 | 227 +++++++++++++++++++++++++++++++++++ 3 files changed, 280 insertions(+), 1 deletion(-) create mode 100644 tests/vm/centos-8-aarch64.ks create mode 100755 tests/vm/centos.aarch64 -- 2.17.1 diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include index cc71e6ed0a..8cccfaf95d 100644 --- a/tests/vm/Makefile.include +++ b/tests/vm/Makefile.include @@ -6,7 +6,7 @@ IMAGES := freebsd netbsd openbsd centos fedora ifneq ($(GENISOIMAGE),) IMAGES += ubuntu.i386 centos ifneq ($(EFI_AARCH64),) -IMAGES += ubuntu.aarch64 +IMAGES += ubuntu.aarch64 centos.aarch64 endif endif @@ -28,6 +28,7 @@ ifneq ($(GENISOIMAGE),) @echo " vm-build-ubuntu.i386 - Build QEMU in ubuntu i386 VM" ifneq ($(EFI_AARCH64),) @echo " vm-build-ubuntu.aarch64 - Build QEMU in ubuntu aarch64 VM" + @echo " vm-build-centos.aarch64 - Build QEMU in CentOS aarch64 VM" else @echo " (install qemu-efi-aarch64 to build centos/ubuntu aarch64 images.)" endif diff --git a/tests/vm/centos-8-aarch64.ks b/tests/vm/centos-8-aarch64.ks new file mode 100644 index 0000000000..fd6ebe4d49 --- /dev/null +++ b/tests/vm/centos-8-aarch64.ks @@ -0,0 +1,51 @@ +# CentOS aarch64 image kickstart file. +# This file is used by the CentOS installer to +# script the generation of the image. +# +# Copyright 2020 Linaro +# +ignoredisk --only-use=vda +# System bootloader configuration +bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=vda +autopart --type=plain +# Partition clearing information +clearpart --linux --initlabel --drives=vda +# Use text mode install +text +repo --name="AppStream" --baseurl=file:///run/install/repo/AppStream +# Use CDROM installation media +cdrom +# Keyboard layouts +keyboard --vckeymap=us --xlayouts='' +# System language +lang en_US.UTF-8 + +# Network information +network --bootproto=dhcp --device=enp0s1 --onboot=off --ipv6=auto --no-activate +network --hostname=localhost.localdomain +# Run the Setup Agent on first boot +firstboot --enable +# Do not configure the X Window System +skipx +# System services +services --enabled="chronyd" +# System timezone +timezone America/New_York --isUtc + +# Shutdown after installation is complete. +shutdown + +%packages +@^server-product-environment +kexec-tools + +%end + +%addon com_redhat_kdump --enable --reserve-mb='auto' + +%end +%anaconda +pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty +pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok +pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty +%end diff --git a/tests/vm/centos.aarch64 b/tests/vm/centos.aarch64 new file mode 100755 index 0000000000..d5232ecdb8 --- /dev/null +++ b/tests/vm/centos.aarch64 @@ -0,0 +1,227 @@ +#!/usr/bin/env python3 +# +# Centos aarch64 image +# +# Copyright 2020 Linaro +# +# Authors: +# Robert Foley +# Originally based on ubuntu.aarch64 +# +# This code is licensed under the GPL version 2 or later. See +# the COPYING file in the top-level directory. +# + +import os +import sys +import subprocess +import basevm +import time +import traceback +import aarch64vm + +DEFAULT_CONFIG = { + 'cpu' : "max", + 'machine' : "virt,gic-version=max", + 'install_cmds' : "yum install -y make git python3 gcc gcc-c++ flex bison, "\ + "yum install -y glib2-devel pixman-devel zlib-devel, "\ + "yum install -y perl-Test-Harness, "\ + "alternatives --set python /usr/bin/python3, "\ + "sudo dnf config-manager "\ + "--add-repo=https://download.docker.com/linux/centos/docker-ce.repo,"\ + "sudo dnf install --nobest -y docker-ce.aarch64,"\ + "systemctl enable docker", + # We increase beyond the default time since during boot + # it can take some time (many seconds) to log into the VM. + 'ssh_timeout' : 60, +} + +class CentosAarch64VM(basevm.BaseVM): + name = "centos.aarch64" + arch = "aarch64" + login_prompt = "localhost login:" + prompt = '[root@localhost ~]#' + image_name = "CentOS-8-aarch64-1905-dvd1.iso" + image_link = "http://mirrors.usc.edu/pub/linux/distributions/centos/8.0.1905/isos/aarch64/" + image_link += image_name + BUILD_SCRIPT = """ + set -e; + cd $(mktemp -d); + sudo chmod a+r /dev/vdb; + tar --checkpoint=.10 -xf /dev/vdb; + ./configure {configure_opts}; + make --output-sync {target} -j{jobs} {verbose}; + """ + def set_key_perm(self): + """Set permissions properly on certain files to allow + ssh access.""" + self.console_wait_send(self.prompt, + "/usr/sbin/restorecon -R -v /root/.ssh\n") + self.console_wait_send(self.prompt, + "/usr/sbin/restorecon -R -v "\ + "/home/{}/.ssh\n".format(self._config["guest_user"])) + + def create_kickstart(self): + """Generate the kickstart file used to generate the centos image.""" + # Start with the template for the kickstart. + ks_file = "../tests/vm/centos-8-aarch64.ks" + subprocess.check_call("cp {} ./ks.cfg".format(ks_file), shell=True) + # Append the ssh keys to the kickstart file + # as the post processing phase of installation. + with open("ks.cfg", "a") as f: + # Add in the root pw and guest user. + rootpw = "rootpw --plaintext {}\n" + f.write(rootpw.format(self._config["root_pass"])) + add_user = "user --groups=wheel --name={} "\ + "--password={} --plaintext\n" + f.write(add_user.format(self._config["guest_user"], + self._config["guest_pass"])) + # Add the ssh keys. + f.write("%post --log=/root/ks-post.log\n") + f.write("mkdir -p /root/.ssh\n") + addkey = 'echo "{}" >> /root/.ssh/authorized_keys\n' + addkey_cmd = addkey.format(self._config["ssh_pub_key"]) + f.write(addkey_cmd) + f.write('mkdir -p /home/{}/.ssh\n'.format(self._config["guest_user"])) + addkey = 'echo "{}" >> /home/{}/.ssh/authorized_keys\n' + addkey_cmd = addkey.format(self._config["ssh_pub_key"], + self._config["guest_user"]) + f.write(addkey_cmd) + f.write("%end\n") + # Take our kickstart file and create an .iso from it. + # The .iso will be provided to qemu as we boot + # from the install dvd. + # Anaconda will recognize the label "OEMDRV" and will + # start the automated installation. + gen_iso_img = 'genisoimage -output ks.iso -volid "OEMDRV" ks.cfg' + subprocess.check_call(gen_iso_img, shell=True) + + def wait_for_shutdown(self): + """We wait for qemu to shutdown the VM and exit. + While this happens we display the console view + for easier debugging.""" + # The image creation is essentially done, + # so whether or not the wait is successful we want to + # wait for qemu to exit (the self.wait()) before we return. + try: + self.console_wait("reboot: Power down") + except Exception as e: + sys.stderr.write("Exception hit\n") + if isinstance(e, SystemExit) and e.code == 0: + return 0 + traceback.print_exc() + finally: + self.wait() + + def build_base_image(self, dest_img): + """Run through the centos installer to create + a base image with name dest_img.""" + # We create the temp image, and only rename + # to destination when we are done. + img = dest_img + ".tmp" + # Create an empty image. + # We will provide this as the install destination. + qemu_img_create = "qemu-img create {} 50G".format(img) + subprocess.check_call(qemu_img_create, shell=True) + + # Create our kickstart file to be fed to the installer. + self.create_kickstart() + # Boot the install dvd with the params as our ks.iso + os_img = self._download_with_cache(self.image_link) + dvd_iso = "centos-8-dvd.iso" + subprocess.check_call(["cp", "-f", os_img, dvd_iso]) + extra_args = "-cdrom ks.iso" + extra_args += " -drive file={},if=none,id=drive1,cache=writeback" + extra_args += " -device virtio-blk,drive=drive1,bootindex=1" + extra_args = extra_args.format(dvd_iso).split(" ") + self.boot(img, extra_args=extra_args) + self.console_wait_send("change the selection", "\n") + # We seem to need to hit esc (chr(27)) twice to abort the + # media check, which takes a long time. + # Waiting a bit seems to be more reliable before hitting esc. + self.console_wait("Checking") + time.sleep(5) + self.console_wait_send("Checking", chr(27)) + time.sleep(5) + self.console_wait_send("Checking", chr(27)) + print("Found Checking") + # Give sufficient time for the installer to create the image. + self.console_init(timeout=7200) + self.wait_for_shutdown() + os.rename(img, dest_img) + print("Done with base image build: {}".format(dest_img)) + + def check_create_base_img(self, img_base, img_dest): + """Create a base image using the installer. + We will use the base image if it exists. + This helps cut down on install time in case we + need to restart image creation, + since the base image creation can take a long time.""" + if not os.path.exists(img_base): + print("Generate new base image: {}".format(img_base)) + self.build_base_image(img_base); + else: + print("Use existing base image: {}".format(img_base)) + # Save a copy of the base image and copy it to dest. + # which we will use going forward. + subprocess.check_call(["cp", img_base, img_dest]) + + def boot(self, img, extra_args=None): + aarch64vm.create_flash_images(self._tmpdir, self._efi_aarch64) + default_args = aarch64vm.get_pflash_args(self._tmpdir) + if extra_args: + extra_args.extend(default_args) + else: + extra_args = default_args + # We always add these performance tweaks + # because without them, we boot so slowly that we + # can time out finding the boot efi device. + if '-smp' not in extra_args and \ + '-smp' not in self._config['extra_args'] and \ + '-smp' not in self._args: + # Only add if not already there to give caller option to change it. + extra_args.extend(["-smp", "8"]) + # We have overridden boot() since aarch64 has additional parameters. + # Call down to the base class method. + super(CentosAarch64VM, self).boot(img, extra_args=extra_args) + + def build_image(self, img): + img_tmp = img + ".tmp" + self.check_create_base_img(img + ".base", img_tmp) + + # Boot the new image for the first time to finish installation. + self.boot(img_tmp) + self.console_init() + self.console_wait_send(self.login_prompt, "root\n") + self.console_wait_send("Password:", + "{}\n".format(self._config["root_pass"])) + + self.set_key_perm() + self.console_wait_send(self.prompt, "rpm -q centos-release\n") + enable_adapter = "sed -i 's/ONBOOT=no/ONBOOT=yes/g'" \ + " /etc/sysconfig/network-scripts/ifcfg-enp0s1\n" + self.console_wait_send(self.prompt, enable_adapter) + self.console_wait_send(self.prompt, "ifup enp0s1\n") + self.console_wait_send(self.prompt, + 'echo "qemu ALL=(ALL) NOPASSWD:ALL" | '\ + 'sudo tee /etc/sudoers.d/qemu\n') + self.console_wait(self.prompt) + + # Rest of the commands we issue through ssh. + self.wait_ssh(wait_root=True) + + # If the user chooses *not* to do the second phase, + # then we will jump right to the graceful shutdown + if self._config['install_cmds'] != "": + install_cmds = self._config['install_cmds'].split(',') + for cmd in install_cmds: + self.ssh_root(cmd) + self.ssh_root("poweroff") + self.wait_for_shutdown() + os.rename(img_tmp, img) + print("image creation complete: {}".format(img)) + return 0 + +if __name__ == "__main__": + defaults = aarch64vm.get_config_defaults(CentosAarch64VM, DEFAULT_CONFIG) + sys.exit(basevm.main(CentosAarch64VM, defaults)) From patchwork Fri May 29 20:34:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187328 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp932479ilb; Fri, 29 May 2020 13:50:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwtrXnGmpkCWD7Z0tVarCH1+b4TRQRw6k5+SezNY5Jj6JLy5WwQ7caOAQ6V16g9tz7iWup X-Received: by 2002:a25:2186:: with SMTP id h128mr15557975ybh.503.1590785419385; Fri, 29 May 2020 13:50:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590785419; cv=none; d=google.com; s=arc-20160816; b=BVlVZ4rppwLfwv8p1Yzu5ScHQC9blGyLaQnNhYcSkMMPDCGIdD8rO5NCj44/GjQo7X ZXv6gClAzUtpX9t5sm5T89ZaDUK01cIr3LbLtNGGNZheQrZEzuqgqFNHGx6UNk2a7kgA tHzHw3nX3dXrKdl5K5iEBn/CbqzbX+oj4lKn9DLFrUhoGbycPJrFCyF5vjQDx3Ck8iKZ 6A8gtK/+qr9KxGl6apl2dX73V0llsEVgl4hxBAyJnoCXZ1HZhQtBOdPcjeQKmmerUxfD 04Wb3IW5rF/QYYDIBVgOn12RyhLFcMuIxUJXkfsekOQeOOaXFp406RLgYu+3qXgRo5Hq Kasw== 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:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=Sw+TlGgfx3bLML4nEK/meujoerMmFhjNA+hcNz6SFHQ=; b=YGLdbO35WgIKAvBn8xggiKKiYnSQV+Ya+C/ct/y2FYy4qp06/X9h1P30XqW3rMQIjP ENzdG7cD1Y7LAIILElsOQvglUH4dDzPGb0IhRMSSl6Z7LtLqvx9QqXJFdoLHOEde/IOK ao8lCGPcW9FoRnL0nFcaziwlfmU8tDx3Ht29NHbUQglpINL4YbzVQLkMxVp0puHzdpo1 7CIg/xx+4dYSL0U3tHHfOLc8X3FaigcrRSJKJ3OyNVHs7NOVtHejT4RnWoSICnu9pOmn IIHSckTP1wqrFK4a9V+5wgm2gfitdyYiV9YINIaV+fbqGxMO7knRQdS0M/sQTjOkz44i tcSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=CBsCAKlO; 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 h133si8403800ybh.292.2020.05.29.13.50.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 May 2020 13:50: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=CBsCAKlO; 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]:59980 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jelxK-0007TJ-Ph for patch@linaro.org; Fri, 29 May 2020 16:50:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jelqq-0006An-4o for qemu-devel@nongnu.org; Fri, 29 May 2020 16:43:36 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:44536) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jelqo-0000yF-IZ for qemu-devel@nongnu.org; Fri, 29 May 2020 16:43:35 -0400 Received: by mail-pg1-x542.google.com with SMTP id p30so460954pgl.11 for ; Fri, 29 May 2020 13:43:34 -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; bh=Sw+TlGgfx3bLML4nEK/meujoerMmFhjNA+hcNz6SFHQ=; b=CBsCAKlOigUhr/oZHqFXHak7TRu+e8J9y5S+9JzNHcat7QKWExvlIFqvqQCdjpLVP+ +10DIYJkoQwpHoA7P/pvay3oCtSH4/Tio5x/+MEwwycX4xVDqE8b8Akv5Ms1qmqZyF2R CQP22EoM1tFDrrAITjj1mgUHsWYw42VrJD8PasEu7UC5IJp6pNOuDtuQ/yGCfZM/9LmY Pl7quteqAz3pmEoilsiSwQmlLNXFMuQ9gGX1DAUcrIUxGbgw4FgJjNcf/m+Tu53Jsr6O VYVU+KYBa5Vmmdv7ie7sXQ/pRPlGS93fOQzlRaJ37sFAob3Y/otnioQrM+L2ziZhVIro tOdA== 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; bh=Sw+TlGgfx3bLML4nEK/meujoerMmFhjNA+hcNz6SFHQ=; b=rYwBIRzlQkR89CmfwBBwCvnXbfKNXQ+bWLGPT0Aji/g/WQeba7G6EjLJbUUdWb0BGc U6YU7a2quqwTMKTXC5tzJX6d2aLanJ13ZDLOn3RxE+5p0TyVJ5+okfhmVlYhJrFWHBPH Q8JaVdVsJS4OC+hw95h67kyi5wVYYzCJk8Jb1r5mfqPqGxDV89BJz1awv9XnMPuyBVm7 hsHU58EzisI0AHq/V4nynT4OTssRoZ5mnDbktcpASufjrlx8FcbGZ5RWDNkou+H8VyLZ +z3VCRYMJsIVKIU4DUasapi10F5MrrHFzbZkzXRW/rQckqJpdPDheLr5u4K+QSCY6RnY Ieig== X-Gm-Message-State: AOAM533He1qgNmh7U4qsN3pfWa86UPT9uUNdxC11wrwoB0lNKd+Ht4r8 itjB3KVMKJ8qfGLlEQmqvbzhmoxXLxApdQ== X-Received: by 2002:a63:b957:: with SMTP id v23mr10214660pgo.262.1590785012718; Fri, 29 May 2020 13:43:32 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:75ac:d268:da04:dde4]) by smtp.gmail.com with ESMTPSA id t12sm282839pjf.3.2020.05.29.13.43.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2020 13:43:32 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v8 10/12] tests/vm: change scripts to use self._config Date: Fri, 29 May 2020 16:34:56 -0400 Message-Id: <20200529203458.1038-11-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200529203458.1038-1-robert.foley@linaro.org> References: <20200529203458.1038-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::542; envelope-from=robert.foley@linaro.org; helo=mail-pg1-x542.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_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 Zheng , philmd@redhat.com, alex.bennee@linaro.org, robert.foley@linaro.org, peter.puhov@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This change converts existing scripts to using for example self.ROOT_PASS, to self._config['root_pass']. We made similar changes for GUEST_USER, and GUEST_PASS. This allows us also to remove the change in basevm.py, which adds __getattr__ for backwards compatibility. Signed-off-by: Robert Foley Reviewed-by: Peter Puhov --- tests/vm/basevm.py | 11 ++--------- tests/vm/fedora | 17 +++++++++-------- tests/vm/freebsd | 16 ++++++++-------- tests/vm/netbsd | 19 ++++++++++--------- tests/vm/openbsd | 17 +++++++++-------- 5 files changed, 38 insertions(+), 42 deletions(-) -- 2.17.1 diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index f406a20466..b9d828423b 100644 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -183,13 +183,6 @@ class BaseVM(object): self.console_init(timeout=timeout) self.console_wait(wait_string) - def __getattr__(self, name): - # Support direct access to config by key. - # for example, access self._config['cpu'] by self.cpu - if name.lower() in self._config.keys(): - return self._config[name.lower()] - return object.__getattribute__(self, name) - def _download_with_cache(self, url, sha256sum=None, sha512sum=None): def check_sha256sum(fname): if not sha256sum: @@ -239,13 +232,13 @@ class BaseVM(object): return r def ssh(self, *cmd): - return self._ssh_do(self.GUEST_USER, cmd, False) + return self._ssh_do(self._config["guest_user"], cmd, False) def ssh_root(self, *cmd): return self._ssh_do("root", cmd, False) def ssh_check(self, *cmd): - self._ssh_do(self.GUEST_USER, cmd, True) + self._ssh_do(self._config["guest_user"], cmd, True) def ssh_root_check(self, *cmd): self._ssh_do("root", cmd, True) diff --git a/tests/vm/fedora b/tests/vm/fedora index bd9c6cf295..f536a92678 100755 --- a/tests/vm/fedora +++ b/tests/vm/fedora @@ -109,20 +109,20 @@ class FedoraVM(basevm.BaseVM): self.console_wait_send("7) [!] Root password", "7\n") self.console_wait("Password:") - self.console_send("%s\n" % self.ROOT_PASS) + self.console_send("%s\n" % self._config["root_pass"]) self.console_wait("Password (confirm):") - self.console_send("%s\n" % self.ROOT_PASS) + self.console_send("%s\n" % self._config["root_pass"]) self.console_wait_send("8) [ ] User creation", "8\n") self.console_wait_send("1) [ ] Create user", "1\n") self.console_wait_send("3) User name", "3\n") - self.console_wait_send("ENTER:", "%s\n" % self.GUEST_USER) + self.console_wait_send("ENTER:", "%s\n" % self._config["guest_user"]) self.console_wait_send("4) [ ] Use password", "4\n") self.console_wait_send("5) Password", "5\n") self.console_wait("Password:") - self.console_send("%s\n" % self.GUEST_PASS) + self.console_send("%s\n" % self._config["guest_pass"]) self.console_wait("Password (confirm):") - self.console_send("%s\n" % self.GUEST_PASS) + self.console_send("%s\n" % self._config["guest_pass"]) self.console_wait_send("7) Groups", "c\n") while True: @@ -140,7 +140,7 @@ class FedoraVM(basevm.BaseVM): if good: break time.sleep(10) - self.console_send("r\n" % self.GUEST_PASS) + self.console_send("r\n" % self._config["guest_pass"]) self.console_wait_send("'b' to begin install", "b\n") @@ -151,12 +151,13 @@ class FedoraVM(basevm.BaseVM): # setup qemu user prompt = " ~]$" - self.console_ssh_init(prompt, self.GUEST_USER, self.GUEST_PASS) + self.console_ssh_init(prompt, self._config["guest_user"], + self._config["guest_pass"]) self.console_wait_send(prompt, "exit\n") # setup root user prompt = " ~]#" - self.console_ssh_init(prompt, "root", self.ROOT_PASS) + self.console_ssh_init(prompt, "root", self._config["root_pass"]) self.console_sshd_config(prompt) # setup virtio-blk #1 (tarfile) diff --git a/tests/vm/freebsd b/tests/vm/freebsd index 298967fe9c..898393b58d 100755 --- a/tests/vm/freebsd +++ b/tests/vm/freebsd @@ -114,9 +114,9 @@ class FreeBSDVM(basevm.BaseVM): # post-install configuration self.console_wait("New Password:") - self.console_send("%s\n" % self.ROOT_PASS) + self.console_send("%s\n" % self._config["root_pass"]) self.console_wait("Retype New Password:") - self.console_send("%s\n" % self.ROOT_PASS) + self.console_send("%s\n" % self._config["root_pass"]) self.console_wait_send("Network Configuration", "\n") self.console_wait_send("IPv4", "y") @@ -135,9 +135,9 @@ class FreeBSDVM(basevm.BaseVM): # qemu user self.console_wait_send("Add User Accounts", "y") self.console_wait("Username") - self.console_send("%s\n" % self.GUEST_USER) + self.console_send("%s\n" % self._config["guest_user"]) self.console_wait("Full name") - self.console_send("%s\n" % self.GUEST_USER) + self.console_send("%s\n" % self._config["guest_user"]) self.console_wait_send("Uid", "\n") self.console_wait_send("Login group", "\n") self.console_wait_send("Login group", "\n") @@ -149,9 +149,9 @@ class FreeBSDVM(basevm.BaseVM): self.console_wait_send("Use an empty password", "\n") self.console_wait_send("Use a random password", "\n") self.console_wait("Enter password:") - self.console_send("%s\n" % self.GUEST_PASS) + self.console_send("%s\n" % self._config["guest_pass"]) self.console_wait("Enter password again:") - self.console_send("%s\n" % self.GUEST_PASS) + self.console_send("%s\n" % self._config["guest_pass"]) self.console_wait_send("Lock out", "\n") self.console_wait_send("OK", "yes\n") self.console_wait_send("Add another user", "no\n") @@ -165,12 +165,12 @@ class FreeBSDVM(basevm.BaseVM): # setup qemu user prompt = "$" - self.console_ssh_init(prompt, self.GUEST_USER, self.GUEST_PASS) + self.console_ssh_init(prompt, self._config["guest_user"], self._config["guest_pass"]) self.console_wait_send(prompt, "exit\n") # setup root user prompt = "root@freebsd:~ #" - self.console_ssh_init(prompt, "root", self.ROOT_PASS) + self.console_ssh_init(prompt, "root", self._config["root_pass"]) self.console_sshd_config(prompt) # setup serial console diff --git a/tests/vm/netbsd b/tests/vm/netbsd index b10c9d429d..7e54fe8322 100755 --- a/tests/vm/netbsd +++ b/tests/vm/netbsd @@ -121,24 +121,24 @@ class NetBSDVM(basevm.BaseVM): self.console_wait_send("d: Change root password", "d\n") self.console_wait_send("a: Yes", "a\n") self.console_wait("New password:") - self.console_send("%s\n" % self.ROOT_PASS) + self.console_send("%s\n" % self._config["root_pass"]) self.console_wait("New password:") - self.console_send("%s\n" % self.ROOT_PASS) + self.console_send("%s\n" % self._config["root_pass"]) self.console_wait("Retype new password:") - self.console_send("%s\n" % self.ROOT_PASS) + self.console_send("%s\n" % self._config["root_pass"]) self.console_wait_send("o: Add a user", "o\n") self.console_wait("username") - self.console_send("%s\n" % self.GUEST_USER) + self.console_send("%s\n" % self._config["guest_pass"]) self.console_wait("to group wheel") self.console_wait_send("a: Yes", "a\n") self.console_wait_send("a: /bin/sh", "a\n") self.console_wait("New password:") - self.console_send("%s\n" % self.GUEST_PASS) + self.console_send("%s\n" % self._config["guest_pass"]) self.console_wait("New password:") - self.console_send("%s\n" % self.GUEST_PASS) + self.console_send("%s\n" % self._config["guest_pass"]) self.console_wait("Retype new password:") - self.console_send("%s\n" % self.GUEST_PASS) + self.console_send("%s\n" % self._config["guest_pass"]) self.console_wait_send("a: Configure network", "a\n") self.console_wait_send("a: vioif0", "a\n") @@ -171,12 +171,13 @@ class NetBSDVM(basevm.BaseVM): # setup qemu user prompt = "localhost$" - self.console_ssh_init(prompt, self.GUEST_USER, self.GUEST_PASS) + self.console_ssh_init(prompt, self._config["guest_user"], + self._config["guest_pass"]) self.console_wait_send(prompt, "exit\n") # setup root user prompt = "localhost#" - self.console_ssh_init(prompt, "root", self.ROOT_PASS) + self.console_ssh_init(prompt, "root", self._config["root_pass"]) self.console_sshd_config(prompt) # setup virtio-blk #1 (tarfile) diff --git a/tests/vm/openbsd b/tests/vm/openbsd index 0b705f4945..04a532c763 100755 --- a/tests/vm/openbsd +++ b/tests/vm/openbsd @@ -99,9 +99,9 @@ class OpenBSDVM(basevm.BaseVM): self.console_wait_send("Which network interface", "done\n") self.console_wait_send("DNS domain name", "localnet\n") self.console_wait("Password for root account") - self.console_send("%s\n" % self.ROOT_PASS) + self.console_send("%s\n" % self._config["root_pass"]) self.console_wait("Password for root account") - self.console_send("%s\n" % self.ROOT_PASS) + self.console_send("%s\n" % self._config["root_pass"]) self.console_wait_send("Start sshd(8)", "yes\n") self.console_wait_send("X Window System", "\n") self.console_wait_send("xenodm", "\n") @@ -109,13 +109,13 @@ class OpenBSDVM(basevm.BaseVM): self.console_wait_send("Which speed", "\n") self.console_wait("Setup a user") - self.console_send("%s\n" % self.GUEST_USER) + self.console_send("%s\n" % self._config["guest_user"]) self.console_wait("Full name") - self.console_send("%s\n" % self.GUEST_USER) + self.console_send("%s\n" % self._config["guest_user"]) self.console_wait("Password") - self.console_send("%s\n" % self.GUEST_PASS) + self.console_send("%s\n" % self._config["guest_pass"]) self.console_wait("Password") - self.console_send("%s\n" % self.GUEST_PASS) + self.console_send("%s\n" % self._config["guest_pass"]) self.console_wait_send("Allow root ssh login", "yes\n") self.console_wait_send("timezone", "UTC\n") @@ -136,12 +136,13 @@ class OpenBSDVM(basevm.BaseVM): # setup qemu user prompt = "$" - self.console_ssh_init(prompt, self.GUEST_USER, self.GUEST_PASS) + self.console_ssh_init(prompt, self._config["guest_user"], + self._config["guest_pass"]) self.console_wait_send(prompt, "exit\n") # setup root user prompt = "openbsd#" - self.console_ssh_init(prompt, "root", self.ROOT_PASS) + self.console_ssh_init(prompt, "root", self._config["root_pass"]) self.console_sshd_config(prompt) # setup virtio-blk #1 (tarfile) From patchwork Fri May 29 20:34:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187330 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp933697ilb; Fri, 29 May 2020 13:52:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnK98l1xf5G0JowXCybcxZwuWIvK1VUIHS9Wux5uk3Yw0uSXMf6D43WQlPipKX6X9rgtaX X-Received: by 2002:a25:5804:: with SMTP id m4mr16255416ybb.488.1590785547407; Fri, 29 May 2020 13:52:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590785547; cv=none; d=google.com; s=arc-20160816; b=yf5FL5IP9C4OzTM0SEHsi9RrWpcxJ9d0W9an3smq7QVoRaPSfgiQ8hrXPElZuPqwym TZeG4L2ADUUzjnyfQiJJUYRN55XVn9kB8X5y+5P4avRld/hIUxTZWXv87qOBUun8Eqam tfIG0OiW6L4E0CIqdly92iR13MevvR+niibfQlX4sGGyYIG2jcJ6+Hxv/E5YKNl6RyaV DLJ0vLwx1fEYF58OAYDscYtX7CA0Bis9SaZPQHyUm9ED4zm3O/HDV1pLz3JSml705b2y vKqOR4pr7Jd08dTgQ3qoVXXbsmeux1iY0oVMaLGyYuer1fnx6tyfcuJpJAiDfPthDaDF K0+g== 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=7quFEHdL4P9uUXPGzV68+zgA7HBXKH+ccwUEceiVJ9c=; b=H4sT7ZpUyo0CK1BPmZ0RTlxrV3xLM1QONg8FrLykv47QMHf1O4cAeUYd1D6x+pGkBs YhKWSwxfBq79XKLdN/moy179nTbVpUHn/BVm8vA3moTABUzqyAsaiU+Nk+YS5d1jiknW nGVDVoEvbybAVgSVUTtPPhTZ97tQ3ghkkVAJgeM/vO4CtX3+gZ1V4RkIt9PWWA1Ywptq 570rBazKk6KSRy9b/a5poCiRUwCKmY+pVhA2Ki50Uo7ODc0YcXi7ODVEwLjZJ9X5GbDk rxepAT/n6qdzOebPix2W5elLnkzisUc0FR11Qy4/v0+zlAIPLmniSVWpVGnk8izjjKgs DpSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=NH27CoFM; 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 y185si8767567ybc.280.2020.05.29.13.52.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 May 2020 13:52:27 -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=NH27CoFM; 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]:37932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jelzO-0001jQ-QY for patch@linaro.org; Fri, 29 May 2020 16:52:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46602) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jelqs-0006Fo-At for qemu-devel@nongnu.org; Fri, 29 May 2020 16:43:38 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]:33767) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jelqq-00010A-OG for qemu-devel@nongnu.org; Fri, 29 May 2020 16:43:37 -0400 Received: by mail-pl1-x632.google.com with SMTP id t7so1711656plr.0 for ; Fri, 29 May 2020 13:43:36 -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=7quFEHdL4P9uUXPGzV68+zgA7HBXKH+ccwUEceiVJ9c=; b=NH27CoFMFxXc3kNC3w5pvyh31DijQsT/ML5F/6a39RgiYuOzckpukL4LPl5GbZ3d6v 77Gy+euUgN4NHAp5Ze4/Mr4Yhs31a1jOVoh/nhdp12WUeEEJGmEKrkAEDrjlsDmVWv6d 7KQt05pEINux3ELxddCpv8710iKF6/3KyUlApdDXN2c8FcxJ4HTicrAZWY4gOLsNLCkH NnzU6cOoKb5Rdx/n3faYrT/WouFtDv7QqMKzrPB2FmmukhvvPyr4FOKsrDDAZ6PrsRzu yoFx49KYXnnSEbqTwyG45EBhArtCpwRSEMlCGzA59DNX9K2EP6QLOVawmkqjP0WaOZwY Pxsg== 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=7quFEHdL4P9uUXPGzV68+zgA7HBXKH+ccwUEceiVJ9c=; b=ZuQEW8gkte8dkjk7CagxRHlrhoofFsn1pS8+/fDnvSWJ7AxZWkrEmX40O//ky3CMMj fNE4yobiXN6cVY0WLTAvNrJDngL5Y+Hd9P+QqwXQZDObQxBzvFekThv5uwAQCZQSuNb1 iWkfbB4FEimg2ZcgqXhH1pSVltTMY0vLvSQfwBiG0QPUvm/oJyfQ7jCqFJ0AveQ8pe4y vcmLd/6gN8u5Gn6VTS5i5ok9F/gP8a5oG0AnItjSWJdhg2diKLvkK6kqkeVybT/E65Ig 1oJqu10A0h+87mf1RjMy3RpQ5xLPlMXnpbViv2qGXtgYrBqhwjEaxkHej/U0pjq4CCT0 Vj2A== X-Gm-Message-State: AOAM531c8R4Oyl1zSowDEXkIqeHzpCzAt/isi1pdcqqt4DM+C2pQ9BH0 AbJmhRuhqHoBueEUaYbWkRq54BOY493k4Q== X-Received: by 2002:a17:902:bf46:: with SMTP id u6mr1837494pls.1.1590785014897; Fri, 29 May 2020 13:43:34 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:75ac:d268:da04:dde4]) by smtp.gmail.com with ESMTPSA id t12sm282839pjf.3.2020.05.29.13.43.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2020 13:43:34 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v8 11/12] python/qemu: Add ConsoleSocket for optional use in QEMUMachine Date: Fri, 29 May 2020 16:34:57 -0400 Message-Id: <20200529203458.1038-12-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200529203458.1038-1-robert.foley@linaro.org> References: <20200529203458.1038-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=robert.foley@linaro.org; helo=mail-pl1-x632.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_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: robert.foley@linaro.org, alex.bennee@linaro.org, Cleber Rosa , peter.puhov@linaro.org, philmd@redhat.com, Eduardo Habkost Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We add the ConsoleSocket object, which has a socket interface and which will consume all arriving characters on the socket, placing them into an in memory buffer. This will also provide those chars via recv() as would a regular socket. ConsoleSocket also has the option of dumping the console bytes to a log file. We also give QEMUMachine the option of using ConsoleSocket to drain and to use for logging console to a file. By default QEMUMachine does not use ConsoleSocket. This is added in preparation for use by basevm.py in a later commit. This is a workaround we found was needed for basevm.py since there is a known issue where QEMU will hang waiting for console characters to be consumed. Cc: Eduardo Habkost Cc: Cleber Rosa Signed-off-by: Robert Foley Reviewed-by: Peter Puhov Acked-by: Alex Bennée --- python/qemu/console_socket.py | 118 ++++++++++++++++++++++++++++++++++ python/qemu/machine.py | 23 +++++-- 2 files changed, 137 insertions(+), 4 deletions(-) create mode 100644 python/qemu/console_socket.py -- 2.17.1 Tested-by: Philippe Mathieu-Daudé diff --git a/python/qemu/console_socket.py b/python/qemu/console_socket.py new file mode 100644 index 0000000000..2fe1c20d64 --- /dev/null +++ b/python/qemu/console_socket.py @@ -0,0 +1,118 @@ +#!/usr/bin/env python3 +# +# This python module implements a ConsoleSocket object which is +# designed always drain the socket itself, and place +# the bytes into a in memory buffer for later processing. +# +# Optionally a file path can be passed in and we will also +# dump the characters to this file for debug. +# +# Copyright 2020 Linaro +# +# Authors: +# Robert Foley +# +# This code is licensed under the GPL version 2 or later. See +# the COPYING file in the top-level directory. +# +import asyncore +import socket +import threading +import io +import os +import sys +from collections import deque +import time +import traceback + +class ConsoleSocket(asyncore.dispatcher): + + def __init__(self, address, file=None): + self._recv_timeout_sec = 300 + self._buffer = deque() + self._asyncore_thread = None + self._sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + self._sock.connect(address) + self._logfile = None + if file: + self._logfile = open(file, "w") + asyncore.dispatcher.__init__(self, sock=self._sock) + self._thread_start() + self._open = True + + def _thread_start(self): + """Kick off a thread to wait on the asyncore.loop""" + if self._asyncore_thread is not None: + return + self._asyncore_thread = threading.Thread(target=asyncore.loop, + kwargs={'timeout':1}) + self._asyncore_thread.daemon = True + self._asyncore_thread.start() + + def handle_close(self): + """redirect close to base class""" + # Call the base class close, but not self.close() since + # handle_close() occurs in the context of the thread which + # self.close() attempts to join. + asyncore.dispatcher.close(self) + + def close(self): + """Close the base object and wait for the thread to terminate""" + if self._open: + self._open = False + asyncore.dispatcher.close(self) + if self._asyncore_thread is not None: + thread, self._asyncore_thread = self._asyncore_thread, None + thread.join() + if self._logfile: + self._logfile.close() + self._logfile = None + + def handle_read(self): + """process arriving characters into in memory _buffer""" + try: + data = asyncore.dispatcher.recv(self, 1) + # latin1 is needed since there are some chars + # we are receiving that cannot be encoded to utf-8 + # such as 0xe2, 0x80, 0xA6. + string = data.decode("latin1") + except: + print("Exception seen.") + traceback.print_exc() + return + if self._logfile: + self._logfile.write("{}".format(string)) + self._logfile.flush() + for c in string: + self._buffer.append(c) + + def recv(self, n=1): + """Return chars from in memory buffer""" + start_time = time.time() + while len(self._buffer) < n: + time.sleep(0.1) + elapsed_sec = time.time() - start_time + if elapsed_sec > self._recv_timeout_sec: + raise socket.timeout + chars = ''.join([self._buffer.popleft() for i in range(n)]) + # We choose to use latin1 to remain consistent with + # handle_read() and give back the same data as the user would + # receive if they were reading directly from the + # socket w/o our intervention. + return chars.encode("latin1") + + def set_blocking(self): + """Maintain compatibility with socket API""" + pass + + def settimeout(self, seconds): + """Set current timeout on recv""" + self._recv_timeout_sec = seconds + +class ByteBuffer(deque): + """Simple in memory buffer with read/write interface""" + def write(self, bytes): + for i in bytes: + self.append(i) + def read(self, n): + return ''.join([self.popleft() for i in range(n)]) diff --git a/python/qemu/machine.py b/python/qemu/machine.py index b9a98e2c86..ee9c337f55 100644 --- a/python/qemu/machine.py +++ b/python/qemu/machine.py @@ -24,6 +24,7 @@ import subprocess import shutil import socket import tempfile +from qemu.console_socket import ConsoleSocket from . import qmp @@ -71,7 +72,8 @@ class QEMUMachine(object): def __init__(self, binary, args=None, wrapper=None, name=None, test_dir="/var/tmp", monitor_address=None, - socket_scm_helper=None, sock_dir=None): + socket_scm_helper=None, sock_dir=None, + drain_console=False, console_log=None): ''' Initialize a QEMUMachine @@ -82,6 +84,9 @@ class QEMUMachine(object): @param test_dir: where to create socket and log file @param monitor_address: address for QMP monitor @param socket_scm_helper: helper program, required for send_fd_scm() + @param sock_dir: where to create socket (overrides test_dir for sock) + @param console_log: (optional) path to console log file + @param drain_console: (optional) True to drain console socket to buffer @note: Qemu process is not started until launch() is used. ''' if args is None: @@ -118,6 +123,12 @@ class QEMUMachine(object): self._console_address = None self._console_socket = None self._remove_files = [] + self._console_log_path = console_log + if self._console_log_path: + # In order to log the console, buffering needs to be enabled. + self._drain_console = True + else: + self._drain_console = drain_console # just in case logging wasn't configured by the main script: logging.basicConfig() @@ -568,7 +579,11 @@ class QEMUMachine(object): Returns a socket connected to the console """ if self._console_socket is None: - self._console_socket = socket.socket(socket.AF_UNIX, - socket.SOCK_STREAM) - self._console_socket.connect(self._console_address) + if self._drain_console: + self._console_socket = ConsoleSocket(self._console_address, + file=self._console_log_path) + else: + self._console_socket = socket.socket(socket.AF_UNIX, + socket.SOCK_STREAM) + self._console_socket.connect(self._console_address) return self._console_socket From patchwork Fri May 29 20:34:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187331 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp934920ilb; Fri, 29 May 2020 13:54:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxSe5x+R49gmECRUKtA0cs9VdGtqrb3sDeyvmuqOtQ2P364funlcXSNEeI6wudhbYvjJrf X-Received: by 2002:a25:d902:: with SMTP id q2mr17308435ybg.96.1590785670195; Fri, 29 May 2020 13:54:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590785670; cv=none; d=google.com; s=arc-20160816; b=r0mzun9jPsaDsKcFtIaL9hJUMF2cv1rV3/9ys0/WRk5Q37jkt1bUQsyuASVlcyhVwT 7J/WKhPekdkcns6h0kumFAnxbn4dvrdy6caHJOZg3GI70BqVKWP4b9RhkW6wblMaZeuX HWbxa8eQkdvd8RCM8L2R0sMyHxn0b/K3T6GalHV9Jtb1DZohDBrd7FTF9zGSo+naKEGV AxdexIiROflgbR6FLrRrfGMhnEBxIzOG5dMpyJhkQNYwA9SDJylkxWoyosdUQYRWoUci VpewQ8N6XbfpIiEdF43dGYTfLcgy12Hw6hePI303JFgThVtlwiGkNB/Dk7TyObBJPjk4 WQNg== 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=DrW0NEIM6Nr/spQYP7ZRVxUxdagYdkLudwFL6LhCVeQ=; b=aFfvoV115DWfERrmh6yoN/4M9zA8Rw5e5FZ1TpzrtgJO1FTasNjexMsDZBfiodFmyP 4R+TziuqG0N70Zn5eHF1ITZL9F44/ZYL5BqVaRydUAkbz8vTYHdni8mE49aAk3CofZKk oEKO3w0YZoguerySofI156nfskVTn48gvn7oN5X4EJd0z9AWBg3Cv19aM4Buh3Zvel02 ovGl77oJgvHQADgHzZvvfxTVGri+AG29WNFx0aF5e1170ifoRvLapf2/uS0nICxobl8P 8bx6NZ0oMzl0RW2PizrVZ1+/v8EpoUrwHWx1/Yn01N5ZCXUq6jtP8AavmTpvWohXFdsv W5WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=krGLgW9B; 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 n70si8037257ybf.387.2020.05.29.13.54.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 May 2020 13:54:30 -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=krGLgW9B; 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]:46378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jem1N-0005KZ-Jz for patch@linaro.org; Fri, 29 May 2020 16:54:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jelqt-0006JL-Uu for qemu-devel@nongnu.org; Fri, 29 May 2020 16:43:39 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:36402) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jelqs-00011M-M4 for qemu-devel@nongnu.org; Fri, 29 May 2020 16:43:39 -0400 Received: by mail-pf1-x444.google.com with SMTP id e11so415620pfn.3 for ; Fri, 29 May 2020 13:43:38 -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=DrW0NEIM6Nr/spQYP7ZRVxUxdagYdkLudwFL6LhCVeQ=; b=krGLgW9Bv/jNAHbmsogW/QBUQ25aEcnRPTeY7vU2y1wfYiiqwl8neJAN2AT31GimCO mFw5k8Jz4VofYl3pZJgaWx14tn/FnnSkPrD1VmIUi+pGRixDI3BqCzxErWCjbLtLnxnJ HA883LNK43VpETpY9s2hY4NPWTB1Rm+q8q2Z0CDOxSKYeAriZZkwcUruRuAJIeu+6qDs TtCtU4g1l3m4Z3gPHQj/Annw1sRSGcTiddqw5W7T8Tv6HgVsASuDMhCraIEZEGfK2XqV 5zMxB95rVCEMC1zzgEdDOF1siLm+9HzeHbtNePv7Wr037OXQBzSyZklDPMXFeMc/mAcM k7BQ== 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=DrW0NEIM6Nr/spQYP7ZRVxUxdagYdkLudwFL6LhCVeQ=; b=j4fcwugBYtTaYwz+GR6BxxuGXxLT/agei0xU4R0SJ4e9Z0kr/fwr5FOyUYGn05wsOu 6t0tHE5F1i7xAPPtODCB1TeWgSjSzdFHdC4xqG/EQIgM09qm2N+Pp0GLFUothykUfNEF 9KHy/03OWcvEbJuu8w9T2e4BXgVTYHJhNIC/1IK+HgQp8823kOwqGv9SX6i7snBfm77W rdmWkoos6qBcJopfD4viN+f60ToBR7PfhB26e3F6400MBRM5A6hmyvuhCASb5bIxEf9m c/FmSXRJbo++LBzANsIKSgSkyLoiigzVa6ffCleH6QxPUjQvIaAhBEYfELsfBfuhpt2S Lp4A== X-Gm-Message-State: AOAM532ter76XXoI5FbqwQZWoWT9xNyAmsbt9onR7iSmkFEF6UIH+Fog 4Z3U1tU7083DMlgY3kWICFCMOGrAKKSCEA== X-Received: by 2002:a62:543:: with SMTP id 64mr10179475pff.271.1590785016902; Fri, 29 May 2020 13:43:36 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:75ac:d268:da04:dde4]) by smtp.gmail.com with ESMTPSA id t12sm282839pjf.3.2020.05.29.13.43.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2020 13:43:36 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v8 12/12] tests/vm: Add workaround to consume console Date: Fri, 29 May 2020 16:34:58 -0400 Message-Id: <20200529203458.1038-13-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200529203458.1038-1-robert.foley@linaro.org> References: <20200529203458.1038-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::444; envelope-from=robert.foley@linaro.org; helo=mail-pf1-x444.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_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 Zheng , philmd@redhat.com, alex.bennee@linaro.org, robert.foley@linaro.org, peter.puhov@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- tests/vm/Makefile.include | 4 ++++ tests/vm/basevm.py | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include index 8cccfaf95d..ad35c6e7a1 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 b9d828423b..64dbe64326 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,9 @@ 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) + 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 +292,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 +305,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 +589,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()