Skip to contentSkip to conversation

tools: More Python 3 fixes (part 1 of N)

PATCH In review Andrew Cooper 4 participants 23 messages Mar 14, 2023 – Mar 16, 2023 Arm/actions semi architecture

lore
Share & tools
lore
#0 lore raw

cover tools: More Python 3 fixes (part 1 of N)

Despite previous statements to the contrary, Xen still does not support Python 3.

Various notes are on https://gitlab.com/xen-project/xen/-/issues/114

The following scripts are installed, and given a python3 shebang, but are not Py3 compatible:

xencov_split
xentrace_format
xencons
xenpvnetboot
verify-stream-v2
convert-legacy-stream

Most of these want converting, and should be reasonably easy, but I don't have time right now.

This series deals with xencons (which is a not-invented-here telnet), various bits of cleanup, and various fixes for shebangs.

The problematic remaining script is xenpvnetboot which, while looking reasonably useful and also not PV specific, depends on a 3rd party module but provides no dependency information at all.

Relatedly, and a critical/blocker for Xen 4.18. Python 3.12, which will be released ahead of the Xen 4.18 release, is deleteing distutils (recommending setuputils as the replacement), so someone is going to have to rework all our setup.py's to be compatible.

Andrew Cooper (7):
tools/python: Drop pylintrc
tools/misc: Drop xencons
tools: Delete trailing whitespace in python scripts tools/pygrub: Factor out common setup.py parts
tools: Use -s for python shebangs tools/python: Improve unit test handling tools/python: Drop shebangs from library files

 tools/Rules.mk                       |   2 +-
 tools/misc/Makefile                  |   2 -
 tools/misc/xencons                   |  92 --------
 tools/misc/xencov_split              |   1 -
 tools/pygrub/Makefile                |  11 +-
 tools/pygrub/src/ExtLinuxConf.py     |   2 +-
 tools/pygrub/src/GrubConf.py         |  30 +--
 tools/pygrub/src/fsimage/fsimage.c   |   8 +-
 tools/pygrub/src/pygrub              |  44 ++--
 tools/python/Makefile                |   4 +-
 tools/python/pylintrc                | 307 ---------------------------
 tools/python/xen/lowlevel/xc/xc.c    | 200 ++++++++---------
 tools/python/xen/lowlevel/xs/xs.c    |   4 +-
 tools/python/xen/migration/legacy.py |   1 -
 tools/python/xen/migration/libxc.py  |   1 -
 tools/python/xen/migration/libxl.py  |   1 -
 tools/python/xen/migration/public.py |   1 -
 tools/python/xen/migration/tests.py  |  15 +-
 tools/python/xen/migration/verify.py |   1 -
 tools/python/xen/migration/xl.py     |   1 -
 tools/python/xen/util.py             |   1 -
 tools/xenmon/xenmon.py               |  44 ++--
 22 files changed, 177 insertions(+), 596 deletions(-)
 delete mode 100755 tools/misc/xencons
 delete mode 100644 tools/python/pylintrc
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/7 tools/python: Drop pylintrc

This was added in 2004 in c/s b7d4a69f0ccb5 and has never been referenced since. Given the the commit message of simply "Added .", it was quite possibly a mistake in the first place.

---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Bernhard Kaindl <[email protected]>

---
 tools/python/pylintrc | 307 ------------------------------------------
 1 file changed, 307 deletions(-)
 delete mode 100644 tools/python/pylintrc
tools/python/pylintrc deleted +0 -307
deleted file mode 100644
index efc4b0b3b2dd..000000000000
@@ -1,307 +0,0 @@
-# lint Python modules using external checkers.                            
-#                                                                                
-#     This is the main checker controling the other ones and the reports         
-#     generation. It is itself both a raw checker and an astng checker in order  
-#     to:                                                                        
-#     * handle message activation / deactivation at the module level             
-#     * handle some basic but necessary stats'data (number of classes, methods...)
-#                                                                                 
-# This checker also defines the following reports:                                    
-#   * R0001: Total errors / warnings                                              
-#   * R0002: % errors / warnings by module                                        
-#   * R0003: Messages                                                             
-#   * R0004: Global evaluation                                                    
-# 
-[MASTER]
-# Add <file or directory> to the black list. It should be a base name, not a
-# path. You may set this option multiple times.
-ignore=CVS
-
-# Pickle collected data for later comparisons.
-persistent=yes
-
-# Set the cache size for astng objects.
-cache-size=500
-
-
-
-[REPORTS]
-# Tells wether to display a full report or only the messages
-reports=yes
-
-# Use HTML as output format instead of text
-html=no
-
-# Use a parseable text output format, so your favorite text editor will be able
-# to jump to the line corresponding to a message.
-parseable=no
-
-# Colorizes text output using ansi escape codes
-color=no
-
-# Put messages in a separate file for each module / package specified on the
-# command line instead of printing them on stdout. Reports (if any) will be
-# written in a file name "pylint_global.[txt|html]".
-files-output=no
-
-# Python expression which should return a note less than 10 (10 is the highest
-# note).You have access to the variables errors warning, statement which
-# respectivly contain the number of errors / warnings messages and the total
-# number of statements analyzed. This is used by the global evaluation report
-# (R0004).
-evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
-
-# Add a comment according to your evaluation note. This is used by the global
-# evaluation report (R0004).
-comment=no
-
-# Include message's id in output
-include-ids=yes
-
-
-
-# checks for                                                              
-#     * unused variables / imports                                               
-#     * undefined variables                                                      
-#     * redefinition of variable from builtins or from an outer scope            
-#     * use of variable before assigment                                         
-#     
-[VARIABLES]
-# Enable / disable this checker
-enable-variables=yes
-
-# Tells wether we should check for unused import in __init__ files.
-init-import=no
-
-# List of variable names used for dummy variables (i.e. not used).
-dummy-variables=_,_1,_2,_3,_4,_5,dummy
-
-
-
-# checks for :                                                            
-#     * doc strings                                                              
-#     * modules / classes / functions / methods / arguments / variables name     
-#     * number of arguments, local variables, branchs, returns and statements in
-# functions, methods                                                       
-#     * required module attributes                                             
-#     * dangerous default values as arguments                                    
-#     * redefinition of function / method / class                                
-#     * uses of the global statement                                             
-#                                                                                 
-# This checker also defines the following reports:                                    
-#   * R0101: Statistics by type                                                   
-# 
-[BASIC]
-# Enable / disable this checker
-enable-basic=yes
-
-# Required attributes for module, separated by a comma
-required-attributes=
-
-# Regular expression which should only match functions or classes name which do
-# not require a docstring
-no-docstring-rgx=.*
-
-# Minimal length for module / class / function / method / argument / variable
-# names
-min-name-length=1
-
-# Regular expression which should only match correct module names
-module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
-
-# Regular expression which should only match correct class names
-class-rgx=[A-Z_][a-zA-Z0-9]+$
-
-# Regular expression which should only match correct function names
-function-rgx=[a-z_][A-Za-z0-9_]*$
-
-# Regular expression which should only match correct method names
-method-rgx=[a-z_][A-Za-z0-9_]*$
-
-# Regular expression which should only match correct argument names
-argument-rgx=[a-z_][A-Za-z0-9_]*$
-
-# Regular expression which should only match correct variable names
-variable-rgx=[a-z_][A-Za-z0-9_]*$
-
-# Good variable names which should always be accepted, separated by a comma
-good-names=i,j,k,ex,Run,_
-
-# Bad variable names which should always be refused, separated by a comma
-bad-names=foo,bar,baz,toto,tutu,tata
-
-# List of builtins function names that should not be used, separated by a comma
-bad-functions=apply,input
-
-
-
-# checks for sign of poor/misdesign:                                      
-#     * number of methods, attributes, local variables...                        
-#     * size, complexity of functions, methods                                   
-#     
-[DESIGN]
-# Enable / disable this checker
-enable-design=yes
-
-# Maximum number of arguments for function / method
-max-args=15
-
-# Maximum number of locals for function / method body
-max-locals=15
-
-# Maximum number of return / yield for function / method body
-max-returns=6
-
-# Maximum number of branch for function / method body
-max-branchs=12
-
-# Maximum number of statements in function / method body
-max-statements=50
-
-# Maximum number of parents for a class (see R0901).
-max-parents=7
-
-# Maximum number of attributes for a class (see R0902).
-max-attributes=7
-
-# Minimum number of public methods for a class (see R0903).
-min-public-methods=2
-
-# Maximum number of public methods for a class (see R0904).
-max-public-methods=20
-
-
-
-# checks for :                                                            
-#     * methods without self as first argument                                   
-#     * overriden methods signature                                              
-#     * access only to existant members via self                                 
-#     * attributes not defined in the __init__ method                            
-#     * supported interfaces implementation                                      
-#     * unreachable code                                                         
-#     
-[CLASSES]
-# Enable / disable this checker
-enable-classes=yes
-
-# List of interface methods to ignore, separated by a comma. This is used for
-# instance to not check methods defines in Zope's Interface base class.
-ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by
-
-# Tells wether missing members accessed in mixin class should be ignored. A
-# mixin class is detected if its name ends with "mixin" (case insensitive).
-ignore-mixin-members=yes
-
-
-
-# checks for                                                              
-#     * external modules dependencies                                            
-#     * relative / wildcard imports                                                         
-#     * cyclic imports                                                           
-#     * uses of deprecated modules
-#                                                                                 
-# This checker also defines the following reports:                                    
-#   * R0401: External dependencies                                                
-#   * R0402: Modules dependencies graph                                           
-# 
-[IMPORTS]
-# Enable / disable this checker
-enable-imports=no
-
-# Deprecated modules which should not be used, separated by a comma
-deprecated-modules=regsub,string,TERMIOS,Bastion,rexec
-
-# Create a graph of every (i.e. internal and external) dependencies in the given
-# file (report R0402 must not be disabled)
-import-graph=
-
-# Create a graph of external dependencies in the given file (report R0402 must
-# not be disabled)
-ext-import-graph=
-
-# Create a graph of internal dependencies in the given file (report R0402 must
-# not be disabled)
-int-import-graph=
-
-
-
-# checks for                                                              
-#     * excepts without exception filter                                         
-#     * string exceptions                                                        
-#     
-[EXCEPTIONS]
-# Enable / disable this checker
-enable-exceptions=yes
-
-
-
-# checks for :                                                            
-#     * unauthorized constructions                                               
-#     * strict indentation                                                       
-#     * line length                                                              
-#     * use of <> instead of !=
-#     
-[FORMAT]
-# Enable / disable this checker
-enable-format=no
-
-# Maximum number of characters on a single line.
-max-line-length=80
-
-# Maximum number of lines in a module
-max-module-lines=1000
-
-# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 tab).
-indent-string='    '
-
-
-
-# does not check anything but gives some raw metrics :                    
-#     * total number of lines                                                    
-#     * total number of code lines                                               
-#     * total number of docstring lines                                          
-#     * total number of comments lines                                           
-#     * total number of empty lines                                              
-#                                                                                 
-# This checker also defines the following reports:                                    
-#   * R0701: Raw metrics                                                          
-# 
-[METRICS]
-# Enable / disable this checker
-enable-metrics=yes
-
-
-
-# checks for:                                                             
-#     * warning notes in the code like FIXME, XXX                                
-#     * PEP 263: source code with non ascii character but no encoding declaration
-#     
-[MISCELLANEOUS]
-# Enable / disable this checker
-enable-miscellaneous=yes
-
-# List of note tags to take in consideration, separated by a comma. Default to
-# FIXME, XXX, TODO
-notes=FIXME,XXX,TODO
-
-
-
-# checks for similarities and duplicated code. This computation may be
-#     memory / CPU intensive, so you should disable it if you experiments some
-#     problems.
-#                                                                                 
-# This checker also defines the following reports:                                    
-#   * R0801: Duplication                                                          
-# 
-[SIMILARITIES]
-# Enable / disable this checker
-enable-similarities=yes
-
-# Minimum lines number of a similarity.
-min-similarity-lines=4
-
-# Ignore comments when computing similarities.
-ignore-comments=yes
-
-
-
Signature · 1 line
2.30.2
Acked-by on v1 1/7
#2 lore raw

Re: [PATCH 1/7] tools/python: Drop pylintrc

Quoted 5 lines · Andrew Cooper

This was added in 2004 in c/s b7d4a69f0ccb5 and has never been referenced since. Given the the commit message of simply "Added .", it was quite possibly a mistake in the first place.

Well, "pylintrc" seems to be a config file to be used by pylint, but there's also no reference to it. So removing the file seems a good option.

Signature · 1 line
Anthony PERARD
Acked-by on v1 1/7
#3 lore raw

Re: [PATCH 1/7] tools/python: Drop pylintrc

In reply to Andrew Cooper
Quoted 5 lines · Andrew Cooper

This was added in 2004 in c/s b7d4a69f0ccb5 and has never been referenced since. Given the the commit message of simply "Added .", it was quite possibly a mistake in the first place.

Ideally, we would have a pylint integrated into CI, but given frequency of changes to that code, I don't think its worth it, so:

Quoted 326 lines

---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Bernhard Kaindl <[email protected]>

---
 tools/python/pylintrc | 307 ------------------------------------------
 1 file changed, 307 deletions(-)
 delete mode 100644 tools/python/pylintrc
