From patchwork Tue Jul 3 01:47:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 10502783 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B98F86028F for ; Tue, 3 Jul 2018 01:48:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A792C28ACB for ; Tue, 3 Jul 2018 01:48:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9AF2028AD1; Tue, 3 Jul 2018 01:48:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 381E628ACB for ; Tue, 3 Jul 2018 01:48:28 +0000 (UTC) Received: from localhost ([::1]:37287 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faAQd-0002w2-F1 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 02 Jul 2018 21:48:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40101) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faAPZ-0002MB-Jd for qemu-devel@nongnu.org; Mon, 02 Jul 2018 21:47:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faAPW-00035x-Ej for qemu-devel@nongnu.org; Mon, 02 Jul 2018 21:47:21 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37498 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faAPW-000353-1O for qemu-devel@nongnu.org; Mon, 02 Jul 2018 21:47:18 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3E56B87A87; Tue, 3 Jul 2018 01:47:17 +0000 (UTC) Received: from localhost (ovpn-12-86.pek2.redhat.com [10.72.12.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id 39D462156889; Tue, 3 Jul 2018 01:47:15 +0000 (UTC) Date: Tue, 3 Jul 2018 09:47:14 +0800 From: Fam Zheng To: Philippe =?iso-8859-1?Q?Mathieu-Daud=E9?= Message-ID: <20180703014714.GC485@lemon.usersys.redhat.com> References: <20180628153535.1411-1-f4bug@amsat.org> <20180628153535.1411-2-f4bug@amsat.org> <20180702071205.GI26002@lemon.usersys.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.0 (2018-05-17) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 03 Jul 2018 01:47:17 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 03 Jul 2018 01:47:17 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'famz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: Re: [Qemu-devel] [PATCH 1/4] tests/vm: Support proxy / corporate firewall 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: Alex =?iso-8859-1?Q?Benn=E9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP On Mon, 07/02 12:11, Philippe Mathieu-Daudé wrote: > Hi Fam, > > On 07/02/2018 04:12 AM, Fam Zheng wrote: > > On Thu, 06/28 12:35, Philippe Mathieu-Daudé wrote: > >> If ftp_proxy/http_proxy/https_proxy standard environment variables > >> are available, pass them to the vm images. > >> > >> As per 06cc3551714: > >> This is required when building behind corporate proxy/firewall, but > >> also help when using local cache server (ie: apt/yum). > >> > >> Signed-off-by: Philippe Mathieu-Daudé > >> --- > >> tests/vm/ubuntu.i386 | 4 ++++ > >> 1 file changed, 4 insertions(+) > >> > >> diff --git a/tests/vm/ubuntu.i386 b/tests/vm/ubuntu.i386 > >> index fc319e0e6e..be16ceed50 100755 > >> --- a/tests/vm/ubuntu.i386 > >> +++ b/tests/vm/ubuntu.i386 > >> @@ -68,6 +68,10 @@ class UbuntuX86VM(basevm.BaseVM): > >> self.boot(img_tmp, extra_args = ["-cdrom", self._gen_cloud_init_iso()]) > >> self.wait_ssh() > >> self.ssh_root_check("touch /etc/cloud/cloud-init.disabled") > >> + for k, v in os.environ.iteritems(): > >> + kl = k.lower() > >> + if kl in ['ftp_proxy', 'http_proxy', 'https_proxy']: > >> + self.ssh_root_check("echo 'Acquire::{}::Proxy \"{}\";' >> /etc/apt/apt.conf.d/01proxy".format(kl[:-6].upper(), v)) > > > > Reasonable, but do we want it for other apps and images? How about setting these > > env vars to ssh commands? > > I see 2 different network usages: > > 1/ how the guest connect to the outer world, this goes via the firewall. > Here the change only affects apt* based commands (via the apt.conf file). > Do we have other commands requiring network connectivity? If we have, > then yes, we should add the same env vars in the guest. > One case I think of is "git submodule init" calling "git clone". Yes, I think this case is what we are looking at here. But this patch is very specific: it only affects one command in one VM, albeit we don't have many. Doing this means we'll need to specially open code tests/vm/fedora, tests/vm/debian, or any other images we introduce later, to be consistent with ubuntu.i386. It is a poor way to do this, IMO. What I mean is, can we do it more generically? Like setting the env var in guest /etc/profile or change BaseVM._ssh_do() to inject env vars: diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index 3643117816..94501e7dc7 100755 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -106,7 +106,9 @@ class BaseVM(object): if interactive: ssh_cmd += ['-t'] assert not isinstance(cmd, str) - ssh_cmd += ["%s@127.0.0.1" % user] + list(cmd) + env = ["%s=%s" % (k, v) for k, v in os.environ.items() if k in \ + ["ftp_proxy", "http_proxy", "https_proxy"]] + ssh_cmd += ["%s@127.0.0.1" % user] + env + list(cmd) logging.debug("ssh_cmd: %s", " ".join(ssh_cmd)) r = subprocess.call(ssh_cmd) if check and r != 0: