kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/6] scripts: More Python fixes
@ 2020-05-12 10:32 Philippe Mathieu-Daudé
  2020-05-12 10:32 ` [PATCH v4 1/6] scripts/qemugdb: Remove shebang header Philippe Mathieu-Daudé
                   ` (7 more replies)
  0 siblings, 8 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-12 10:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: Markus Armbruster, John Snow, Paolo Bonzini, qemu-block,
	qemu-trivial, Philippe Mathieu-Daudé,
	Cleber Rosa, kvm, Eduardo Habkost, Alex Bennée,
	Marcelo Tosatti, Stefan Hajnoczi, Fam Zheng

Trivial Python3 fixes, again...

Since v3:
- Fixed missing scripts/qemugdb/timers.py (kwolf)
- Cover more scripts
- Check for __main__ in few scripts

Since v2:
- Remove patch updating MAINTAINERS

Since v1:
- Added Alex Bennée A-b tags
- Addressed John Snow review comments
  - Use /usr/bin/env
  - Do not modify os.path (dropped last patch)

Philippe Mathieu-Daudé (6):
  scripts/qemugdb: Remove shebang header
  scripts/qemu-gdb: Use Python 3 interpreter
  scripts/qmp: Use Python 3 interpreter
  scripts/kvm/vmxcap: Use Python 3 interpreter and add pseudo-main()
  scripts/modules/module_block: Use Python 3 interpreter & add
    pseudo-main
  tests/migration/guestperf: Use Python 3 interpreter

 scripts/kvm/vmxcap                 |  7 ++++---
 scripts/modules/module_block.py    | 31 +++++++++++++++---------------
 scripts/qemu-gdb.py                |  4 ++--
 scripts/qemugdb/__init__.py        |  3 +--
 scripts/qemugdb/aio.py             |  3 +--
 scripts/qemugdb/coroutine.py       |  3 +--
 scripts/qemugdb/mtree.py           |  4 +---
 scripts/qemugdb/tcg.py             |  1 -
 scripts/qemugdb/timers.py          |  1 -
 scripts/qmp/qom-get                |  2 +-
 scripts/qmp/qom-list               |  2 +-
 scripts/qmp/qom-set                |  2 +-
 scripts/qmp/qom-tree               |  2 +-
 tests/migration/guestperf-batch.py |  2 +-
 tests/migration/guestperf-plot.py  |  2 +-
 tests/migration/guestperf.py       |  2 +-
 16 files changed, 33 insertions(+), 38 deletions(-)

-- 
2.21.3


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v4 1/6] scripts/qemugdb: Remove shebang header
  2020-05-12 10:32 [PATCH v4 0/6] scripts: More Python fixes Philippe Mathieu-Daudé