tools/python/pylintrc deleted +0 -307
deleted file mode 100644
index efc4b0b3b2dd..000000000000
@@ -1,307 +0,0 @@
-# lint Python modules using external checkers.                            
-#                                                                                
-#     This is the main checker controling the other ones and the reports         
-#     generation. It is itself both a raw checker and an astng checker in order  
-#     to:                                                                        
-#     * handle message activation / deactivation at the module level             
-#     * handle some basic but necessary stats'data (number of classes, methods...)
-#                                                                                 
-# This checker also defines the following reports:                                    
-#   * R0001: Total errors / warnings                                              
-#   * R0002: % errors / warnings by module                                        
-#   * R0003: Messages                                                             
-#   * R0004: Global evaluation                                                    
-# 
-[MASTER]
-# Add <file or directory> to the black list. It should be a base name, not a
-# path. You may set this option multiple times.
-ignore=CVS
-
-# Pickle collected data for later comparisons.
-persistent=yes
-
-# Set the cache size for astng objects.
-cache-size=500
-
-
-
-[REPORTS]
-# Tells wether to display a full report or only the messages
-reports=yes
-
-# Use HTML as output format instead of text
-html=no
-
-# Use a parseable text output format, so your favorite text editor will be able
-# to jump to the line corresponding to a message.
-parseable=no
-
-# Colorizes text output using ansi escape codes
-color=no
-
-# Put messages in a separate file for each module / package specified on the
-# command line instead of printing them on stdout. Reports (if any) will be
-# written in a file name "pylint_global.[txt|html]".
-files-output=no
-
-# Python expression which should return a note less than 10 (10 is the highest
-# note).You have access to the variables errors warning, statement which
-# respectivly contain the number of errors / warnings messages and the total
-# number of statements analyzed. This is used by the global evaluation report
-# (R0004).
-evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
-
-# Add a comment according to your evaluation note. This is used by the global
-# evaluation report (R0004).
-comment=no
-
-# Include message's id in output
-include-ids=yes
-
-
-
-# checks for                                                              
-#     * unused variables / imports                                               
-#     * undefined variables                                                      
-#     * redefinition of variable from builtins or from an outer scope            
-#     * use of variable before assigment                                         
-#     
-[VARIABLES]
-# Enable / disable this checker
-enable-variables=yes
-
-# Tells wether we should check for unused import in __init__ files.
-init-import=no
-
-# List of variable names used for dummy variables (i.e. not used).
-dummy-variables=_,_1,_2,_3,_4,_5,dummy
-
-
-
-# checks for :                                                            
-#     * doc strings                                                              
-#     * modules / classes / functions / methods / arguments / variables name     
-#     * number of arguments, local variables, branchs, returns and statements in
-# functions, methods                                                       
-#     * required module attributes                                             
-#     * dangerous default values as arguments                                    
-#     * redefinition of function / method / class                                
-#     * uses of the global statement                                             
-#                                                                                 
-# This checker also defines the following reports:                                    
-#   * R0101: Statistics by type                                                   
-# 
-[BASIC]
-# Enable / disable this checker
-enable-basic=yes
-
-# Required attributes for module, separated by a comma
-required-attributes=
-
-# Regular expression which should only match functions or classes name which do
-# not require a docstring
-no-docstring-rgx=.*
-
-# Minimal length for module / class / function / method / argument / variable
-# names
-min-name-length=1
-
-# Regular expression which should only match correct module names
-module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
-
-# Regular expression which should only match correct class names
-class-rgx=[A-Z_][a-zA-Z0-9]+$
-
-# Regular expression which should only match correct function names
-function-rgx=[a-z_][A-Za-z0-9_]*$
-
-# Regular expression which should only match correct method names
-method-rgx=[a-z_][A-Za-z0-9_]*$
-
-# Regular expression which should only match correct argument names
-argument-rgx=[a-z_][A-Za-z0-9_]*$
-
-# Regular expression which should only match correct variable names
-variable-rgx=[a-z_][A-Za-z0-9_]*$
-
-# Good variable names which should always be accepted, separated by a comma
-good-names=i,j,k,ex,Run,_
-
-# Bad variable names which should always be refused, separated by a comma
-bad-names=foo,bar,baz,toto,tutu,tata
-
-# List of builtins function names that should not be used, separated by a comma
-bad-functions=apply,input
-
-
-
-# checks for sign of poor/misdesign:                                      
-#     * number of methods, attributes, local variables...                        
-#     * size, complexity of functions, methods                                   
-#     
-[DESIGN]
-# Enable / disable this checker
-enable-design=yes
-
-# Maximum number of arguments for function / method
-max-args=15
-
-# Maximum number of locals for function / method body
-max-locals=15
-
-# Maximum number of return / yield for function / method body
-max-returns=6
-
-# Maximum number of branch for function / method body
-max-branchs=12
-
-# Maximum number of statements in function / method body
-max-statements=50
-
-# Maximum number of parents for a class (see R0901).
-max-parents=7
-
-# Maximum number of attributes for a class (see R0902).
-max-attributes=7
-
-# Minimum number of public methods for a class (see R0903).
-min-public-methods=2
-
-# Maximum number of public methods for a class (see R0904).
-max-public-methods=20
-
-
-
-# checks for :                                                            
-#     * methods without self as first argument                                   
-#     * overriden methods signature                                              
-#     * access only to existant members via self                                 
-#     * attributes not defined in the __init__ method                            
-#     * supported interfaces implementation                                      
-#     * unreachable code                                                         
-#     
-[CLASSES]
-# Enable / disable this checker
-enable-classes=yes
-
-# List of interface methods to ignore, separated by a comma. This is used for
-# instance to not check methods defines in Zope's Interface base class.
-ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by
-
-# Tells wether missing members accessed in mixin class should be ignored. A
-# mixin class is detected if its name ends with "mixin" (case insensitive).
-ignore-mixin-members=yes
-
-
-
-# checks for                                                              
-#     * external modules dependencies                                            
-#     * relative / wildcard imports                                                         
-#     * cyclic imports                                                           
-#     * uses of deprecated modules
-#                                                                                 
-# This checker also defines the following reports:                                    
-#   * R0401: External dependencies                                                
-#   * R0402: Modules dependencies graph                                           
-# 
-[IMPORTS]
-# Enable / disable this checker
-enable-imports=no
-
-# Deprecated modules which should not be used, separated by a comma
-deprecated-modules=regsub,string,TERMIOS,Bastion,rexec
-
-# Create a graph of every (i.e. internal and external) dependencies in the given
-# file (report R0402 must not be disabled)
-import-graph=
-
-# Create a graph of external dependencies in the given file (report R0402 must
-# not be disabled)
-ext-import-graph=
-
-# Create a graph of internal dependencies in the given file (report R0402 must
-# not be disabled)
-int-import-graph=
-
-
-
-# checks for                                                              
-#     * excepts without exception filter                                         
-#     * string exceptions                                                        
-#     
-[EXCEPTIONS]
-# Enable / disable this checker
-enable-exceptions=yes
-
-
-
-# checks for :                                                            
-#     * unauthorized constructions                                               
-#     * strict indentation                                                       
-#     * line length                                                              
-#     * use of <> instead of !=
-#     
-[FORMAT]
-# Enable / disable this checker
-enable-format=no
-
-# Maximum number of characters on a single line.
-max-line-length=80
-
-# Maximum number of lines in a module
-max-module-lines=1000
-
-# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 tab).
-indent-string='    '
-
-
-
-# does not check anything but gives some raw metrics :                    
-#     * total number of lines                                                    
-#     * total number of code lines                                               
-#     * total number of docstring lines                                          
-#     * total number of comments lines                                           
-#     * total number of empty lines                                              
-#                                                                                 
-# This checker also defines the following reports:                                    
-#   * R0701: Raw metrics                                                          
-# 
-[METRICS]
-# Enable / disable this checker
-enable-metrics=yes
-
-
-
-# checks for:                                                             
-#     * warning notes in the code like FIXME, XXX                                
-#     * PEP 263: source code with non ascii character but no encoding declaration
-#     
-[MISCELLANEOUS]
-# Enable / disable this checker
-enable-miscellaneous=yes
-
-# List of note tags to take in consideration, separated by a comma. Default to
-# FIXME, XXX, TODO
-notes=FIXME,XXX,TODO
-
-
-
-# checks for similarities and duplicated code. This computation may be
-#     memory / CPU intensive, so you should disable it if you experiments some
-#     problems.
-#                                                                                 
-# This checker also defines the following reports:                                    
-#   * R0801: Duplication                                                          
-# 
-[SIMILARITIES]
-# Enable / disable this checker
-enable-similarities=yes
-
-# Minimum lines number of a similarity.
-min-similarity-lines=4
-
-# Ignore comments when computing similarities.
-ignore-comments=yes
-
-
-
Signature · 1 line
2.30.2
Signature · 3 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
#4 lore raw

