From nobody Thu Nov 6 03:26:11 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539390744143659.3236778854066; Fri, 12 Oct 2018 17:32:24 -0700 (PDT) Received: from localhost ([::1]:43167 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gB7qi-0000vL-Bk for importer@patchew.org; Fri, 12 Oct 2018 20:32:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38541) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gB7pj-0000cf-V1 for qemu-devel@nongnu.org; Fri, 12 Oct 2018 20:31:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gB7pg-0003Fy-QB for qemu-devel@nongnu.org; Fri, 12 Oct 2018 20:31:07 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:44137) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gB7pg-0003Fd-FK for qemu-devel@nongnu.org; Fri, 12 Oct 2018 20:31:04 -0400 Received: by mail-wr1-x42d.google.com with SMTP id 63-v6so15089575wra.11 for ; Fri, 12 Oct 2018 17:31:04 -0700 (PDT) Received: from x1.local (62.red-88-24-165.staticip.rima-tde.net. [88.24.165.62]) by smtp.gmail.com with ESMTPSA id l67-v6sm5429761wma.20.2018.10.12.17.31.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:31:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=H/CAfaz4uHwycYTe6a2T/DF0FuoyfLAVk7BUib6FdnE=; b=G1O5QPAcd3Qud9r0+1/+/QfA39GFlUxc21cT+XZZ1rWbCnurKQDq0zXT1cjtj9InRU XyeEXRm/O4/JSibnH9x6FjC/M0IzPLuZZQ6E4RzkVzgSJUUvRaa4FF2jodGCiG2kwaIZ jyBwvEKFYE3P81KSyVJK4tBCu0o3A3qTwPw8zDVbB9TSzwWklSyNzzKOiauriuIjEyvC NhrMM7qh7MosaJMCy1pKakk5WpAkSMA73G1162xZYpkHQ6KGdpSdr+SxV0JuCX/LYTUq kd5EkDNuVsv/Ul0VQp7v5mUdTNzxyVX1q0m3VKDwbsR6XJmsP7uifbzAuRoTqhIdK1He AMEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=H/CAfaz4uHwycYTe6a2T/DF0FuoyfLAVk7BUib6FdnE=; b=U78SxT7v9McRbVzLMg+y9Ls6lU+Izyx5qQ/V/5+ym43Hx3xlfnlwV0/SeoZP8I4bCo CWxYHGRsjSKTTa1RG4RI1AGtbYL9JWJkpn0orSH6FawxCvSA0ihce3osgo5XWCTo5uyQ C4/il9O9L9pYRDPUhJWATiSS5TC0IFRmUOla86uL6KtIjLS7IuFTpJZmqsbYmKZKfY/P ypsjxPbHeqRfTWAGpCdg82sW5w1N/+x0vx/Xu+2uyxxcbFs3kriR8+3+v6ITblZbo5kB Fh65eiR48Wh83sWoJ5DrXdo1ct/XpnGs/M5QsGIw/hj30mGl9sGj21DvHz3ZYREacJYX oyzg== X-Gm-Message-State: ABuFfoj46TLGDF5yGfIED1IF2oCqz6iC2e4tyHjrpuFjX7zTvuV/gI1t yXhnEils90gpyxZjIdBCVNc= X-Google-Smtp-Source: ACcGV62O70Eo1kGkntxzdQeY2K3x/XQA2l5mfiGm0dxwOBMfD8smhVQCu56Pzl0p+149tEKScYuQSg== X-Received: by 2002:adf:f6c4:: with SMTP id y4-v6mr7520720wrp.79.1539390663164; Fri, 12 Oct 2018 17:31:03 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Fam Zheng Date: Sat, 13 Oct 2018 02:30:57 +0200 Message-Id: <20181013003058.3349-1-f4bug@amsat.org> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42d Subject: [Qemu-devel] [PATCH] tests/vm: Use subprocess.Popen() with to uncompress XZ files X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Avoiding the file copy greatly speeds the process up. Comparison with network file already cached, stopping after build_image(): Before: $ time make vm-build-freebsd real 1m38.153s user 1m16.871s sys 0m19.325s After: $ time make vm-build-freebsd real 0m13.512s user 0m9.520s sys 0m3.685s Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/vm/centos | 5 ++--- tests/vm/freebsd | 9 ++------- tests/vm/netbsd | 9 ++------- tests/vm/openbsd | 9 ++------- 4 files changed, 8 insertions(+), 24 deletions(-) diff --git a/tests/vm/centos b/tests/vm/centos index afd560c564..fa653c1650 100755 --- a/tests/vm/centos +++ b/tests/vm/centos @@ -63,9 +63,8 @@ class CentosVM(basevm.BaseVM): =20 def build_image(self, img): cimg =3D self._download_with_cache("https://cloud.centos.org/cento= s/7/images/CentOS-7-x86_64-GenericCloud-1802.qcow2.xz") - img_tmp =3D img + ".tmp" - subprocess.check_call(["cp", "-f", cimg, img_tmp + ".xz"]) - subprocess.check_call(["xz", "-df", img_tmp + ".xz"]) + with open(img, 'wb', 0644) as output: + subprocess.Popen(["xz", "--threads=3D0", "--decompress", "--fo= rce", "--to-stdout", cimg], stdout=3Doutput) subprocess.check_call(["qemu-img", "resize", img_tmp, "50G"]) self.boot(img_tmp, extra_args =3D ["-cdrom", self._gen_cloud_init_= iso()]) self.wait_ssh() diff --git a/tests/vm/freebsd b/tests/vm/freebsd index b6983127d0..7ec43a4c5c 100755 --- a/tests/vm/freebsd +++ b/tests/vm/freebsd @@ -31,13 +31,8 @@ class FreeBSDVM(basevm.BaseVM): def build_image(self, img): cimg =3D self._download_with_cache("http://download.patchew.org/fr= eebsd-11.1-amd64.img.xz", sha256sum=3D'adcb771549b37bc63826c501f05121a206ed3d9f55f49= 145908f7e1432d65891') - img_tmp_xz =3D img + ".tmp.xz" - img_tmp =3D img + ".tmp" - subprocess.check_call(["cp", "-f", cimg, img_tmp_xz]) - subprocess.check_call(["xz", "-df", img_tmp_xz]) - if os.path.exists(img): - os.remove(img) - os.rename(img_tmp, img) + with open(img, 'wb', 0644) as output: + subprocess.Popen(["xz", "--threads=3D0", "--decompress", "--fo= rce", "--to-stdout", cimg], stdout=3Doutput) =20 if __name__ =3D=3D "__main__": sys.exit(basevm.main(FreeBSDVM)) diff --git a/tests/vm/netbsd b/tests/vm/netbsd index a4e25820d5..99023344b7 100755 --- a/tests/vm/netbsd +++ b/tests/vm/netbsd @@ -31,13 +31,8 @@ class NetBSDVM(basevm.BaseVM): def build_image(self, img): cimg =3D self._download_with_cache("http://download.patchew.org/ne= tbsd-7.1-amd64.img.xz", sha256sum=3D'b633d565b0eac3d02015= cd0c81440bd8a7a8df8512615ac1ee05d318be015732') - img_tmp_xz =3D img + ".tmp.xz" - img_tmp =3D img + ".tmp" - subprocess.check_call(["cp", "-f", cimg, img_tmp_xz]) - subprocess.check_call(["xz", "-df", img_tmp_xz]) - if os.path.exists(img): - os.remove(img) - os.rename(img_tmp, img) + with open(img, 'wb', 0644) as output: + subprocess.Popen(["xz", "--threads=3D0", "--decompress", "--fo= rce", "--to-stdout", cimg], stdout=3Doutput) =20 if __name__ =3D=3D "__main__": sys.exit(basevm.main(NetBSDVM)) diff --git a/tests/vm/openbsd b/tests/vm/openbsd index 52500ee52b..57604bb43d 100755 --- a/tests/vm/openbsd +++ b/tests/vm/openbsd @@ -32,13 +32,8 @@ class OpenBSDVM(basevm.BaseVM): def build_image(self, img): cimg =3D self._download_with_cache("http://download.patchew.org/op= enbsd-6.1-amd64.img.xz", sha256sum=3D'8c6cedc483e602cfee5e04f0406c64eb99138495e8ca5= 80bc0293bcf0640c1bf') - img_tmp_xz =3D img + ".tmp.xz" - img_tmp =3D img + ".tmp" - subprocess.check_call(["cp", "-f", cimg, img_tmp_xz]) - subprocess.check_call(["xz", "-df", img_tmp_xz]) - if os.path.exists(img): - os.remove(img) - os.rename(img_tmp, img) + with open(img, 'wb', 0644) as output: + subprocess.Popen(["xz", "--threads=3D0", "--decompress", "--fo= rce", "--to-stdout", cimg], stdout=3Doutput) =20 if __name__ =3D=3D "__main__": sys.exit(basevm.main(OpenBSDVM)) --=20 2.19.1