@ 2020-05-12 10:32 ` Philippe Mathieu-Daudé
  2020-05-13 20:58   ` John Snow
  2020-05-12 10:32 ` [PATCH v4 2/6] scripts/qemu-gdb: Use Python 3 interpreter Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-12 10:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: Markus Armbruster, John Snow, Paolo Bonzini, qemu-block,
	qemu-trivial, Philippe Mathieu-Daudé,
	Cleber Rosa, kvm, Eduardo Habkost, Alex Bennée,
	Marcelo Tosatti, Stefan Hajnoczi, Fam Zheng,
	Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

These scripts are loaded as plugin by GDB (and they don't
have any __main__ entry point). Remove the shebang header.

Acked-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 scripts/qemugdb/__init__.py  | 3 +--
 scripts/qemugdb/aio.py       | 3 +--
 scripts/qemugdb/coroutine.py | 3 +--
 scripts/qemugdb/mtree.py     | 4 +---
 scripts/qemugdb/tcg.py       | 1 -
 scripts/qemugdb/timers.py    | 1 -
 6 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/scripts/qemugdb/__init__.py b/scripts/qemugdb/__init__.py
index 969f552b26..da8ff612e5 100644
--- a/scripts/qemugdb/__init__.py
+++ b/scripts/qemugdb/__init__.py
@@ -1,5 +1,4 @@
-#!/usr/bin/python
-
+#
 # GDB debugging support
 #
 # Copyright (c) 2015 Linaro Ltd
diff --git a/scripts/qemugdb/aio.py b/scripts/qemugdb/aio.py
index 2ba00c4444..d7c1ba0c28 100644
--- a/scripts/qemugdb/aio.py
+++ b/scripts/qemugdb/aio.py
@@ -1,5 +1,4 @@
-#!/usr/bin/python
-
+#
 # GDB debugging support: aio/iohandler debug
 #
 # Copyright (c) 2015 Red Hat, Inc.
diff --git a/scripts/qemugdb/coroutine.py b/scripts/qemugdb/coroutine.py
index 41e079d0e2..db61389022 100644
--- a/scripts/qemugdb/coroutine.py
+++ b/scripts/qemugdb/coroutine.py
@@ -1,5 +1,4 @@
-#!/usr/bin/python
-
+#
 # GDB debugging support
 #
 # Copyright 2012 Red Hat, Inc. and/or its affiliates
diff --git a/scripts/qemugdb/mtree.py b/scripts/qemugdb/mtree.py
index 3030a60d3f..8fe42c3c12 100644
--- a/scripts/qemugdb/mtree.py
+++ b/scripts/qemugdb/mtree.py
@@ -1,5 +1,4 @@
-#!/usr/bin/python
-
+#
 # GDB debugging support
 #
 # Copyright 2012 Red Hat, Inc. and/or its affiliates
@@ -84,4 +83,3 @@ def print_item(self, ptr, offset = gdb.Value(0), level = 0):
         while not isnull(subregion):
             self.print_item(subregion, addr, level)
             subregion = subregion['subregions_link']['tqe_next']
-
diff --git a/scripts/qemugdb/tcg.py b/scripts/qemugdb/tcg.py
index 18880fc9a7..16c03c06a9 100644
--- a/scripts/qemugdb/tcg.py
+++ b/scripts/qemugdb/tcg.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 # -*- coding: utf-8 -*-
 #
 # GDB debugging support, TCG status
diff --git a/scripts/qemugdb/timers.py b/scripts/qemugdb/timers.py
index f0e132d27a..46537b27cf 100644
--- a/scripts/qemugdb/timers.py
+++ b/scripts/qemugdb/timers.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 # -*- coding: utf-8 -*-
 # GDB debugging support
 #
-- 
2.21.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v4 2/6] scripts/qemu-gdb: Use Python 3 interpreter
  2020-05-12 10:32 [PATCH v4 0/6] scripts: More Python fixes Philippe Mathieu-Daudé
  2020-05-12 10:32 ` [PATCH v4 1/6] scripts/qemugdb: Remove shebang header Philippe Mathieu-Daudé
@ 2020-05-12 10:32 ` Philippe Mathieu-Daudé
  2020-05-13 20:58   ` John Snow
  2020-05-12 10:32 ` [PATCH v4 3/6] scripts/qmp: " Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-12 10:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: Markus Armbruster, John Snow, Paolo Bonzini, qemu-block,
	qemu-trivial, Philippe Mathieu-Daudé,
	Cleber Rosa, kvm, Eduardo Habkost, Alex Bennée,
	Marcelo Tosatti, Stefan Hajnoczi, Fam Zheng,
	Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 scripts/qemu-gdb.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/qemu-gdb.py b/scripts/qemu-gdb.py
index f2a305c42e..e0bfa7b5a4 100644
--- a/scripts/qemu-gdb.py
+++ b/scripts/qemu-gdb.py
@@ -1,5 +1,5 @@
-#!/usr/bin/python
-
+#!/usr/bin/env python3
+#
 # GDB debugging support
 #
 # Copyright 2012 Red Hat, Inc. and/or its affiliates
-- 
2.21.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v4 3/6] scripts/qmp: Use Python 3 interpreter
  2020-05-12 10:32 [PATCH v4 0/6] scripts: More Python fixes Philippe Mathieu-Daudé
  2020-05-12 10:32 ` [PATCH v4 1/6] scripts/qemugdb: Remove shebang header Philippe Mathieu-Daudé
  2020-05-12 10:32 ` [PATCH v4 2/6] scripts/qemu-gdb: Use Python 3 interpreter Philippe Mathieu-Daudé
@ 2020-05-12 10:32 ` Philippe Mathieu-Daudé
  2020-05-13 20:59   ` John Snow
  2020-05-12 10:32 ` [PATCH v4 4/6] scripts/kvm/vmxcap: Use Python 3 interpreter and add pseudo-main() Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-12 10:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: Markus Armbruster, John Snow, Paolo Bonzini, qemu-block,
	qemu-trivial, Philippe Mathieu-Daudé,
	Cleber Rosa, kvm, Eduardo Habkost, Alex Bennée,
	Marcelo Tosatti, Stefan Hajnoczi, Fam Zheng,
	Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 scripts/qmp/qom-get  | 2 +-
 scripts/qmp/qom-list | 2 +-
 scripts/qmp/qom-set  | 2 +-
 scripts/qmp/qom-tree | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/scripts/qmp/qom-get b/scripts/qmp/qom-get
index 007b4cd442..7c5ede91bb 100755
--- a/scripts/qmp/qom-get
+++ b/scripts/qmp/qom-get
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 ##
 # QEMU Object Model test tools
 #
diff --git a/scripts/qmp/qom-list b/scripts/qmp/qom-list
index 03bda3446b..bb68fd65d4 100755
--- a/scripts/qmp/qom-list
+++ b/scripts/qmp/qom-list
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 ##
 # QEMU Object Model test tools
 #
diff --git a/scripts/qmp/qom-set b/scripts/qmp/qom-set
index c37fe78b00..19881d85e9 100755
--- a/scripts/qmp/qom-set
+++ b/scripts/qmp/qom-set
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 ##
 # QEMU Object Model test tools
 #
diff --git a/scripts/qmp/qom-tree b/scripts/qmp/qom-tree
index 1c8acf61e7..fa91147a03 100755
--- a/scripts/qmp/qom-tree
+++ b/scripts/qmp/qom-tree
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 ##
 # QEMU Object Model test tools
 #
-- 
2.21.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v4 4/6] scripts/kvm/vmxcap: Use Python 3 interpreter and add pseudo-main()
  2020-05-12 10:32 [PATCH v4 0/6] scripts: More Python fixes Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2020-05-12 10:32 ` [PATCH v4 3/6] scripts/qmp: " Philippe Mathieu-Daudé
@ 2020-05-12 10:32 ` Philippe Mathieu-Daudé
  2020-05-12 11:35   ` Paolo Bonzini
  2020-05-13 21:00   ` John Snow
  2020-05-12 10:32 ` [PATCH v4 5/6] scripts/modules/module_block: Use Python 3 interpreter & add pseudo-main Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  7 siblings, 2 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-12 10:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: Markus Armbruster, John Snow, Paolo Bonzini, qemu-block,
	qemu-trivial, Philippe Mathieu-Daudé,
	Cleber Rosa, kvm, Eduardo Habkost, Alex Bennée,
	Marcelo Tosatti, Stefan Hajnoczi, Fam Zheng

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 scripts/kvm/vmxcap | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/scripts/kvm/vmxcap b/scripts/kvm/vmxcap
index 971ed0e721..6fe66d5f57 100755
--- a/scripts/kvm/vmxcap
+++ b/scripts/kvm/vmxcap
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 #
 # tool for querying VMX capabilities
 #
@@ -275,5 +275,6 @@ controls = [
         ),
     ]
 
-for c in controls:
-    c.show()
+if __name__ == '__main__':
+    for c in controls:
+        c.show()
-- 
2.21.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v4 5/6] scripts/modules/module_block: Use Python 3 interpreter & add pseudo-main
  2020-05-12 10:32 [PATCH v4 0/6] scripts: More Python fixes Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2020-05-12 10:32 ` [PATCH v4 4/6] scripts/kvm/vmxcap: Use Python 3 interpreter and add pseudo-main() Philippe Mathieu-Daudé