PATCH 2/7 tools/misc: Drop xencons

In reply to Andrew Cooper

This is a python script which has it's shebang modified by be python3, but was never converted to be python3 compatible.

The most recent reference I can find to this script (which isn't incidental adjustments in the makefile) is from the Xen book, fileish 561e30b80402 which says

%% <snip> Alternatively, if the
%% Xen machine is connected to a serial-port server then we supply a %% dumb TCP terminal client, {\tt xencons}.

So this a not-invented-here version of telnet. Delete it.

---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Bernhard Kaindl <[email protected]>

---
 tools/misc/Makefile |  2 -
 tools/misc/xencons  | 92 ---------------------------------------------
 2 files changed, 94 deletions(-)
 delete mode 100755 tools/misc/xencons
tools/misc/Makefile +0 -2
index 1c6e1d6a0471..233a7948c050 100644
@@ -12,7 +12,6 @@ CFLAGS += $(CFLAGS_libxenstore)
 # Everything to be installed in regular bin/
 INSTALL_BIN-$(CONFIG_X86)      += xen-cpuid
 INSTALL_BIN-$(CONFIG_X86)      += xen-detect
-INSTALL_BIN                    += xencons
 INSTALL_BIN                    += xencov_split
 INSTALL_BIN += $(INSTALL_BIN-y)
 
@@ -44,7 +43,6 @@ INSTALL_PRIVBIN                += xenpvnetboot
 TARGETS_ALL := $(INSTALL_BIN) $(INSTALL_SBIN) $(INSTALL_PRIVBIN)
 
 # Everything which only needs copying to install
-TARGETS_COPY += xencons
 TARGETS_COPY += xencov_split
 TARGETS_COPY += xenpvnetboot
 
tools/misc/xencons deleted +0 -92

92 lines not on this page · raw message

Signature · 1 line
2.30.2
Acked-by on v1 2/7
#5 lore raw

Re: [PATCH 2/7] tools/misc: Drop xencons

Quoted 2 lines · Andrew Cooper

This is a python script which has it's shebang modified by be python3, but was never converted to be python3 compatible.

Not quite, that's the original shebang ;-)

Quoted 11 lines

The most recent reference I can find to this script (which isn't incidental adjustments in the makefile) is from the Xen book, fileish 561e30b80402 which says

%% <snip> Alternatively, if the
%% Xen machine is connected to a serial-port server then we supply a %% dumb TCP terminal client, {\tt xencons}.

So this a not-invented-here version of telnet. Delete it.

Thanks,

Signature · 1 line
Anthony PERARD
#6 lore raw

Re: [PATCH 2/7] tools/misc: Drop xencons

Quoted 4 lines · Anthony PERARD
Quoted 2 lines · Andrew Cooper

This is a python script which has it's shebang modified by be python3, but was never converted to be python3 compatible.

Not quite, that's the original shebang ;-)

What I meant was that INSTALL_PYTHON_PROG turns it into a python3 shebang.

I'll see if I can think of some slightly clearer wording.

Quoted 5 lines
Quoted 5 lines

The most recent reference I can find to this script (which isn't incidental adjustments in the makefile) is from the Xen book, fileish 561e30b80402 which says

Quoted 8 lines
Quoted 7 lines

%% <snip> Alternatively, if the
%% Xen machine is connected to a serial-port server then we supply a %% dumb TCP terminal client, {\tt xencons}.

So this a not-invented-here version of telnet. Delete it.

Thanks.

~Andrew

Acked-by on v1 2/7
#7 lore raw

Re: [PATCH 2/7] tools/misc: Drop xencons

In reply to Andrew Cooper
Quoted 7 lines · Andrew Cooper

This is a python script which has it's shebang modified by be python3, but was never converted to be python3 compatible.

The most recent reference I can find to this script (which isn't incidental adjustments in the makefile) is from the Xen book, fileish 561e30b80402 which says

Quoted 7 lines

%% <snip> Alternatively, if the
%% Xen machine is connected to a serial-port server then we supply a %% dumb TCP terminal client, {\tt xencons}.

So this a not-invented-here version of telnet. Delete it.

Not sure if necessary, but in any case:

Signature · 3 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
#8 lore raw

PATCH 3/7 tools: Delete trailing whitespace in python scripts

In reply to Andrew Cooper

No functional change.

---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Bernhard Kaindl <[email protected]>

---
 tools/misc/xencov_split            |   1 -
 tools/pygrub/src/ExtLinuxConf.py   |   2 +-
 tools/pygrub/src/GrubConf.py       |  30 ++---
 tools/pygrub/src/fsimage/fsimage.c |   8 +-
 tools/pygrub/src/pygrub            |  44 +++----
 tools/python/xen/lowlevel/xc/xc.c  | 200 ++++++++++++++---------------
 tools/python/xen/lowlevel/xs/xs.c  |   4 +-
 tools/xenmon/xenmon.py             |  44 +++----
 8 files changed, 166 insertions(+), 167 deletions(-)
tools/misc/xencov_split +0 -1
index 5771f6cfc285..e4f68ebb6eda 100755
@@ -94,4 +94,3 @@ if __name__ == "__main__":
         sys.exit(1)
     except KeyboardInterrupt:
         sys.exit(1)
-
tools/pygrub/src/ExtLinuxConf.py +1 -1
index 9fd635b9cf7a..4e990a9304b6 100644
@@ -207,7 +207,7 @@ class ExtLinuxConfigFile(object):
                  "f1": None,
                  "f2": None,
                  }
-        
+
 if __name__ == "__main__":
     if len(sys.argv) < 2:
         raise RuntimeError("Need a configuration file to read")
tools/pygrub/src/GrubConf.py +15 -15
index 73f1bbed2f54..580c9628ca64 100644
@@ -95,7 +95,7 @@ class _GrubImage(object):
         self.title = title.strip()
 
     def __repr__(self):
-        return ("title: %s\n" 
+        return ("title: %s\n"
                 "  root: %s\n"
                 "  kernel: %s\n"
                 "  args: %s\n"
@@ -140,7 +140,7 @@ class _GrubImage(object):
 class GrubImage(_GrubImage):
     def __init__(self, title, lines):
         _GrubImage.__init__(self, title, lines)
-    
+
     def set_from_line(self, line, replace = None):
         (com, arg) = grub_exact_split(line, 2)
 
@@ -265,7 +265,7 @@ class _GrubConfigFile(object):
 class GrubConfigFile(_GrubConfigFile):
     def __init__(self, fn = None):
         _GrubConfigFile.__init__(self,fn)
-        
+
     def new_image(self, title, lines):
         return GrubImage(title, lines)
 
@@ -297,7 +297,7 @@ class GrubConfigFile(_GrubConfigFile):
                 img = []
                 title = l[6:]
                 continue
-                
+
             if img is not None:
                 img.append(l)
                 continue
@@ -310,7 +310,7 @@ class GrubConfigFile(_GrubConfigFile):
                     logging.info("Ignored directive %s" %(com,))
             else:
                 logging.warning("Unknown directive %s" %(com,))
-                
+
         if img:
             self.add_image(GrubImage(title, img))
 
@@ -322,7 +322,7 @@ def grub2_handle_set(arg):
     com="set:" + com
     m = re.match("([\"\'])(.*)\\1", arg)
     if m is not None:
-        arg=m.group(2) 
+        arg=m.group(2)
     return (com,arg)
 
 class Grub2Image(_GrubImage):
@@ -334,7 +334,7 @@ class Grub2Image(_GrubImage):
 
         if com == "set":
             (com,arg) = grub2_handle_set(arg)
-            
+
         if com in self.commands:
             if self.commands[com] is not None:
                 setattr(self, self.commands[com], arg.strip())
@@ -351,7 +351,7 @@ class Grub2Image(_GrubImage):
         else:
             self.lines.pop(replace)
             self.lines.insert(replace, line)
-                
+
     commands = {'set:root': 'root',
                 'linux': 'kernel',
                 'linux16': 'kernel',
@@ -360,14 +360,14 @@ class Grub2Image(_GrubImage):
                 'echo': None,
                 'insmod': None,
                 'search': None}
-    
+
 class Grub2ConfigFile(_GrubConfigFile):
     def __init__(self, fn = None):
         _GrubConfigFile.__init__(self, fn)
-       
+
     def new_image(self, title, lines):
         return Grub2Image(title, lines)
- 
+
     def parse(self, buf = None):
         if buf is None:
             if self.filename is None:
@@ -431,10 +431,10 @@ class Grub2ConfigFile(_GrubConfigFile):
                 continue
 
             (com, arg) = grub_exact_split(l, 2)
-        
+
             if com == "set":
                 (com,arg) = grub2_handle_set(arg)
-                
+
             if com in self.commands:
                 if self.commands[com] is not None:
                     arg_strip = arg.strip()
@@ -448,7 +448,7 @@ class Grub2ConfigFile(_GrubConfigFile):
                 pass
             else:
                 logging.warning("Unknown directive %s" %(com,))
-            
+
         if img is not None:
             raise RuntimeError("syntax error: end of file with open menuentry(%d %s)" % (len(img),img))
 
@@ -466,7 +466,7 @@ class Grub2ConfigFile(_GrubConfigFile):
                 'if': None,
                 'fi': None,
                 }
-        
+
 if __name__ == "__main__":
     if len(sys.argv) < 3:
         raise RuntimeError('Need a grub version ("grub" or "grub2") and a grub.conf or grub.cfg to read')
tools/pygrub/src/fsimage/fsimage.c +4 -4
index 2ebbbe35df92..fdcfa1a3c040 100644
@@ -31,7 +31,7 @@ typedef struct fsimage_fs {
 	fsi_t *fs;
 } fsimage_fs_t;
 
-typedef struct fsimage_file { 
+typedef struct fsimage_file {
 	PyObject_HEAD
 	fsimage_fs_t *fs;
 	fsi_file_t *file;
@@ -47,7 +47,7 @@ fsimage_file_read(fsimage_file_t *file, PyObject *args, PyObject *kwargs)
 	ssize_t bytesread = 0;
 	PyObject * buffer;
 
-	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|iL", kwlist, 
+	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|iL", kwlist,
 	    &size, &offset))
 		return (NULL);
 
@@ -62,7 +62,7 @@ fsimage_file_read(fsimage_file_t *file, PyObject *args, PyObject *kwargs)
 
 	if (buffer == NULL)
 		return (NULL);
- 
+
 	while (1) {
 		int err;
 		void *buf =
@@ -255,7 +255,7 @@ fsimage_open(PyObject *o, PyObject *args, PyObject *kwargs)
 	uint64_t offset = 0;
 	fsimage_fs_t *fs;
 
-	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|Ls", kwlist, 
+	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|Ls", kwlist,
 	    &name, &offset, &options))
 		return (NULL);
 
tools/pygrub/src/pygrub +22 -22

169 lines not on this page · raw message

tools/python/xen/lowlevel/xc/xc.c +100 -100

620 lines not on this page · raw message

tools/python/xen/lowlevel/xs/xs.c +2 -2
index 3ba5a8b893d9..87f1187bb116 100644
@@ -1,4 +1,4 @@
-/* 
+/*
  * Python interface to the Xen Store Daemon.
  *
  * This library is free software; you can redistribute it and/or
@@ -859,7 +859,7 @@ static void remove_watch(XsHandle *self, PyObject *token)
  * Parse transaction and path arguments from the given args and kwds,
  * convert the given self value to an xs_handle, and return all three by
  * reference.
- * 
+ *
  * @return 1 on success, in which case *xh, *th, and *path are valid, or 0 on
  * failure.
  */
tools/xenmon/xenmon.py +22 -22

156 lines not on this page · raw message

Signature · 1 line
2.30.2
#11 lore raw

PATCH 4/7 tools/pygrub: Factor out common setup.py parts

In reply to Andrew Cooper

... to mirror the tools/python side in c/s 2b8314a3c354.

No functional change.

---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Bernhard Kaindl <[email protected]>

---
 tools/pygrub/Makefile | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
tools/pygrub/Makefile +6 -5
index 37b214621492..29ad0513212f 100644
@@ -6,19 +6,20 @@ PY_CFLAGS = $(CFLAGS) $(PY_NOOPT_CFLAGS)
 PY_LDFLAGS = $(SHLIB_LDFLAGS) $(APPEND_LDFLAGS)
 INSTALL_LOG = build/installed_files.txt
 
+setup.py = CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDSHARED="$(CC)" LDFLAGS="$(PY_LDFLAGS)" \
+           $(PYTHON) setup.py
+
 .PHONY: all
 all: build
 .PHONY: build
 build:
-	CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDSHARED="$(CC)" LDFLAGS="$(PY_LDFLAGS)" $(PYTHON) setup.py build
+	$(setup.py) build
 
 .PHONY: install
 install: all
 	$(INSTALL_DIR) $(DESTDIR)/$(bindir)
-	CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDSHARED="$(CC)" \
-		LDFLAGS="$(PY_LDFLAGS)" $(PYTHON) setup.py install \
-		--record $(INSTALL_LOG) $(PYTHON_PREFIX_ARG) \
-		 --root="$(DESTDIR)" --install-scripts=$(LIBEXEC_BIN) --force
+	$(setup.py) install --record $(INSTALL_LOG) $(PYTHON_PREFIX_ARG) \
+		--root="$(DESTDIR)" --install-scripts=$(LIBEXEC_BIN) --force
 	set -e; if [ $(bindir) != $(LIBEXEC_BIN) -a \
 	             "`readlink -f $(DESTDIR)/$(bindir)`" != \
 	             "`readlink -f $(LIBEXEC_BIN)`" ]; then \
Signature · 1 line
2.30.2
#13 lore raw

PATCH 5/7 tools: Use -s for python shebangs

In reply to Andrew Cooper

This is mandated by the Fedora packaging guidelines because it is a security vulnerability otherwise in suid scripts. It's a very good idea generally, because it prevents the users local python environment interfering from system packaged scripts.

---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Bernhard Kaindl <[email protected]>

---
 tools/Rules.mk        | 2 +-
 tools/pygrub/Makefile | 2 +-
 tools/python/Makefile | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
tools/Rules.mk +1 -1
index 6e135387bd7e..18cf83f5be83 100644
@@ -179,7 +179,7 @@ CFLAGS += $(CFLAGS-y)
 CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
 
 INSTALL_PYTHON_PROG = \
-	$(XEN_ROOT)/tools/python/install-wrap "$(PYTHON_PATH)" $(INSTALL_PROG)
+	$(XEN_ROOT)/tools/python/install-wrap "$(PYTHON_PATH) -s" $(INSTALL_PROG)
 
 %.opic: %.c
 	$(CC) $(CPPFLAGS) -DPIC $(CFLAGS) $(CFLAGS_$*.opic) -fPIC -c -o $@ $< $(APPEND_CFLAGS)
tools/pygrub/Makefile +1 -1
index 29ad0513212f..04b3995cc0f6 100644
@@ -7,7 +7,7 @@ PY_LDFLAGS = $(SHLIB_LDFLAGS) $(APPEND_LDFLAGS)
 INSTALL_LOG = build/installed_files.txt
 
 setup.py = CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDSHARED="$(CC)" LDFLAGS="$(PY_LDFLAGS)" \
-           $(PYTHON) setup.py
+           $(PYTHON) setup.py --executable="$(PYTHON_PATH) -s"
 
 .PHONY: all
 all: build
tools/python/Makefile +1 -1
index cc764236478a..511e7deae409 100644
@@ -12,7 +12,7 @@ setup.py = CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDSHARED="$(CC)" LDFLAGS="$(PY_LDFLA
            SHLIB_libxenctrl="$(SHLIB_libxenctrl)" \
            SHLIB_libxenguest="$(SHLIB_libxenguest)" \
            SHLIB_libxenstore="$(SHLIB_libxenstore)" \
-           $(PYTHON) setup.py
+           $(PYTHON) setup.py --executable="$(PYTHON_PATH) -s"
 
 .PHONY: build
 build:
Signature · 1 line
2.30.2
#14 lore raw

Re: [PATCH 5/7] tools: Use -s for python shebangs

tools/pygrub/Makefile PY_LDFLAGS = $(SHLIB_LDFLAGS) $(APPEND_LDFLAGS) · line 10

Quoted 10 lines · Andrew Cooper
tools/pygrub/Makefile +1 -1
index 29ad0513212f..04b3995cc0f6 100644
@@ -7,7 +7,7 @@ PY_LDFLAGS = $(SHLIB_LDFLAGS) $(APPEND_LDFLAGS)
 INSTALL_LOG = build/installed_files.txt
 
 setup.py = CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDSHARED="$(CC)" LDFLAGS="$(PY_LDFLAGS)" \
-           $(PYTHON) setup.py
+           $(PYTHON) setup.py --executable="$(PYTHON_PATH) -s"

/sigh

CI has gone a wall of red to this.  Apparently --executable is only known by setuputils, not distutils.

Which is a problem because it means the main pygrub executable won't get a corrected shebang, as it doesn't pass through install-wrap.

In the short term, I could fix that by moving the main pygrub binary out of setup.py and do it manually.  Thoughts?

~Andrew

#15 lore raw

Re: [PATCH 5/7] tools: Use -s for python shebangs

Quoted 14 lines · Andrew Cooper

tools/pygrub/Makefile PY_LDFLAGS = $(SHLIB_LDFLAGS) $(APPEND_LDFLAGS) · line 10

Quoted 10 lines · Andrew Cooper
tools/pygrub/Makefile +1 -1
index 29ad0513212f..04b3995cc0f6 100644
@@ -7,7 +7,7 @@ PY_LDFLAGS = $(SHLIB_LDFLAGS) $(APPEND_LDFLAGS)
 INSTALL_LOG = build/installed_files.txt
 
 setup.py = CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDSHARED="$(CC)" LDFLAGS="$(PY_LDFLAGS)" \
-           $(PYTHON) setup.py
+           $(PYTHON) setup.py --executable="$(PYTHON_PATH) -s"

/sigh

Quoted 8 lines

CI has gone a wall of red to this.  Apparently --executable is only known by setuputils, not distutils.

Which is a problem because it means the main pygrub executable won't get a corrected shebang, as it doesn't pass through install-wrap.

In the short term, I could fix that by moving the main pygrub binary out of setup.py and do it manually.  Thoughts?

Or do the fixing in "setup.py", https://stackoverflow.com/a/17099342 :-) But that probably more work that necessary.
Doing the binary installation in the Makefile sounds fine.

Thanks,

Signature · 1 line
Anthony PERARD
#16 lore raw

PATCH v2 5/7 tools: Use -s for python shebangs

In reply to Andrew Cooper

This is mandated by the Fedora packaging guidelines because it is a security vulnerability otherwise in suid scripts. While Xen doesn't have suid scripts, it's a very good idea generally, because it prevents the users local python environment interfering from system packaged scripts.

pygrub is the odd-script-out, being installed by distutils rather than manually with INSTALL_PYTHON_PROG. distutils has no nice way of editing the shebang, so arrange to use INSTALL_PYTHON_PROG on pygrub too.

---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Bernhard Kaindl <[email protected]>

v2:
* Remove accidental setuputils dependency.

---
 tools/Rules.mk        | 2 +-
 tools/pygrub/Makefile | 4 +++-
 tools/pygrub/setup.py | 1 -
 3 files changed, 4 insertions(+), 3 deletions(-)
tools/Rules.mk +1 -1
index 6e135387bd7e..18cf83f5be83 100644
@@ -179,7 +179,7 @@ CFLAGS += $(CFLAGS-y)
 CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
 
 INSTALL_PYTHON_PROG = \
-	$(XEN_ROOT)/tools/python/install-wrap "$(PYTHON_PATH)" $(INSTALL_PROG)
+	$(XEN_ROOT)/tools/python/install-wrap "$(PYTHON_PATH) -s" $(INSTALL_PROG)
 
 %.opic: %.c
 	$(CC) $(CPPFLAGS) -DPIC $(CFLAGS) $(CFLAGS_$*.opic) -fPIC -c -o $@ $< $(APPEND_CFLAGS)
tools/pygrub/Makefile +3 -1
index 29ad0513212f..4963bc89c6ed 100644
@@ -18,8 +18,10 @@ build:
 .PHONY: install
 install: all
 	$(INSTALL_DIR) $(DESTDIR)/$(bindir)
+	$(INSTALL_DIR) $(DESTDIR)/$(LIBEXEC_BIN)
 	$(setup.py) install --record $(INSTALL_LOG) $(PYTHON_PREFIX_ARG) \
-		--root="$(DESTDIR)" --install-scripts=$(LIBEXEC_BIN) --force
+		--root="$(DESTDIR)" --force
+	$(INSTALL_PYTHON_PROG) src/pygrub $(DESTDIR)/$(LIBEXEC_BIN)/pygrub
 	set -e; if [ $(bindir) != $(LIBEXEC_BIN) -a \
 	             "`readlink -f $(DESTDIR)/$(bindir)`" != \
 	             "`readlink -f $(LIBEXEC_BIN)`" ]; then \
tools/pygrub/setup.py +0 -1
index 0e4e3d02d372..502aa4df2dae 100644
@@ -23,7 +23,6 @@ setup(name='pygrub',
       author_email='[email protected]',
       license='GPL',
       package_dir={'grub': 'src', 'fsimage': 'src'},
-      scripts = ["src/pygrub"],
       packages=pkgs,
       ext_modules = [ xenfsimage ]
       )
Signature · 1 line
2.30.2
Acked-by on v2 5/7
#17 lore raw

Re: [PATCH v2 5/7] tools: Use -s for python shebangs

Quoted 10 lines · Andrew Cooper

This is mandated by the Fedora packaging guidelines because it is a security vulnerability otherwise in suid scripts. While Xen doesn't have suid scripts, it's a very good idea generally, because it prevents the users local python environment interfering from system packaged scripts.

pygrub is the odd-script-out, being installed by distutils rather than manually with INSTALL_PYTHON_PROG. distutils has no nice way of editing the shebang, so arrange to use INSTALL_PYTHON_PROG on pygrub too.

Quoted 8 lines

---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Bernhard Kaindl <[email protected]>

v2:
* Remove accidental setuputils dependency.

... and tools/python/setup.py doesn't install any scripts, so it isn't relevant there.

Quoted 50 lines
---
 tools/Rules.mk        | 2 +-
 tools/pygrub/Makefile | 4 +++-
 tools/pygrub/setup.py | 1 -
 3 files changed, 4 insertions(+), 3 deletions(-)
tools/Rules.mk +1 -1
index 6e135387bd7e..18cf83f5be83 100644
@@ -179,7 +179,7 @@ CFLAGS += $(CFLAGS-y)
 CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
 
 INSTALL_PYTHON_PROG = \
-	$(XEN_ROOT)/tools/python/install-wrap "$(PYTHON_PATH)" $(INSTALL_PROG)
+	$(XEN_ROOT)/tools/python/install-wrap "$(PYTHON_PATH) -s" $(INSTALL_PROG)
 
 %.opic: %.c
 	$(CC) $(CPPFLAGS) -DPIC $(CFLAGS) $(CFLAGS_$*.opic) -fPIC -c -o $@ $< $(APPEND_CFLAGS)
tools/pygrub/Makefile +3 -1
index 29ad0513212f..4963bc89c6ed 100644
@@ -18,8 +18,10 @@ build:
 .PHONY: install
 install: all
 	$(INSTALL_DIR) $(DESTDIR)/$(bindir)
+	$(INSTALL_DIR) $(DESTDIR)/$(LIBEXEC_BIN)
 	$(setup.py) install --record $(INSTALL_LOG) $(PYTHON_PREFIX_ARG) \
-		--root="$(DESTDIR)" --install-scripts=$(LIBEXEC_BIN) --force
+		--root="$(DESTDIR)" --force
+	$(INSTALL_PYTHON_PROG) src/pygrub $(DESTDIR)/$(LIBEXEC_BIN)/pygrub
 	set -e; if [ $(bindir) != $(LIBEXEC_BIN) -a \
 	             "`readlink -f $(DESTDIR)/$(bindir)`" != \
 	             "`readlink -f $(LIBEXEC_BIN)`" ]; then \
tools/pygrub/setup.py +0 -1
index 0e4e3d02d372..502aa4df2dae 100644
@@ -23,7 +23,6 @@ setup(name='pygrub',
       author_email='[email protected]',
       license='GPL',
       package_dir={'grub': 'src', 'fsimage': 'src'},
-      scripts = ["src/pygrub"],
       packages=pkgs,
       ext_modules = [ xenfsimage ]
       )
Signature · 1 line
2.30.2
Signature · 3 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
#18 lore raw

PATCH 6/7 tools/python: Improve unit test handling

In reply to Andrew Cooper

* Add X86_{CPUID,MSR}_POLICY_FORMAT checks which were missed previously.
* Drop test_suite(). It hasn't been necessary since the Py2.3 era.
* Drop the __main__ logic. This can't be used without manually adjusting the include path, and make test knows how to do the right thing.
* For make test, use -v to see which tests have been discovered and run.

---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Bernhard Kaindl <[email protected]>

---
 tools/python/Makefile               |  2 +-
 tools/python/xen/migration/tests.py | 14 ++------------
 2 files changed, 3 insertions(+), 13 deletions(-)
tools/python/Makefile +1 -1
index 511e7deae409..697299bf2802 100644
@@ -36,7 +36,7 @@ uninstall:
 
 .PHONY: test
 test:
-	LD_LIBRARY_PATH=$$(readlink -f ../libs/ctrl):$$(readlink -f ../xenstore) $(PYTHON) -m unittest discover
+	LD_LIBRARY_PATH=$$(readlink -f ../libs/ctrl):$$(readlink -f ../xenstore) $(PYTHON) -m unittest discover -v
 
 .PHONY: clean
 clean:
tools/python/xen/migration/tests.py +2 -12
index ff2768946bb5..f22e2c2b7cf0 100644
@@ -26,6 +26,8 @@ class TestLibxc(unittest.TestCase):
                          (libxc.X86_TSC_INFO_FORMAT, 24),
                          (libxc.HVM_PARAMS_ENTRY_FORMAT, 16),
                          (libxc.HVM_PARAMS_FORMAT, 8),
+                         (libxc.X86_CPUID_POLICY_FORMAT, 24),
+                         (libxc.X86_MSR_POLICY_FORMAT, 16),
                          ):
             self.assertEqual(calcsize(fmt), sz)
 
@@ -40,15 +42,3 @@ class TestLibxl(unittest.TestCase):
                          (libxl.EMULATOR_HEADER_FORMAT, 8),
                          ):
             self.assertEqual(calcsize(fmt), sz)
-
-
-def test_suite():
-    suite = unittest.TestSuite()
-
-    suite.addTest(unittest.makeSuite(TestLibxc))
-    suite.addTest(unittest.makeSuite(TestLibxl))
-
-    return suite
-
-if __name__ == "__main__":
-    unittest.main()
Signature · 1 line
2.30.2
Acked-by on v1 6/7
#19 lore raw

Re: [PATCH 6/7] tools/python: Improve unit test handling

Quoted 7 lines · Andrew Cooper

* Add X86_{CPUID,MSR}_POLICY_FORMAT checks which were missed previously.
* Drop test_suite(). It hasn't been necessary since the Py2.3 era.
* Drop the __main__ logic. This can't be used without manually adjusting the include path, and make test knows how to do the right thing.
* For make test, use -v to see which tests have been discovered and run.

Quoted 55 lines

---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Bernhard Kaindl <[email protected]>

---
 tools/python/Makefile               |  2 +-
 tools/python/xen/migration/tests.py | 14 ++------------
 2 files changed, 3 insertions(+), 13 deletions(-)
tools/python/Makefile +1 -1
index 511e7deae409..697299bf2802 100644
@@ -36,7 +36,7 @@ uninstall:
 
 .PHONY: test
 test:
-	LD_LIBRARY_PATH=$$(readlink -f ../libs/ctrl):$$(readlink -f ../xenstore) $(PYTHON) -m unittest discover
+	LD_LIBRARY_PATH=$$(readlink -f ../libs/ctrl):$$(readlink -f ../xenstore) $(PYTHON) -m unittest discover -v
 
 .PHONY: clean
 clean:
tools/python/xen/migration/tests.py +2 -12
index ff2768946bb5..f22e2c2b7cf0 100644
@@ -26,6 +26,8 @@ class TestLibxc(unittest.TestCase):
                          (libxc.X86_TSC_INFO_FORMAT, 24),
                          (libxc.HVM_PARAMS_ENTRY_FORMAT, 16),
                          (libxc.HVM_PARAMS_FORMAT, 8),
+                         (libxc.X86_CPUID_POLICY_FORMAT, 24),
+                         (libxc.X86_MSR_POLICY_FORMAT, 16),
                          ):
             self.assertEqual(calcsize(fmt), sz)
 
