Re: [PATCH] python 3.5 compatibility

2020-12-01 Thread Daniel P . Berrangé
On Tue, Dec 01, 2020 at 04:59:23PM +0100, Enrico Weigelt, metux IT consult 
wrote:
> On 01.12.20 07:33, Markus Armbruster wrote:
> 
> > Which has oldstable status.  Good for running the old and stable
> > software packaged by it (such as QEMU 2.8), and old (and hopefully
> > stable) software of similar vintage.
> 
> It's still heavily used out in the field, and officially supported.
> But that's just one example.
> 
> Perhaps I should add some more details on the situation: I'm using
> (specially built) qemu with ptxdist/dkit - not the distro package.
> The idea w/ ptxdist is that you just pull the trigger and it builds
> everything needed for some project. Qemu is built specifically for
> the configured target. Perhaps you've noticed I'm also doing development
> of new qemu features - something that one doesn't want to do on old
> versions.
> 
> > Have you considered upgrading to stable?
> 
> This would solve the problem just for me alone, not for others out
> there, who're working w/ the BSP. And asking everybody (especially in
> enterprise environments) to do a full release upgrade just for one
> single tool (qemu) isn't someting that works easily.
> 
> If you insist in having python3.6 a hard requirement for qemu, you're
> putting me into the situation of having to do lots of backport work
> for quite long time (until everybody really did the upgrade). :(

python3.6 is just the one problem you've currently hit. In order to keep
the burden of maintaining support for old software under control we have
a well defined set of platforms that we target. When a particular version
of a distro drops off our list, we will bump the minimum versions of any
software we depend on. In this case you've hit python3.6 so far, but we
are liable to bump other minimum versions too which will also impact
this old distro. So I'm afraid it will be a loosing battle to stay on
this old distro, while building cutting edge QEMU.

I appreciate this isn't the answer you want to hear, but we've defined
our support platform matrix to try to balance multiple competing factors
and unfortunately this means distros are going to periodically get dropped
by new QEMU as they get older.

One possible way you can mitigate this is to make use of containers for
your development and deployment. eg even tough you're using an old
Devuan, you can use docker/podman to build and deploy QEMU inside a
stable Devuan container.

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 :|




Re: [PATCH] python 3.5 compatibility

2020-12-01 Thread Enrico Weigelt, metux IT consult
On 01.12.20 07:33, Markus Armbruster wrote:

> Which has oldstable status.  Good for running the old and stable
> software packaged by it (such as QEMU 2.8), and old (and hopefully
> stable) software of similar vintage.

It's still heavily used out in the field, and officially supported.
But that's just one example.

Perhaps I should add some more details on the situation: I'm using
(specially built) qemu with ptxdist/dkit - not the distro package.
The idea w/ ptxdist is that you just pull the trigger and it builds
everything needed for some project. Qemu is built specifically for
the configured target. Perhaps you've noticed I'm also doing development
of new qemu features - something that one doesn't want to do on old
versions.

> Have you considered upgrading to stable?

This would solve the problem just for me alone, not for others out
there, who're working w/ the BSP. And asking everybody (especially in
enterprise environments) to do a full release upgrade just for one
single tool (qemu) isn't someting that works easily.