@ 2020-05-12 10:32 ` Philippe Mathieu-Daudé
  2020-05-13 21:04   ` John Snow
  2020-05-12 10:32 ` [PATCH v4 6/6] tests/migration/guestperf: Use Python 3 interpreter Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-12 10:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: Markus Armbruster, John Snow, Paolo Bonzini, qemu-block,
	qemu-trivial, Philippe Mathieu-Daudé,
	Cleber Rosa, kvm, Eduardo Habkost, Alex Bennée,
	Marcelo Tosatti, Stefan Hajnoczi, Fam Zheng

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 scripts/modules/module_block.py | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/scripts/modules/module_block.py b/scripts/modules/module_block.py
index f23191fac1..2e7021b952 100644
--- a/scripts/modules/module_block.py
+++ b/scripts/modules/module_block.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 #
 # Module information generator
 #
@@ -10,7 +10,6 @@
 # This work is licensed under the terms of the GNU GPL, version 2.
 # See the COPYING file in the top-level directory.
 
-import sys
 import os
 
 def get_string_struct(line):
@@ -80,19 +79,21 @@ def print_bottom(fheader):
 #endif
 ''')
 
-# First argument: output file
-# All other arguments: modules source files (.c)
-output_file = sys.argv[1]
-with open(output_file, 'w') as fheader:
-    print_top(fheader)
+if __name__ == '__main__':
+    import sys
+    # First argument: output file
+    # All other arguments: modules source files (.c)
+    output_file = sys.argv[1]
+    with open(output_file, 'w') as fheader:
+        print_top(fheader)
 
-    for filename in sys.argv[2:]:
-        if os.path.isfile(filename):
-            process_file(fheader, filename)
-        else:
-            print("File " + filename + " does not exist.", file=sys.stderr)
-            sys.exit(1)
+        for filename in sys.argv[2:]:
+            if os.path.isfile(filename):
+                process_file(fheader, filename)
+            else:
+                print("File " + filename + " does not exist.", file=sys.stderr)
+                sys.exit(1)
 
-    print_bottom(fheader)
+        print_bottom(fheader)
 
-sys.exit(0)
+    sys.exit(0)
-- 
2.21.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v4 6/6] tests/migration/guestperf: Use Python 3 interpreter
  2020-05-12 10:32 [PATCH v4 0/6] scripts: More Python fixes Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2020-05-12 10:32 ` [PATCH v4 5/6] scripts/modules/module_block: Use Python 3 interpreter & add pseudo-main Philippe Mathieu-Daudé
@ 2020-05-12 10:32 ` Philippe Mathieu-Daudé
  2020-05-13 21:08   ` John Snow
  2020-05-12 11:16 ` [PATCH v4 0/6] scripts: More Python fixes Kevin Wolf
  2020-05-29  9:40 ` Philippe Mathieu-Daudé
  7 siblings, 1 reply; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-12 10:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: Markus Armbruster, John Snow, Paolo Bonzini, qemu-block,
	qemu-trivial, Philippe Mathieu-Daudé,
	Cleber Rosa, kvm, Eduardo Habkost, Alex Bennée,
	Marcelo Tosatti, Stefan Hajnoczi, Fam Zheng

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 tests/migration/guestperf-batch.py | 2 +-
 tests/migration/guestperf-plot.py  | 2 +-
 tests/migration/guestperf.py       | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/migration/guestperf-batch.py b/tests/migration/guestperf-batch.py
index cb150ce804..f1e900908d 100755
--- a/tests/migration/guestperf-batch.py
+++ b/tests/migration/guestperf-batch.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 #
 # Migration test batch comparison invokation
 #
diff --git a/tests/migration/guestperf-plot.py b/tests/migration/guestperf-plot.py
index d70bb7a557..907151011a 100755
--- a/tests/migration/guestperf-plot.py
+++ b/tests/migration/guestperf-plot.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 #
 # Migration test graph plotting command
 #
diff --git a/tests/migration/guestperf.py b/tests/migration/guestperf.py
index 99b027e8ba..ba1c4bc4ca 100755
--- a/tests/migration/guestperf.py
+++ b/tests/migration/guestperf.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 #
 # Migration test direct invokation command
 #