@@ -40,15 +42,3 @@ class TestLibxl(unittest.TestCase):
                          (libxl.EMULATOR_HEADER_FORMAT, 8),
                          ):
             self.assertEqual(calcsize(fmt), sz)
-
-
-def test_suite():
-    suite = unittest.TestSuite()
-
-    suite.addTest(unittest.makeSuite(TestLibxc))
-    suite.addTest(unittest.makeSuite(TestLibxl))
-
-    return suite
-
-if __name__ == "__main__":
-    unittest.main()
Signature · 1 line
2.30.2
Signature · 3 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
#20 lore raw

PATCH 7/7 tools/python: Drop shebangs from library files

In reply to Andrew Cooper

These aren't runable scripts, so shouldn't have shebangs.

---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Bernhard Kaindl <[email protected]>

---
 tools/python/xen/migration/legacy.py | 1 -
 tools/python/xen/migration/libxc.py  | 1 -
 tools/python/xen/migration/libxl.py  | 1 -
 tools/python/xen/migration/public.py | 1 -
 tools/python/xen/migration/tests.py  | 1 -
 tools/python/xen/migration/verify.py | 1 -
 tools/python/xen/migration/xl.py     | 1 -
 tools/python/xen/util.py             | 1 -
 8 files changed, 8 deletions(-)
