[v1,01/24] configure: add test for docker availability

Message ID 20180410193919.28026-2-alex.bennee@linaro.org
State New
Headers show
Series
  • fix building of tests/tcg
Related show

Commit Message

Alex Bennée April 10, 2018, 7:38 p.m.
This tests for a working docker installation without sudo and sets up
config-host.mak accordingly. This will be useful from cross compiling
things in the future.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

---
 configure | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

-- 
2.16.2

Comments

Fam Zheng April 11, 2018, 8:50 a.m. | #1
On Tue, 04/10 20:38, Alex Bennée wrote:
> This tests for a working docker installation without sudo and sets up

> config-host.mak accordingly. This will be useful from cross compiling

> things in the future.

> 

> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

> ---

>  configure | 23 +++++++++++++++++++++++

>  1 file changed, 23 insertions(+)

> 

> diff --git a/configure b/configure

> index 4d0e92c96c..b402befe94 100755

> --- a/configure

> +++ b/configure

> @@ -451,6 +451,7 @@ jemalloc="no"

>  replication="yes"

>  vxhs=""

>  libxml2=""

> +docker="no"

>  

>  supported_cpu="no"

>  supported_os="no"

> @@ -5396,6 +5397,23 @@ EOF

>    fi

>  fi

>  

> +##########################################

> +# Docker and cross-compiler support

> +#

> +# This is specifically for building test

> +# cases for foreign architectures, not

> +# cross-compiling QEMU itself.

> +

> +if has "docker"; then

> +    if docker images  >/dev/null 2>&1 ; then

> +        docker="yes"

> +    else

> +        # docker may be available but using sudo

> +        # so we won't use it for cross-building

> +        docker="maybe"


What is the problem with using sudo for cross-building?

Fam

> +    fi

> +fi

> +

>  ##########################################

>  # End of CC checks

>  # After here, no more $cc or $ld runs

> @@ -5857,6 +5875,7 @@ echo "avx2 optimization $avx2_opt"

>  echo "replication support $replication"

>  echo "VxHS block device $vxhs"

>  echo "capstone          $capstone"

> +echo "docker            $docker"

>  

>  if test "$sdl_too_old" = "yes"; then

>  echo "-> Your SDL version is too old - please upgrade to have SDL support"

> @@ -6680,6 +6699,10 @@ if test "$gcov" = "yes" ; then

>    echo "GCOV=$gcov_tool" >> $config_host_mak

>  fi

>  

> +if test "$docker" = "yes"; then

> +    echo "HAVE_USER_DOCKER=y" >> $config_host_mak

> +fi

> +

>  # use included Linux headers

>  if test "$linux" = "yes" ; then

>    mkdir -p linux-headers

> -- 

> 2.16.2

>
Alex Bennée April 11, 2018, 10:58 a.m. | #2
Fam Zheng <famz@redhat.com> writes:

> On Tue, 04/10 20:38, Alex Bennée wrote:

>> This tests for a working docker installation without sudo and sets up

>> config-host.mak accordingly. This will be useful from cross compiling

>> things in the future.

>>

>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

>> ---

>>  configure | 23 +++++++++++++++++++++++

>>  1 file changed, 23 insertions(+)

>>

>> diff --git a/configure b/configure

>> index 4d0e92c96c..b402befe94 100755

>> --- a/configure

>> +++ b/configure

>> @@ -451,6 +451,7 @@ jemalloc="no"

>>  replication="yes"

>>  vxhs=""

>>  libxml2=""

>> +docker="no"

>>

>>  supported_cpu="no"

>>  supported_os="no"

>> @@ -5396,6 +5397,23 @@ EOF

>>    fi

>>  fi

>>

>> +##########################################

>> +# Docker and cross-compiler support

>> +#

>> +# This is specifically for building test

>> +# cases for foreign architectures, not

>> +# cross-compiling QEMU itself.

>> +

>> +if has "docker"; then

>> +    if docker images  >/dev/null 2>&1 ; then

>> +        docker="yes"

>> +    else

>> +        # docker may be available but using sudo

>> +        # so we won't use it for cross-building

>> +        docker="maybe"

>