-- 
2.21.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 0/6] scripts: More Python fixes
  2020-05-12 10:32 [PATCH v4 0/6] scripts: More Python fixes Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2020-05-12 10:32 ` [PATCH v4 6/6] tests/migration/guestperf: Use Python 3 interpreter Philippe Mathieu-Daudé
@ 2020-05-12 11:16 ` Kevin Wolf
  2020-05-29  9:40 ` Philippe Mathieu-Daudé
  7 siblings, 0 replies; 16+ messages in thread
From: Kevin Wolf @ 2020-05-12 11:16 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Fam Zheng, kvm, qemu-block, qemu-trivial,
	Marcelo Tosatti, Markus Armbruster, Alex Bennée,
	Stefan Hajnoczi, Cleber Rosa, Paolo Bonzini, Eduardo Habkost

Am 12.05.2020 um 12:32 hat Philippe Mathieu-Daudé geschrieben:
> Trivial Python3 fixes, again...
> 
> Since v3:
> - Fixed missing scripts/qemugdb/timers.py (kwolf)
> - Cover more scripts
> - Check for __main__ in few scripts

I'm not sure if the __main__ check actually provides anything useful in
source files of standalone tools that aren't supposed to be imported
from somewhere else. But of course, it's not wrong either.

Reviewed-by: Kevin Wolf <kwolf@redhat.com>


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 4/6] scripts/kvm/vmxcap: Use Python 3 interpreter and add pseudo-main()
  2020-05-12 10:32 ` [PATCH v4 4/6] scripts/kvm/vmxcap: Use Python 3 interpreter and add pseudo-main() Philippe Mathieu-Daudé
@ 2020-05-12 11:35   ` Paolo Bonzini
  2020-05-13 21:00   ` John Snow
  1 sibling, 0 replies; 16+ messages in thread
From: Paolo Bonzini @ 2020-05-12 11:35 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Markus Armbruster, John Snow, qemu-block, qemu-trivial,
	Cleber Rosa, kvm, Eduardo Habkost, Alex Bennée,
	Marcelo Tosatti, Stefan Hajnoczi, Fam Zheng

On 12/05/20 12:32, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  scripts/kvm/vmxcap | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/scripts/kvm/vmxcap b/scripts/kvm/vmxcap
> index 971ed0e721..6fe66d5f57 100755
> --- a/scripts/kvm/vmxcap
> +++ b/scripts/kvm/vmxcap
> @@ -1,4 +1,4 @@
> -#!/usr/bin/python
> +#!/usr/bin/env python3
>  #
>  # tool for querying VMX capabilities
>  #
> @@ -275,5 +275,6 @@ controls = [
>          ),
>      ]
>  
> -for c in controls:
> -    c.show()
> +if __name__ == '__main__':
> +    for c in controls:
> +        c.show()
> 

Acked-by: Paolo Bonzini <pbonzini@redhat.com>


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 1/6] scripts/qemugdb: Remove shebang header
  2020-05-12 10:32 ` [PATCH v4 1/6] scripts/qemugdb: Remove shebang header Philippe Mathieu-Daudé
@ 2020-05-13 20:58   ` John Snow
  0 siblings, 0 replies; 16+ messages in thread
From: John Snow @ 2020-05-13 20:58 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Markus Armbruster, Paolo Bonzini, qemu-block, qemu-trivial,
	Cleber Rosa, kvm, Eduardo Habkost, Alex Bennée,
	Marcelo Tosatti, Stefan Hajnoczi, Fam Zheng,
	Philippe Mathieu-Daudé



On 5/12/20 6:32 AM, Philippe Mathieu-Daudé wrote:
> From: Philippe Mathieu-Daudé <f4bug@amsat.org>
> 
> These scripts are loaded as plugin by GDB (and they don't
> have any __main__ entry point). Remove the shebang header.
> 
> Acked-by: Alex Bennée <alex.bennee@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org
(The A-B should come below the S-O-B unless you do mean to indicate
you've since made changes that AB didn't acknowledge, I think.)

Reviewed-by: John Snow <jsnow@redhat.com>


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 2/6] scripts/qemu-gdb: Use Python 3 interpreter
  2020-05-12 10:32 ` [PATCH v4 2/6] scripts/qemu-gdb: Use Python 3 interpreter Philippe Mathieu-Daudé
@ 2020-05-13 20:58   ` John Snow
  0 siblings, 0 replies; 16+ messages in thread
From: John Snow @ 2020-05-13 20:58 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Markus Armbruster, Paolo Bonzini, qemu-block, qemu-trivial,
	Cleber Rosa, kvm, Eduardo Habkost, Alex Bennée,
	Marcelo Tosatti, Stefan Hajnoczi, Fam Zheng,
	Philippe Mathieu-Daudé


