All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, "Thomas Huth" <th.huth+qemu@posteo.eu>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: Re: [PATCH] tests/functional/qemu_test/asset.py: Don't use setxattr when it doesn't exist
Date: Fri, 01 May 2026 13:38:27 +0100	[thread overview]
Message-ID: <875x57e24c.fsf@draig.linaro.org> (raw)
In-Reply-To: <20260501115506.3792110-1-peter.maydell@linaro.org> (Peter Maydell's message of "Fri, 1 May 2026 12:55:06 +0100")

Peter Maydell <peter.maydell@linaro.org> writes:

> The Python os.setxattr() API is Linux-specific, so trying to use
> it on other OSes triggers a failure:
>
>   File "/Users/pm215/src/qemu/tests/functional/qemu_test/asset.py",
> line 227, in fetch
>     os.setxattr(str(tmp_cache_file), "user.qemu-asset-url",
>     ^^^^^^^^^^^
> AttributeError: module 'os' has no attribute 'setxattr'
>
> Since we only set the attributes here for informational
> purposes, skip them when os.setxattr() isn't available.
>
> Cc: qemu-stable@nongnu.org
> Fixes: 9903217a4ed013 ("tests/functional: add a module for handling asset download & caching")
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  tests/functional/qemu_test/asset.py | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/tests/functional/qemu_test/asset.py b/tests/functional/qemu_test/asset.py
> index 51a434b2b7..0abd89e0a3 100644
> --- a/tests/functional/qemu_test/asset.py
> +++ b/tests/functional/qemu_test/asset.py
> @@ -223,11 +223,14 @@ def fetch(self):
>              raise AssetError(self, "Download retries exceeded", transient=True)
>  
>          try:
> -            # Set these just for informational purposes
> -            os.setxattr(str(tmp_cache_file), "user.qemu-asset-url",
> -                        self.url.encode('utf8'))
> -            os.setxattr(str(tmp_cache_file), "user.qemu-asset-hash",
> -                        self.hash.encode('utf8'))
> +            # Set these just for informational purposes. Note that
> +            # setxattr is Linux-only; as this is only informational
> +            # we can simply skip it on other platforms.
> +            if hasattr(os, "setxattr"):
> +                os.setxattr(str(tmp_cache_file), "user.qemu-asset-url",
> +                            self.url.encode('utf8'))
> +                os.setxattr(str(tmp_cache_file), "user.qemu-asset-hash",
> +                            self.hash.encode('utf8'))

Well TIL:

  attr -g qemu-asset-url /home/alex/.cache/qemu/download/ff9d7dd7c6bdba325bd85ee85c02db61ff653e129558aeffe6aff55bffb6763a
  Attribute "qemu-asset-url" had a 73 byte value for /home/alex/.cache/qemu/download/ff9d7dd7c6bdba325bd85ee85c02db61ff653e129558aeffe6aff55bffb6763a:
  https://qemu-advcal.gitlab.io/qac-best-of-multiarch/download/day20.tar.xz

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

>          except OSError as e:
>              self.log.debug("Unable to set xattr on %s: %s", tmp_cache_file, e)

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


  parent reply	other threads:[~2026-05-01 12:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-01 11:55 [PATCH] tests/functional/qemu_test/asset.py: Don't use setxattr when it doesn't exist Peter Maydell
2026-05-01 12:07 ` Daniel P. Berrangé
2026-05-01 12:38 ` Alex Bennée [this message]
2026-05-01 21:01 ` Thomas Huth
2026-05-11 14:47 ` Peter Maydell
2026-05-11 15:15   ` Daniel P. Berrangé
2026-05-11 15:23     ` Peter Maydell
2026-05-12  4:49   ` Thomas Huth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875x57e24c.fsf@draig.linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=berrange@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=th.huth+qemu@posteo.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.