qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: John Snow <jsnow@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>,
	Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [PATCH 2/6] iotests: add warning for rogue 'qemu' packages
Date: Thu, 23 Sep 2021 12:09:07 +0100	[thread overview]
Message-ID: <YUxgU6DrbcspzDtr@redhat.com> (raw)
In-Reply-To: <20210923001625.3996451-3-jsnow@redhat.com>

On Wed, Sep 22, 2021 at 08:16:21PM -0400, John Snow wrote:
> Add a warning for when 'iotests' runs against a qemu namespace that
> isn't the one in the source tree. This might occur if you have
> (accidentally) installed the Python namespace package to your local
> packages.

IIUC, it is/was a valid use case to run the iotests on arbitrary
QEMU outside the source tree ie a distro packaged binary set.

Are we not allowing the tests/qemu-iotests/* content to be
run outside the context of the main source tree for this
purpose ?

eg  consider if Fedora/RHEL builds put tests/qemu-iotests/* into
a 'qemu-iotests' RPM, which was installed and used with a distro
package python-qemu ?

> (I'm not going to say that this is because I bit myself with this,
> but. You can fill in the blanks.)
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>  tests/qemu-iotests/testenv.py | 21 ++++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py
> index 88104dace90..8a43b193af5 100644
> --- a/tests/qemu-iotests/testenv.py
> +++ b/tests/qemu-iotests/testenv.py
> @@ -16,6 +16,8 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  #
>  
> +import importlib.util
> +import logging
>  import os
>  import sys
>  import tempfile
> @@ -25,7 +27,7 @@
>  import random
>  import subprocess
>  import glob
> -from typing import List, Dict, Any, Optional, ContextManager
> +from typing import List, Dict, Any, Optional, ContextManager, cast
>  
>  DEF_GDB_OPTIONS = 'localhost:12345'
>  
> @@ -112,6 +114,22 @@ def init_directories(self) -> None:
>          # Path where qemu goodies live in this source tree.
>          qemu_srctree_path = Path(__file__, '../../../python').resolve()
>  
> +        # warn if we happen to be able to find 'qemu' packages from an
> +        # unexpected location (i.e. the package is already installed in
> +        # the user's environment)
> +        qemu_spec = importlib.util.find_spec('qemu.qmp')
> +        if qemu_spec:
> +            spec_path = Path(cast(str, qemu_spec.origin))
> +            try:
> +                _ = spec_path.relative_to(qemu_srctree_path)
> +            except ValueError:
> +                self._logger.warning(
> +                    "WARNING: 'qemu' package will be imported from outside "
> +                    "the source tree!")
> +                self._logger.warning(
> +                    "Importing from: '%s'",
> +                    spec_path.parents[1])

It feels to me like the scenario  we're blocking here is actally
the scenario we want to aim for.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



  parent reply	other threads:[~2021-09-23 11:11 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-23  0:16 [PATCH 0/6] iotests: update environment and linting configuration John Snow
2021-09-23  0:16 ` [PATCH 1/6] iotests: add 'qemu' package location to PYTHONPATH in testenv John Snow
2021-09-23 10:33   ` Philippe Mathieu-Daudé
2021-09-23 15:19   ` Vladimir Sementsov-Ogievskiy
2021-09-23 15:46     ` John Snow
2021-09-23  0:16 ` [PATCH 2/6] iotests: add warning for rogue 'qemu' packages John Snow
2021-09-23 10:57   ` Kevin Wolf
2021-09-23 11:17     ` Kevin Wolf
2021-09-23 14:59       ` John Snow
2021-09-23 11:09   ` Daniel P. Berrangé [this message]
2021-09-23 15:42     ` John Snow
2021-09-23  0:16 ` [PATCH 3/6] iotests/linters: check mypy files all at once John Snow
2021-09-23 10:33   ` Philippe Mathieu-Daudé
2021-09-23 15:39   ` Vladimir Sementsov-Ogievskiy
2021-09-23  0:16 ` [PATCH 4/6] iotests/mirror-top-perms: Adjust imports John Snow
2021-09-23 15:40   ` Vladimir Sementsov-Ogievskiy
2021-09-23  0:16 ` [PATCH 5/6] iotests/migrate-bitmaps-test: delint John Snow
2021-09-23 15:48   ` Vladimir Sementsov-Ogievskiy
2021-09-23  0:16 ` [PATCH 6/6] iotests: Update for pylint 2.11.1 John Snow
2021-09-23 15:51   ` Vladimir Sementsov-Ogievskiy
2021-09-23 12:57 ` [PATCH 0/6] iotests: update environment and linting configuration Kevin Wolf

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=YUxgU6DrbcspzDtr@redhat.com \
    --to=berrange@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@virtuozzo.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).