On 5/12/20 6:32 AM, Philippe Mathieu-Daudé wrote:
> From: Philippe Mathieu-Daudé <f4bug@amsat.org>
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: John Snow <jsnow@redhat.com>


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 3/6] scripts/qmp: Use Python 3 interpreter
  2020-05-12 10:32 ` [PATCH v4 3/6] scripts/qmp: " Philippe Mathieu-Daudé
@ 2020-05-13 20:59   ` John Snow
  0 siblings, 0 replies; 16+ messages in thread
From: John Snow @ 2020-05-13 20:59 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Markus Armbruster, Paolo Bonzini, qemu-block, qemu-trivial,
	Cleber Rosa, kvm, Eduardo Habkost, Alex Bennée,
	Marcelo Tosatti, Stefan Hajnoczi, Fam Zheng,
	Philippe Mathieu-Daudé


On 5/12/20 6:32 AM, Philippe Mathieu-Daudé wrote:
> From: Philippe Mathieu-Daudé <f4bug@amsat.org>
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Whoops, I address this in a patch series I'm working on, too. I'll keep
my patch in there for now until this one makes it in, or vice-versa.

Reviewed-by: John Snow <jsnow@redhat.com>


> ---
>  scripts/qmp/qom-get  | 2 +-
>  scripts/qmp/qom-list | 2 +-
>  scripts/qmp/qom-set  | 2 +-
>  scripts/qmp/qom-tree | 2 +-
>  4 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/scripts/qmp/qom-get b/scripts/qmp/qom-get
> index 007b4cd442..7c5ede91bb 100755
> --- a/scripts/qmp/qom-get
> +++ b/scripts/qmp/qom-get
> @@ -1,4 +1,4 @@
> -#!/usr/bin/python
> +#!/usr/bin/env python3
>  ##
>  # QEMU Object Model test tools
>  #
> diff --git a/scripts/qmp/qom-list b/scripts/qmp/qom-list
> index 03bda3446b..bb68fd65d4 100755
> --- a/scripts/qmp/qom-list
> +++ b/scripts/qmp/qom-list
> @@ -1,4 +1,4 @@
> -#!/usr/bin/python
> +#!/usr/bin/env python3
>  ##
>  # QEMU Object Model test tools
>  #
> diff --git a/scripts/qmp/qom-set b/scripts/qmp/qom-set
> index c37fe78b00..19881d85e9 100755
> --- a/scripts/qmp/qom-set
> +++ b/scripts/qmp/qom-set
> @@ -1,4 +1,4 @@
> -#!/usr/bin/python
> +#!/usr/bin/env python3
>  ##
>  # QEMU Object Model test tools
>  #
> diff --git a/scripts/qmp/qom-tree b/scripts/qmp/qom-tree
> index 1c8acf61e7..fa91147a03 100755
> --- a/scripts/qmp/qom-tree
> +++ b/scripts/qmp/qom-tree
> @@ -1,4 +1,4 @@
> -#!/usr/bin/python
> +#!/usr/bin/env python3
>  ##
>  # QEMU Object Model test tools
>  #
> 

-- 
—js


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 4/6] scripts/kvm/vmxcap: Use Python 3 interpreter and add pseudo-main()
  2020-05-12 10:32 ` [PATCH v4 4/6] scripts/kvm/vmxcap: Use Python 3 interpreter and add pseudo-main() Philippe Mathieu-Daudé
  2020-05-12 11:35   ` Paolo Bonzini
@ 2020-05-13 21:00   ` John Snow
  1 sibling, 0 replies; 16+ messages in thread
From: John Snow @ 2020-05-13 21:00 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Markus Armbruster, Paolo Bonzini, qemu-block, qemu-trivial,
	Cleber Rosa, kvm, Eduardo Habkost, Alex Bennée,
	Marcelo Tosatti, Stefan Hajnoczi, Fam Zheng



On 5/12/20 6:32 AM, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  scripts/kvm/vmxcap | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/scripts/kvm/vmxcap b/scripts/kvm/vmxcap
> index 971ed0e721..6fe66d5f57 100755
> --- a/scripts/kvm/vmxcap
> +++ b/scripts/kvm/vmxcap
> @@ -1,4 +1,4 @@
> -#!/usr/bin/python
> +#!/usr/bin/env python3
>  #
>  # tool for querying VMX capabilities
>  #
> @@ -275,5 +275,6 @@ controls = [
>          ),
>      ]
>  
> -for c in controls:
> -    c.show()
> +if __name__ == '__main__':
> +    for c in controls:
> +        c.show()
> 

yay

Reviewed-by: John Snow <jsnow@redhat.com>


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 5/6] scripts/modules/module_block: Use Python 3 interpreter & add pseudo-main
  2020-05-12 10:32 ` [PATCH v4 5/6] scripts/modules/module_block: Use Python 3 interpreter & add pseudo-main Philippe Mathieu-Daudé