tools/python/xen/migration/legacy.py +0 -1
index 6456d6157ce3..e196ca876095 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
tools/python/xen/migration/libxc.py +0 -1
index 9881f5ced4ea..e52e632cb106 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
tools/python/xen/migration/libxl.py +0 -1
index 5c4d4fe0631b..5dcb50fe0207 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
tools/python/xen/migration/public.py +0 -1
index fab2f84587b7..23183ef67db8 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
tools/python/xen/migration/tests.py +0 -1
index f22e2c2b7cf0..fcf94b0bb264 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
tools/python/xen/migration/verify.py +0 -1
index 1e38f4a3c01e..b847c4bd220f 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
tools/python/xen/migration/xl.py +0 -1
index 978e744dfd95..139d496654df 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
tools/python/xen/util.py +0 -1
index a11358eefa13..47ceb5bd21fe 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 import os
Signature · 1 line
2.30.2
Acked-by on v1 7/7
#21 lore raw

Re: [PATCH 7/7] tools/python: Drop shebangs from library files

Quoted 3 lines · Andrew Cooper

These aren't runable scripts, so shouldn't have shebangs.

Quoted 91 lines

---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Bernhard Kaindl <[email protected]>

---
 tools/python/xen/migration/legacy.py | 1 -
 tools/python/xen/migration/libxc.py  | 1 -
 tools/python/xen/migration/libxl.py  | 1 -
 tools/python/xen/migration/public.py | 1 -
 tools/python/xen/migration/tests.py  | 1 -
 tools/python/xen/migration/verify.py | 1 -
 tools/python/xen/migration/xl.py     | 1 -
 tools/python/xen/util.py             | 1 -
 8 files changed, 8 deletions(-)
