From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Jones Subject: [PATCH kvm-unit-tests 11/15] arm/arm64: enable environ Date: Fri, 13 Jan 2017 19:15:29 +0100 Message-ID: <20170113181533.15145-12-drjones@redhat.com> References: <20170113181533.15145-1-drjones@redhat.com> Cc: rkrcmar@redhat.com, pbonzini@redhat.com, lvivier@redhat.com, thuth@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:47694 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751183AbdAMSP6 (ORCPT ); Fri, 13 Jan 2017 13:15:58 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8E88D7F415 for ; Fri, 13 Jan 2017 18:15:54 +0000 (UTC) In-Reply-To: <20170113181533.15145-1-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Give arm/arm64 unit tests access to environment variables. The environment variables are passed to the unit test with '-initrd env-file'. Signed-off-by: Andrew Jones --- arm/run | 1 + lib/arm/setup.c | 8 ++++++++ arm/cstart.S | 1 + arm/cstart64.S | 1 + 4 files changed, 11 insertions(+) diff --git a/arm/run b/arm/run index 1c40ab02eb57..2134c9efb1bd 100755 --- a/arm/run +++ b/arm/run @@ -79,6 +79,7 @@ fi M+=",accel=$ACCEL" command="$qemu -nodefaults $M -cpu $processor $chr_testdev $pci_testdev" +[ -f "$ENV" ] && command+=" -initrd $ENV" command+=" -display none -serial stdio -kernel" command="$(timeout_cmd) $command" echo $command "$@" diff --git a/lib/arm/setup.c b/lib/arm/setup.c index c4d69ae2c143..689c211d3018 100644 --- a/lib/arm/setup.c +++ b/lib/arm/setup.c @@ -23,6 +23,7 @@ extern unsigned long stacktop; extern void io_init(void); extern void setup_args_progname(const char *args); +extern void setup_env(char *env, int size); char *initrd; u32 initrd_size; @@ -173,4 +174,11 @@ void setup(const void *fdt) ret = dt_get_bootargs(&bootargs); assert(ret == 0 || ret == -FDT_ERR_NOTFOUND); setup_args_progname(bootargs); + + if (initrd) { + /* environ is currently the only file in the initrd */ + char *env = malloc(initrd_size); + memcpy(env, initrd, initrd_size); + setup_env(env, initrd_size); + } } diff --git a/arm/cstart.S b/arm/cstart.S index 9822fb7ba637..12461d104dad 100644 --- a/arm/cstart.S +++ b/arm/cstart.S @@ -62,6 +62,7 @@ start: ldr r0, =__argc ldr r0, [r0] ldr r1, =__argv + ldr r2, =__environ bl main bl exit b halt diff --git a/arm/cstart64.S b/arm/cstart64.S index 44cff32d0f18..7738babc4109 100644 --- a/arm/cstart64.S +++ b/arm/cstart64.S @@ -43,6 +43,7 @@ start: adr x0, __argc ldr x0, [x0] adr x1, __argv + adr x2, __environ bl main bl exit b halt -- 2.9.3