@ 2020-05-13 21:04   ` John Snow
  0 siblings, 0 replies; 16+ messages in thread
From: John Snow @ 2020-05-13 21:04 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Markus Armbruster, Paolo Bonzini, qemu-block, qemu-trivial,
	Cleber Rosa, kvm, Eduardo Habkost, Alex Bennée,
	Marcelo Tosatti, Stefan Hajnoczi, Fam Zheng



On 5/12/20 6:32 AM, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  scripts/modules/module_block.py | 31 ++++++++++++++++---------------
>  1 file changed, 16 insertions(+), 15 deletions(-)
> 
> diff --git a/scripts/modules/module_block.py b/scripts/modules/module_block.py
> index f23191fac1..2e7021b952 100644
> --- a/scripts/modules/module_block.py
> +++ b/scripts/modules/module_block.py
> @@ -1,4 +1,4 @@
> -#!/usr/bin/python
> +#!/usr/bin/env python3
>  #
>  # Module information generator
>  #
> @@ -10,7 +10,6 @@
>  # This work is licensed under the terms of the GNU GPL, version 2.
>  # See the COPYING file in the top-level directory.
>  
> -import sys
>  import os
>  
>  def get_string_struct(line):
> @@ -80,19 +79,21 @@ def print_bottom(fheader):
>  #endif
>  ''')
>  
> -# First argument: output file
> -# All other arguments: modules source files (.c)
> -output_file = sys.argv[1]
> -with open(output_file, 'w') as fheader:
> -    print_top(fheader)
> +if __name__ == '__main__':
> +    import sys

You can keep the imports at the top of the file.

If you want to split apart the code such that the core import doesn't
import it, you can create a "core module" containing the classes and
routines, and a separate script entrypoint, which imports arg parsers,
sys.argv, etc.

For this, for now, it's okay to just leave it at the top of the file.

> +    # First argument: output file
> +    # All other arguments: modules source files (.c)
> +    output_file = sys.argv[1]
> +    with open(output_file, 'w') as fheader:
> +        print_top(fheader)
>  
> -    for filename in sys.argv[2:]:
> -        if os.path.isfile(filename):
> -            process_file(fheader, filename)
> -        else:
> -            print("File " + filename + " does not exist.", file=sys.stderr)
> -            sys.exit(1)
> +        for filename in sys.argv[2:]:
> +            if os.path.isfile(filename):
> +                process_file(fheader, filename)
> +            else:
> +                print("File " + filename + " does not exist.", file=sys.stderr)
> +                sys.exit(1)
>  
> -    print_bottom(fheader)
> +        print_bottom(fheader)
>  
> -sys.exit(0)
> +    sys.exit(0)
> 

But, well. It's nitpicky and I'm not sure it matters just yet. It might,
as we start to expand pylint to more places, but we're not being
rigorous about that just yet. So either way, I know this works:

Reviewed-by: John Snow <jsnow@redhat.com>


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 6/6] tests/migration/guestperf: Use Python 3 interpreter
  2020-05-12 10:32 ` [PATCH v4 6/6] tests/migration/guestperf: Use Python 3 interpreter Philippe Mathieu-Daudé
@ 2020-05-13 21:08   ` John Snow
  0 siblings, 0 replies; 16+ messages in thread
From: John Snow @ 2020-05-13 21:08 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Markus Armbruster, Paolo Bonzini, qemu-block, qemu-trivial,
	Cleber Rosa, kvm, Eduardo Habkost, Alex Bennée,
	Marcelo Tosatti, Stefan Hajnoczi, Fam Zheng



On 5/12/20 6:32 AM, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Reviewed-by: John Snow <jsnow@redhat.com>


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 0/6] scripts: More Python fixes
  2020-05-12 10:32 [PATCH v4 0/6] scripts: More Python fixes Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2020-05-12 11:16 ` [PATCH v4 0/6] scripts: More Python fixes Kevin Wolf
