[1/1] eal: enable xz read support and ignore warning
Checks
Commit Message
archive_read_support_filter_xz returns a warning when
compression is not fully supported and is supported
through external program. This warning can be ignored
when reading the files through firmware open as only
decompression is required.
Fixes: 40edb9c0d36b ("eal: handle compressed firmware")
Cc: stable@dpdk.org
Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
---
lib/eal/unix/eal_firmware.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
Comments
Hello,
Thank you for the patch.
On Fri, Sep 22, 2023 at 6:54 PM Srikanth Yalavarthi
<syalavarthi@marvell.com> wrote:
>
> archive_read_support_filter_xz returns a warning when
> compression is not fully supported and is supported
> through external program. This warning can be ignored
> when reading the files through firmware open as only
> decompression is required.
- I don't understand the last sentence, it seems to state something
about *only* needing decompression support but well,
archive_read_support_filter_xz (like archive_read_support_filter_*
other helpers) *is about* decompressing a file.
- I can't reproduce this ARCHIVE_WARN thing, not sure which libarchive
you use, or which knob/build option triggered this behavior you
observe.
So I need you to to double check how this change affects the code.
Please pass a xz-compressed mldev fw .bin file and confirm it still works.
>
> Fixes: 40edb9c0d36b ("eal: handle compressed firmware")
> Cc: stable@dpdk.org
>
> Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
> ---
> lib/eal/unix/eal_firmware.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/lib/eal/unix/eal_firmware.c b/lib/eal/unix/eal_firmware.c
> index d1616b0bd9..05c06c222a 100644
> --- a/lib/eal/unix/eal_firmware.c
> +++ b/lib/eal/unix/eal_firmware.c
> @@ -25,12 +25,19 @@ static int
> firmware_open(struct firmware_read_ctx *ctx, const char *name, size_t blocksize)
> {
> struct archive_entry *e;
> + int err;
>
> ctx->a = archive_read_new();
> if (ctx->a == NULL)
> return -1;
> +
> + err = archive_read_support_filter_xz(ctx->a);
> + if (err != ARCHIVE_OK && err != ARCHIVE_WARN) {
> + ctx->a = NULL;
> + return -1;
> + }
- This patch leaks ctx->a content on error.
Plus I prefer we keep the original order of the code because it
matches what libarchive does: first look for an archive format, then
next look for compression matters.
The simpler is to add an error label like I did in the debug patch.
Something like:
diff --git a/lib/eal/unix/eal_firmware.c b/lib/eal/unix/eal_firmware.c
index d1616b0bd9..269688d550 100644
--- a/lib/eal/unix/eal_firmware.c
+++ b/lib/eal/unix/eal_firmware.c
@@ -25,19 +25,27 @@ static int
firmware_open(struct firmware_read_ctx *ctx, const char *name, size_t
blocksize)
{
struct archive_entry *e;
+ int err;
ctx->a = archive_read_new();
if (ctx->a == NULL)
return -1;
- if (archive_read_support_format_raw(ctx->a) != ARCHIVE_OK ||
- archive_read_support_filter_xz(ctx->a) != ARCHIVE_OK ||
- archive_read_open_filename(ctx->a, name,
blocksize) != ARCHIVE_OK ||
- archive_read_next_header(ctx->a, &e) != ARCHIVE_OK) {
- archive_read_free(ctx->a);
- ctx->a = NULL;
- return -1;
- }
+ if (archive_read_support_format_raw(ctx->a) != ARCHIVE_OK)
+ goto error;
+ err = archive_read_support_filter_xz(ctx->a);
+ if (err != ARCHIVE_OK && err != ARCHIVE_WARN)
+ goto error;
+ if (archive_read_open_filename(ctx->a, name, blocksize) != ARCHIVE_OK)
+ goto error;
+ if (archive_read_next_header(ctx->a, &e))
+ goto error;
+
return 0;
+
+error:
+ archive_read_free(ctx->a);
+ ctx->a = NULL;
+ return -1;
}
static ssize_t
> -----Original Message-----
> From: David Marchand <david.marchand@redhat.com>
> Sent: 25 September 2023 14:40
> To: Srikanth Yalavarthi <syalavarthi@marvell.com>
> Cc: Aaron Conole <aconole@redhat.com>; Igor Russkikh
> <irusskikh@marvell.com>; dev@dpdk.org; Shivah Shankar Shankar Narayan
> Rao <sshankarnara@marvell.com>; Anup Prabhu <aprabhu@marvell.com>;
> Prince Takkar <ptakkar@marvell.com>; jerinjacobk@gmail.com;
> stable@dpdk.org; Srikanth Yalavarthi <syalavarthi@marvell.com>
> Subject: [EXT] Re: [PATCH 1/1] eal: enable xz read support and ignore
> warning
>
> External Email
>
> ----------------------------------------------------------------------
> Hello,
>
> Thank you for the patch.
>
> On Fri, Sep 22, 2023 at 6:54 PM Srikanth Yalavarthi
> <syalavarthi@marvell.com> wrote:
> >
> > archive_read_support_filter_xz returns a warning when compression is
> > not fully supported and is supported through external program. This
> > warning can be ignored when reading the files through firmware open as
> > only decompression is required.
>
> - I don't understand the last sentence, it seems to state something about
> *only* needing decompression support but well,
> archive_read_support_filter_xz (like archive_read_support_filter_* other
> helpers) *is about* decompressing a file.
What I meant is, in rte_firmware_read, we will be reading / decompressing the archive files.
Since support to write compressed files is required here, we can ignore the ARCHIVE_WARN.
>
>
> - I can't reproduce this ARCHIVE_WARN thing, not sure which libarchive you
> use, or which knob/build option triggered this behavior you observe.
> So I need you to to double check how this change affects the code.
>
In our build setup, we are cross-compiling libarchive without any dependency libs/headers like zlib, bzip2, lzma enabled.
I guess this is causing libarchive to be built without compression support.
> Please pass a xz-compressed mldev fw .bin file and confirm it still works.
I have tested 3 cases.
(1) ml-fw.bin -> A decompressed binary file
(2) ml-fw.bin.xz -> A compressed archive created from mlip-fw.bin (1)
(3) ml-fw.bin -> mlip-fw.bin.xz (2) renamed as ml-fw.bin
>
>
> >
> > Fixes: 40edb9c0d36b ("eal: handle compressed firmware")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
> > ---
> > lib/eal/unix/eal_firmware.c | 9 ++++++++-
> > 1 file changed, 8 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/eal/unix/eal_firmware.c b/lib/eal/unix/eal_firmware.c
> > index d1616b0bd9..05c06c222a 100644
> > --- a/lib/eal/unix/eal_firmware.c
> > +++ b/lib/eal/unix/eal_firmware.c
> > @@ -25,12 +25,19 @@ static int
> > firmware_open(struct firmware_read_ctx *ctx, const char *name, size_t
> > blocksize) {
> > struct archive_entry *e;
> > + int err;
> >
> > ctx->a = archive_read_new();
> > if (ctx->a == NULL)
> > return -1;
> > +
> > + err = archive_read_support_filter_xz(ctx->a);
> > + if (err != ARCHIVE_OK && err != ARCHIVE_WARN) {
> > + ctx->a = NULL;
> > + return -1;
> > + }
>
> - This patch leaks ctx->a content on error.
>
> Plus I prefer we keep the original order of the code because it matches what
> libarchive does: first look for an archive format, then next look for
> compression matters.
>
> The simpler is to add an error label like I did in the debug patch.
> Something like:
Submitted v2 patch with suggested changes.
>
> diff --git a/lib/eal/unix/eal_firmware.c b/lib/eal/unix/eal_firmware.c index
> d1616b0bd9..269688d550 100644
> --- a/lib/eal/unix/eal_firmware.c
> +++ b/lib/eal/unix/eal_firmware.c
> @@ -25,19 +25,27 @@ static int
> firmware_open(struct firmware_read_ctx *ctx, const char *name, size_t
> blocksize)
> {
> struct archive_entry *e;
> + int err;
>
> ctx->a = archive_read_new();
> if (ctx->a == NULL)
> return -1;
> - if (archive_read_support_format_raw(ctx->a) != ARCHIVE_OK ||
> - archive_read_support_filter_xz(ctx->a) != ARCHIVE_OK ||
> - archive_read_open_filename(ctx->a, name,
> blocksize) != ARCHIVE_OK ||
> - archive_read_next_header(ctx->a, &e) != ARCHIVE_OK) {
> - archive_read_free(ctx->a);
> - ctx->a = NULL;
> - return -1;
> - }
> + if (archive_read_support_format_raw(ctx->a) != ARCHIVE_OK)
> + goto error;
> + err = archive_read_support_filter_xz(ctx->a);
> + if (err != ARCHIVE_OK && err != ARCHIVE_WARN)
> + goto error;
> + if (archive_read_open_filename(ctx->a, name, blocksize) !=
> ARCHIVE_OK)
> + goto error;
> + if (archive_read_next_header(ctx->a, &e))
> + goto error;
> +
> return 0;
> +
> +error:
> + archive_read_free(ctx->a);
> + ctx->a = NULL;
> + return -1;
> }
>
> static ssize_t
>
>
> --
> David Marchand
@@ -25,12 +25,19 @@ static int
firmware_open(struct firmware_read_ctx *ctx, const char *name, size_t blocksize)
{
struct archive_entry *e;
+ int err;
ctx->a = archive_read_new();
if (ctx->a == NULL)
return -1;
+
+ err = archive_read_support_filter_xz(ctx->a);
+ if (err != ARCHIVE_OK && err != ARCHIVE_WARN) {
+ ctx->a = NULL;
+ return -1;
+ }
+
if (archive_read_support_format_raw(ctx->a) != ARCHIVE_OK ||
- archive_read_support_filter_xz(ctx->a) != ARCHIVE_OK ||
archive_read_open_filename(ctx->a, name, blocksize) != ARCHIVE_OK ||
archive_read_next_header(ctx->a, &e) != ARCHIVE_OK) {
archive_read_free(ctx->a);