If you insist in having python3.6 a hard requirement for qemu, you're
putting me into the situation of having to do lots of backport work
for quite long time (until everybody really did the upgrade). :(

This individual patch wasn't very complicated, but expect even more
(and more tricky cases) on the horizon.


--mtx

-- 
---
Hinweis: unverschlüsselte E-Mails können leicht abgehört und manipuliert
werden ! Für eine vertrauliche Kommunikation senden Sie bitte ihren
GPG/PGP-Schlüssel zu.
---
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
i...@metux.net -- +49-151-27565287



Re: [PATCH] python 3.5 compatibility

2020-11-30 Thread Marc-André Lureau
Hi

On Mon, Nov 30, 2020 at 10:29 PM Enrico Weigelt, metux IT consult <
l...@metux.net> wrote:

> On 27.11.20 20:15, Peter Maydell wrote:
>
> Hi,
>
> > Could you say which "stable distros" you have in mind, and whether
> > they are covered by our "supported build platforms" policy
> > https://www.qemu.org/docs/master/system/build-platforms.html  ?
>
> I'm running on Devuan Ascii.
>
> And packaging python-3.6 just for a few pieces of one application (qemu)
> is far too much work.
>

It might be necessary to keep that distro alive, as python 3.5 is EOL:

https://www.python.org/downloads/release/python-3510/

(fwiw, upcoming meson version will also depend on >= 3.6)


> --mtx
>
> --
> ---
> Hinweis: unverschlüsselte E-Mails können leicht abgehört und manipuliert
> werden ! Für eine vertrauliche Kommunikation senden Sie bitte ihren
> GPG/PGP-Schlüssel zu.
> ---
> Enrico Weigelt, metux IT consult
> Free software and Linux embedded engineering
> i...@metux.net -- +49-151-27565287
>
>

-- 
Marc-André Lureau


Re: [PATCH] python 3.5 compatibility

2020-11-30 Thread Markus Armbruster
"Enrico Weigelt, metux IT consult"  writes:

> On 27.11.20 20:15, Peter Maydell wrote:
>
> Hi,
>
>> Could you say which "stable distros" you have in mind, and whether
>> they are covered by our "supported build platforms" policy
>> https://www.qemu.org/docs/master/system/build-platforms.html  ?
>
> I'm running on Devuan Ascii.

Which has oldstable status.  Good for running the old and stable
software packaged by it (such as QEMU 2.8), and old (and hopefully
stable) software of similar vintage.

Devian ASCII appears to be a derivative of Debian 9 Stretch, which we no
longer support, because it's EOL.  docs/system/build-platforms.rst:

For distributions with long-lifetime releases, the project will aim to
support the most recent major version at all times. Support for the
previous major version will be dropped 2 years after the new major
version is released, or when it reaches "end of life". For the purposes
of identifying supported software versions, the project will look at
RHEL, Debian, Ubuntu LTS, and SLES distros. Other long-lifetime distros
will be assumed to ship similar software versions.

This policy balances cost and benefit of keeping bleeding-edge QEMU work
on a wide variety of hosts.  Years of balancing.

> And packaging python-3.6 just for a few pieces of one application (qemu)
> is far too much work.

Have you considered upgrading to stable?




Re: [PATCH] python 3.5 compatibility

2020-11-30 Thread Enrico Weigelt, metux IT consult
On 30.11.20 10:44, Kevin Wolf wrote:

Hi,

> While type hints are valuable documentation, they are more than just
> that. They help to find and prevent avoidable bugs in the code. We are
> actively in the process of adding them to everything in the QAPI
> generator to improve maintainability rather than removing them.

IOW: I'll have to do lots of backporting work, just to keep it running :(


--mtx

-- 
---
Hinweis: unverschlüsselte E-Mails können leicht abgehört und manipuliert
werden ! Für eine vertrauliche Kommunikation senden Sie bitte ihren
GPG/PGP-Schlüssel zu.
---
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
i...@metux.net -- +49-151-27565287



Re: [PATCH] python 3.5 compatibility

2020-11-30 Thread Enrico Weigelt, metux IT consult
On 27.11.20 20:15, Peter Maydell wrote:

Hi,

> Could you say which "stable distros" you have in mind, and whether
> they are covered by our "supported build platforms" policy
> https://www.qemu.org/docs/master/system/build-platforms.html  ?

I'm running on Devuan Ascii.

And packaging python-3.6 just for a few pieces of one application (qemu)
is far too much work.

--mtx

-- 
---
Hinweis: unverschlüsselte E-Mails können leicht abgehört und manipuliert
werden ! Für eine vertrauliche Kommunikation senden Sie bitte ihren
GPG/PGP-Schlüssel zu.
---
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
i...@metux.net -- +49-151-27565287



Re: [PATCH] python 3.5 compatibility

2020-11-30 Thread Kevin Wolf
Am 27.11.2020 um 19:36 hat Enrico Weigelt, metux IT consult geschrieben:
> Several stable distros are still on python-3.5, so qemu cannot be
> built there, w/o backporting the whole python stack. In order to
> make qemu build there, make it running w/ python-3.5. The changes
> are mostly removing the new type annotations (which, IMHO, just
> serve for documentation purpose)

While type hints are valuable documentation, they are more than just
that. They help to find and prevent avoidable bugs in the code. We are
actively in the process of adding them to everything in the QAPI
generator to improve maintainability rather than removing them.

Kevin

> and replacing f-strings by classic
> string formatting.
> 
> Signed-off-by: Enrico Weigelt, metux IT consult 
> ---
>  configure  |  4 +--
>  scripts/block-coroutine-wrapper.py | 56 
> ++
>  scripts/qapi/commands.py   |  2 +-
>  scripts/qapi/common.py |  2 +-
>  scripts/qapi/events.py |  2 +-
>  scripts/qapi/gen.py| 10 +++
>  scripts/qapi/main.py   |  6 ++--
>  scripts/qapi/schema.py |  2 +-
>  scripts/qapi/source.py | 10 +++
>  9 files changed, 46 insertions(+), 48 deletions(-)




Re: [PATCH] python 3.5 compatibility

2020-11-27 Thread Peter Maydell
On Fri, 27 Nov 2020 at 19:12, Enrico Weigelt, metux IT consult
 wrote:
> Several stable distros are still on python-3.5, so qemu cannot be
> built there, w/o backporting the whole python stack. In order to
> make qemu build there, make it running w/ python-3.5. The changes
> are mostly removing the new type annotations (which, IMHO, just
> serve for documentation purpose) and replacing f-strings by classic
> string formatting.

We dropped Python 3.5 support deliberately in commit
1b11f28d05121fec43 on the basis that all our supported build
platforms are on at least 3.6 and there were features we wanted there.

Could you say which "stable distros" you have in mind, and whether
they are covered by our "supported build platforms" policy
https://www.qemu.org/docs/master/system/build-platforms.html  ?

thanks
-- PMM



[PATCH] python 3.5 compatibility

2020-11-27 Thread Enrico Weigelt, metux IT consult
Several stable distros are still on python-3.5, so qemu cannot be
built there, w/o backporting the whole python stack. In order to
make qemu build there, make it running w/ python-3.5. The changes
are mostly removing the new type annotations (which, IMHO, just
serve for documentation purpose) and replacing f-strings by classic
string formatting.

Signed-off-by: Enrico Weigelt, metux IT consult 
---
 configure  |  4 +--
 scripts/block-coroutine-wrapper.py | 56 ++
 scripts/qapi/commands.py   |  2 +-
 scripts/qapi/common.py |  2 +-
 scripts/qapi/events.py |  2 +-
 scripts/qapi/gen.py| 10 +++
 scripts/qapi/main.py   |  6 ++--
 scripts/qapi/schema.py |  2 +-
 scripts/qapi/source.py | 10 +++
 9 files changed, 46 insertions(+), 48 deletions(-)

diff --git a/configure b/configure
index 18c26e0389..e1119929fa 100755
--- a/configure
+++ b/configure
@@ -1866,8 +1866,8 @@ fi
 
 # Note that if the Python conditional here evaluates True we will exit
 # with status 1 which is a shell 'false' value.
-if ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then
-  error_exit "Cannot use '$python', Python >= 3.6 is required." \
+if ! $python -c 'import sys; sys.exit(sys.version_info < (3,5))'; then
+  error_exit "Cannot use '$python', Python >= 3.5 is required." \
   "Use --python=/path/to/python to specify a supported Python."
 fi
 
diff --git a/scripts/block-coroutine-wrapper.py 
b/scripts/block-coroutine-wrapper.py
index 0461fd1c45..a36f7af06f 100644
--- a/scripts/block-coroutine-wrapper.py
+++ b/scripts/block-coroutine-wrapper.py
@@ -32,11 +32,11 @@ def gen_header():
 copyright = re.sub('^.*Copyright', 'Copyright', __doc__, flags=re.DOTALL)
 copyright = re.sub('^(?=.)', ' * ', copyright.strip(), flags=re.MULTILINE)
 copyright = re.sub('^$', ' *', copyright, flags=re.MULTILINE)
-return f"""\
+return """\
 /*
  * File is generated by scripts/block-coroutine-wrapper.py
  *
-{copyright}
+"""+copyright+"""
  */
 
 #include "qemu/osdep.h"
@@ -55,7 +55,7 @@ class ParamDecl:
 def __init__(self, param_decl: str) -> None:
 m = self.param_re.match(param_decl.strip())
 if m is None:
-raise ValueError(f'Wrong parameter declaration: "{param_decl}"')
+raise ValueError('Wrong parameter declaration: '+param_decl)
 self.decl = m.group('decl')
 self.type = m.group('type')
 self.name = m.group('name')
@@ -107,44 +107,42 @@ def gen_wrapper(func: FuncDecl) -> str:
 bs = 'bs' if func.args[0].type == 'BlockDriverState *' else 'child->bs'
 struct_name = snake_to_camel(name)
 
-return f"""\
+return """\
 /*
- * Wrappers for {name}
+ * Wrappers for """+name+"""
  */
 
-typedef struct {struct_name} {{
+typedef struct """+struct_name+""" {
 BdrvPollCo poll_state;
-{ func.gen_block('{decl};') }
-}} {struct_name};
+"""+func.gen_block('{decl};')+"""
+} """+struct_name+""";
 
-static void coroutine_fn {name}_entry(void *opaque)
-{{
-{struct_name} *s = opaque;
+static void coroutine_fn """+name+"""_entry(void *opaque)
+{
+"""+struct_name+""" *s = opaque;
 
-s->poll_state.ret = {name}({ func.gen_list('s->{name}') });
+s->poll_state.ret = """+name+"""("""+func.gen_list('s->{name}')+""");
 s->poll_state.in_progress = false;
 
 aio_wait_kick();
-}}
-
-int {func.name}({ func.gen_list('{decl}') })
-{{
-if (qemu_in_coroutine()) {{
-return {name}({ func.gen_list('{name}') });
-}} else {{
-{struct_name} s = {{
-.poll_state.bs = {bs},
+}
+
+int """+func.name+"""("""+func.gen_list('{decl}')+""")
+{
+if (qemu_in_coroutine()) {
+return """+name+"""("""+func.gen_list('{name}')+""");
+} else {
+"""+struct_name+""" s = {
+.poll_state.bs = """+bs+""",
 .poll_state.in_progress = true,
+"""+func.gen_block('.{name} = {name},')+"""
+};
 
-{ func.gen_block('.{name} = {name},') }
-}};
-
-s.poll_state.co = qemu_coroutine_create({name}_entry, );
+s.poll_state.co = qemu_coroutine_create("""+name+"""_entry, );
 
 return bdrv_poll_co(_state);
-}}
-}}"""
-
+}
+}"""
 
 def gen_wrappers(input_code: str) -> str:
 res = ''
@@ -157,7 +155,7 @@ def gen_wrappers(input_code: str) -> str:
 
 if __name__ == '__main__':
 if len(sys.argv) < 3:
-exit(f'Usage: {sys.argv[0]} OUT_FILE.c IN_FILE.[ch]...')
+exit('Usage: '+sys.argv[0]+' OUT_FILE.c IN_FILE.[ch]...')
 
 with open(sys.argv[1], 'w', encoding='utf-8') as f_out:
 f_out.write(gen_header())
diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py
index 50978090b4..3b22a16759 100644
--- a/scripts/qapi/commands.py
+++ b/scripts/qapi/commands.py
@@ -256,7 +256,7 @@ class 
QAPISchemaGenCommandVisitor(QAPISchemaModularCVisitor):
 prefix,