tools/python/xen/migration/legacy.py +0 -1
index 6456d6157ce3..e196ca876095 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
tools/python/xen/migration/libxc.py +0 -1
index 9881f5ced4ea..e52e632cb106 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
tools/python/xen/migration/libxl.py +0 -1
index 5c4d4fe0631b..5dcb50fe0207 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
tools/python/xen/migration/public.py +0 -1
index fab2f84587b7..23183ef67db8 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
tools/python/xen/migration/tests.py +0 -1
index f22e2c2b7cf0..fcf94b0bb264 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
tools/python/xen/migration/verify.py +0 -1
index 1e38f4a3c01e..b847c4bd220f 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
tools/python/xen/migration/xl.py +0 -1
index 978e744dfd95..139d496654df 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
tools/python/xen/util.py +0 -1
index a11358eefa13..47ceb5bd21fe 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 import os
Signature · 1 line
2.30.2
Signature · 3 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
#22 lore raw
In reply to Andrew Cooper

Hi Andrew,

Quoted 8 lines

-----Original Message-----
From: Andrew Cooper <[email protected]>
Subject: [PATCH 0/7] tools: More Python 3 fixes (part 1 of N)

Relatedly, and a critical/blocker for Xen 4.18. Python 3.12, which will be released ahead of the Xen 4.18 release, is deleteing distutils (recommending setuputils as the replacement), so someone is going to have to rework all our setup.py's to be compatible.

Thanks for noting this, I've taken a note of this issue in my 4.18 release blocker list.

Kind regards,
Henry