> What is the problem with using sudo for cross-building?


Nothing in particular but we need someway of testing if the sudo is
passwordless otherwise you might find the build stuck waiting for user
interaction. This is fine for "make docker-foo" but for an eventual
unattended "make check" this may cause problems.

Is there a way we can test for this? Maybe we can push the docker probe
into docker.py and just return to configure if it can run docker
unattended?

--
Alex Bennée
Fam Zheng April 11, 2018, 12:59 p.m. | #3
On Wed, 04/11 11:58, Alex Bennée wrote:
> 

> Fam Zheng <famz@redhat.com> writes:

> 

> > On Tue, 04/10 20:38, Alex Bennée wrote:

> >> This tests for a working docker installation without sudo and sets up

> >> config-host.mak accordingly. This will be useful from cross compiling

> >> things in the future.

> >>

> >> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

> >> ---

> >>  configure | 23 +++++++++++++++++++++++

> >>  1 file changed, 23 insertions(+)

> >>

> >> diff --git a/configure b/configure

> >> index 4d0e92c96c..b402befe94 100755

> >> --- a/configure

> >> +++ b/configure

> >> @@ -451,6 +451,7 @@ jemalloc="no"

> >>  replication="yes"

> >>  vxhs=""

> >>  libxml2=""

> >> +docker="no"

> >>

> >>  supported_cpu="no"

> >>  supported_os="no"

> >> @@ -5396,6 +5397,23 @@ EOF

> >>    fi

> >>  fi

> >>

> >> +##########################################

> >> +# Docker and cross-compiler support

> >> +#

> >> +# This is specifically for building test

> >> +# cases for foreign architectures, not

> >> +# cross-compiling QEMU itself.

> >> +

> >> +if has "docker"; then

> >> +    if docker images  >/dev/null 2>&1 ; then

> >> +        docker="yes"

> >> +    else

> >> +        # docker may be available but using sudo

> >> +        # so we won't use it for cross-building

> >> +        docker="maybe"

> >

> > What is the problem with using sudo for cross-building?

> 

> Nothing in particular but we need someway of testing if the sudo is

> passwordless otherwise you might find the build stuck waiting for user

> interaction. This is fine for "make docker-foo" but for an eventual

> unattended "make check" this may cause problems.

> 

> Is there a way we can test for this? Maybe we can push the docker probe

> into docker.py and just return to configure if it can run docker

> unattended?


We can try 'sudo -n -k docker' to test if passwordless docker works. According
to the manpage, -k ignores the credential cache, and -n ensures non-interaction.

Fam

Patch

diff --git a/configure b/configure
index 4d0e92c96c..b402befe94 100755
--- a/configure
+++ b/configure
@@ -451,6 +451,7 @@  jemalloc="no"
 replication="yes"
 vxhs=""
 libxml2=""
+docker="no"
 
 supported_cpu="no"
 supported_os="no"
@@ -5396,6 +5397,23 @@  EOF
   fi
 fi
 
+##########################################
+# Docker and cross-compiler support
+#
+# This is specifically for building test
+# cases for foreign architectures, not
+# cross-compiling QEMU itself.
+
+if has "docker"; then
+    if docker images  >/dev/null 2>&1 ; then
+        docker="yes"
+    else
+        # docker may be available but using sudo
+        # so we won't use it for cross-building
+        docker="maybe"
+    fi
+fi
+
 ##########################################
 # End of CC checks
 # After here, no more $cc or $ld runs
@@ -5857,6 +5875,7 @@  echo "avx2 optimization $avx2_opt"
 echo "replication support $replication"
 echo "VxHS block device $vxhs"
 echo "capstone          $capstone"
+echo "docker            $docker"
 
 if test "$sdl_too_old" = "yes"; then
 echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -6680,6 +6699,10 @@  if test "$gcov" = "yes" ; then
   echo "GCOV=$gcov_tool" >> $config_host_mak
 fi
 
+if test "$docker" = "yes"; then
+    echo "HAVE_USER_DOCKER=y" >> $config_host_mak
+fi
+
 # use included Linux headers
 if test "$linux" = "yes" ; then
   mkdir -p linux-headers