@ 2020-05-29  9:40 ` Philippe Mathieu-Daudé
  7 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-29  9:40 UTC (permalink / raw)
  To: qemu-devel
  Cc: Markus Armbruster, John Snow, Paolo Bonzini, qemu-block,
	qemu-trivial, Cleber Rosa, kvm, Eduardo Habkost,
	Alex Bennée, Marcelo Tosatti, Stefan Hajnoczi, Fam Zheng

On 5/12/20 12:32 PM, Philippe Mathieu-Daudé wrote:
> Trivial Python3 fixes, again...
> 
> Since v3:
> - Fixed missing scripts/qemugdb/timers.py (kwolf)
> - Cover more scripts
> - Check for __main__ in few scripts
> 
> Since v2:
> - Remove patch updating MAINTAINERS
> 
> Since v1:
> - Added Alex Bennée A-b tags
> - Addressed John Snow review comments
>   - Use /usr/bin/env
>   - Do not modify os.path (dropped last patch)
> 
> Philippe Mathieu-Daudé (6):
>   scripts/qemugdb: Remove shebang header
>   scripts/qemu-gdb: Use Python 3 interpreter
>   scripts/qmp: Use Python 3 interpreter
>   scripts/kvm/vmxcap: Use Python 3 interpreter and add pseudo-main()
>   scripts/modules/module_block: Use Python 3 interpreter & add
>     pseudo-main
>   tests/migration/guestperf: Use Python 3 interpreter
> 
>  scripts/kvm/vmxcap                 |  7 ++++---
>  scripts/modules/module_block.py    | 31 +++++++++++++++---------------
>  scripts/qemu-gdb.py                |  4 ++--
>  scripts/qemugdb/__init__.py        |  3 +--
>  scripts/qemugdb/aio.py             |  3 +--
>  scripts/qemugdb/coroutine.py       |  3 +--
>  scripts/qemugdb/mtree.py           |  4 +---
>  scripts/qemugdb/tcg.py             |  1 -
>  scripts/qemugdb/timers.py          |  1 -
>  scripts/qmp/qom-get                |  2 +-
>  scripts/qmp/qom-list               |  2 +-
>  scripts/qmp/qom-set                |  2 +-
>  scripts/qmp/qom-tree               |  2 +-
>  tests/migration/guestperf-batch.py |  2 +-
>  tests/migration/guestperf-plot.py  |  2 +-
>  tests/migration/guestperf.py       |  2 +-
>  16 files changed, 33 insertions(+), 38 deletions(-)

Thanks, applied to my python-next tree:
https://gitlab.com/philmd/qemu/commits/python-next


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2020-05-29  9:40 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-12 10:32 [PATCH v4 0/6] scripts: More Python fixes Philippe Mathieu-Daudé
2020-05-12 10:32 ` [PATCH v4 1/6] scripts/qemugdb: Remove shebang header Philippe Mathieu-Daudé
2020-05-13 20:58   ` John Snow
2020-05-12 10:32 ` [PATCH v4 2/6] scripts/qemu-gdb: Use Python 3 interpreter Philippe Mathieu-Daudé
2020-05-13 20:58   ` John Snow
2020-05-12 10:32 ` [PATCH v4 3/6] scripts/qmp: " Philippe Mathieu-Daudé
2020-05-13 20:59   ` John Snow
2020-05-12 10:32 ` [PATCH v4 4/6] scripts/kvm/vmxcap: Use Python 3 interpreter and add pseudo-main() Philippe Mathieu-Daudé
2020-05-12 11:35   ` Paolo Bonzini
2020-05-13 21:00   ` John Snow
2020-05-12 10:32 ` [PATCH v4 5/6] scripts/modules/module_block: Use Python 3 interpreter & add pseudo-main Philippe Mathieu-Daudé
2020-05-13 21:04   ` John Snow
2020-05-12 10:32 ` [PATCH v4 6/6] tests/migration/guestperf: Use Python 3 interpreter Philippe Mathieu-Daudé
2020-05-13 21:08   ` John Snow
2020-05-12 11:16 ` [PATCH v4 0/6] scripts: More Python fixes Kevin Wolf
2020-05-29  9:40 ` Philippe Mathieu-Daudé

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).