diff mbox series

[v2,1/3] tools: docker: Install a readable kernel for libguestfs-tools

Message ID 20210613140731.16254-2-alpernebiyasak@gmail.com
State Superseded
Delegated to: Tom Rini
Headers show
Series Fix CIs skipping filesystem, EFI secure boot and EFI capsule tests | expand

Commit Message

Alper Nebi Yasak June 13, 2021, 2:07 p.m. UTC
The filesystem and EFI (capsule and secure boot) test setups try to use
guestmount and virt-make-fs respectively to prepare disk images to run
tests on. However, these libguestfs tools need a kernel image and fail
with the following message (revealed in debug/trace mode) if it can't
find one:

    supermin: failed to find a suitable kernel (host_cpu=x86_64).

    I looked for kernels in /boot and modules in /lib/modules.

    If this is a Xen guest, and you only have Xen domU kernels
    installed, try installing a fullvirt kernel (only for
    supermin use, you shouldn't boot the Xen guest with it).

This failure then causes these tests to be skipped in CIs. Install a
kernel package in the Docker containers so the CIs can run these
tests with libguestfs tools again (assuming the container is run with
necessary host devices and privileges). As this kernel would be only
used for virtualization, we can use the kernel package specialized for
that. On Ubuntu systems kernel images are not readable by non-root
users, so explicitly add read permissions with chmod as well.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---

Changes in v2:
- Add tag "Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>"

 tools/docker/Dockerfile | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Heinrich Schuchardt June 14, 2021, 5:29 p.m. UTC | #1
On 6/13/21 4:07 PM, Alper Nebi Yasak wrote:
> The filesystem and EFI (capsule and secure boot) test setups try to use
> guestmount and virt-make-fs respectively to prepare disk images to run
> tests on. However, these libguestfs tools need a kernel image and fail
> with the following message (revealed in debug/trace mode) if it can't
> find one:
>
>      supermin: failed to find a suitable kernel (host_cpu=x86_64).
>
>      I looked for kernels in /boot and modules in /lib/modules.
>
>      If this is a Xen guest, and you only have Xen domU kernels
>      installed, try installing a fullvirt kernel (only for
>      supermin use, you shouldn't boot the Xen guest with it).
>
> This failure then causes these tests to be skipped in CIs. Install a
> kernel package in the Docker containers so the CIs can run these
> tests with libguestfs tools again (assuming the container is run with
> necessary host devices and privileges). As this kernel would be only
> used for virtualization, we can use the kernel package specialized for
> that. On Ubuntu systems kernel images are not readable by non-root
> users, so explicitly add read permissions with chmod as well.
>
> Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
> Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
>
> Changes in v2:
> - Add tag "Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>"
>
>   tools/docker/Dockerfile | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
> index d2f0074ee8a6..563b16639e54 100644
> --- a/tools/docker/Dockerfile
> +++ b/tools/docker/Dockerfile
> @@ -71,6 +71,7 @@ RUN apt-get update && apt-get install -y \
>   	libssl-dev \
>   	libudev-dev \
>   	libusb-1.0-0-dev \
> +	linux-image-kvm \
>   	lzma-alone \
>   	lzop \
>   	mount \
> @@ -99,6 +100,9 @@ RUN apt-get update && apt-get install -y \
>   	zip \
>   	&& rm -rf /var/lib/apt/lists/*
>
> +# Make kernels readable for libguestfs tools to work correctly
> +RUN chmod +r /boot/vmlinu* /lib/modules/*/vmlinu* || true

/lib/modules/4.15.0-1092-kvm# find . -name 'vm*'
does not find any file.

We don't need '|| true' if you do not refer to non-existent files.

Best regards

Heinrich

> +
>   # Manually install libmpfr4 for the toolchains
>   RUN wget http://mirrors.kernel.org/ubuntu/pool/main/m/mpfr4/libmpfr4_3.1.4-1_amd64.deb && dpkg -i libmpfr4_3.1.4-1_amd64.deb && rm libmpfr4_3.1.4-1_amd64.deb
>
>
Alper Nebi Yasak June 21, 2021, 6:12 p.m. UTC | #2
On 14/06/2021 20:29, Heinrich Schuchardt wrote:
> On 6/13/21 4:07 PM, Alper Nebi Yasak wrote:
>>
>>      supermin: failed to find a suitable kernel (host_cpu=x86_64).
>>
>>      I looked for kernels in /boot and modules in /lib/modules.
>>
>> [...]
>>
>> diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
>> index d2f0074ee8a6..563b16639e54 100644
>> --- a/tools/docker/Dockerfile
>> +++ b/tools/docker/Dockerfile
>> @@ -71,6 +71,7 @@ RUN apt-get update && apt-get install -y \
>>   	libssl-dev \
>>   	libudev-dev \
>>   	libusb-1.0-0-dev \
>> +	linux-image-kvm \
>>   	lzma-alone \
>>   	lzop \
>>   	mount \
>> @@ -99,6 +100,9 @@ RUN apt-get update && apt-get install -y \
>>   	zip \
>>   	&& rm -rf /var/lib/apt/lists/*
>>
>> +# Make kernels readable for libguestfs tools to work correctly
>> +RUN chmod +r /boot/vmlinu* /lib/modules/*/vmlinu* || true
> 
> /lib/modules/4.15.0-1092-kvm# find . -name 'vm*'
> does not find any file.
> 
> We don't need '|| true' if you do not refer to non-existent files.

I included both dirs as libguestfs checks both of them. If that doesn't
convince you, I can send a v3 with just `chmod +r /boot/vmlinu*`.

I actually misread the error message above as mentioning both dirs for
kernel so I didn't explicitly write it in the commit message, but the
source code [1] confirms that both are checked.

[1]
https://github.com/libguestfs/supermin/blob/master/src/format_ext2_kernel.ml#L28-L49

(sorry for the late reply)
Heinrich Schuchardt June 21, 2021, 6:35 p.m. UTC | #3
On 6/21/21 8:12 PM, Alper Nebi Yasak wrote:
> On 14/06/2021 20:29, Heinrich Schuchardt wrote:
>> On 6/13/21 4:07 PM, Alper Nebi Yasak wrote:
>>>
>>>       supermin: failed to find a suitable kernel (host_cpu=x86_64).
>>>
>>>       I looked for kernels in /boot and modules in /lib/modules.
>>>
>>> [...]
>>>
>>> diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
>>> index d2f0074ee8a6..563b16639e54 100644
>>> --- a/tools/docker/Dockerfile
>>> +++ b/tools/docker/Dockerfile
>>> @@ -71,6 +71,7 @@ RUN apt-get update && apt-get install -y \
>>>    	libssl-dev \
>>>    	libudev-dev \
>>>    	libusb-1.0-0-dev \
>>> +	linux-image-kvm \
>>>    	lzma-alone \
>>>    	lzop \
>>>    	mount \
>>> @@ -99,6 +100,9 @@ RUN apt-get update && apt-get install -y \
>>>    	zip \
>>>    	&& rm -rf /var/lib/apt/lists/*
>>>
>>> +# Make kernels readable for libguestfs tools to work correctly
>>> +RUN chmod +r /boot/vmlinu* /lib/modules/*/vmlinu* || true
>>
>> /lib/modules/4.15.0-1092-kvm# find . -name 'vm*'
>> does not find any file.
>>
>> We don't need '|| true' if you do not refer to non-existent files.
>
> I included both dirs as libguestfs checks both of them. If that doesn't
> convince you, I can send a v3 with just `chmod +r /boot/vmlinu*`.

We are on Ubuntu. We only need to consider files that Ubuntu actually
provides.

Best regards

Heinrich

>
> I actually misread the error message above as mentioning both dirs for
> kernel so I didn't explicitly write it in the commit message, but the
> source code [1] confirms that both are checked.
>
> [1]
> https://github.com/libguestfs/supermin/blob/master/src/format_ext2_kernel.ml#L28-L49
>
> (sorry for the late reply)
>
diff mbox series

Patch

diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
index d2f0074ee8a6..563b16639e54 100644
--- a/tools/docker/Dockerfile
+++ b/tools/docker/Dockerfile
@@ -71,6 +71,7 @@  RUN apt-get update && apt-get install -y \
 	libssl-dev \
 	libudev-dev \
 	libusb-1.0-0-dev \
+	linux-image-kvm \
 	lzma-alone \
 	lzop \
 	mount \
@@ -99,6 +100,9 @@  RUN apt-get update && apt-get install -y \
 	zip \
 	&& rm -rf /var/lib/apt/lists/*
 
+# Make kernels readable for libguestfs tools to work correctly
+RUN chmod +r /boot/vmlinu* /lib/modules/*/vmlinu* || true
+
 # Manually install libmpfr4 for the toolchains
 RUN wget http://mirrors.kernel.org/ubuntu/pool/main/m/mpfr4/libmpfr4_3.1.4-1_amd64.deb && dpkg -i libmpfr4_3.1.4-1_amd64.deb && rm libmpfr4_3.1.4-1_amd64.deb