[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/6] iotests: add warning for rogue 'qemu' packages
From: |
Daniel P . Berrangé |
Subject: |
Re: [PATCH 2/6] iotests: add warning for rogue 'qemu' packages |
Date: |
Thu, 23 Sep 2021 12:09:07 +0100 |
User-agent: |
Mutt/2.0.7 (2021-05-04) |
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 :|