[elbe-devel] [PATCH] kvm: avoid unboundlocalerror

John Ogness john.ogness at linutronix.de
Fri Jul 20 13:01:11 CEST 2018


On 2018-07-12, Manuel Traut <manut at linutronix.de> wrote:
> /usr/bin/kvm: 2: exec: qemu-system-x86_64: not found
> Traceback (most recent call last):
>   File "./elbe", line 52, in <module>
>     mod = __import__(modname)
>   File "/home/elbe/elbepack/commands/initvm.py", line 13, in <module>
>     from elbepack.initvmaction import InitVMAction, InitVMError
>   File "/home/elbe/elbepack/initvmaction.py", line 18, in <module>
>     from elbepack.elbexml import ElbeXML, ValidationError, ValidationMode
>   File "/home/elbe/elbepack/elbexml.py", line 13, in <module>
>     from elbepack.xmldefaults import ElbeDefaults
>   File "/home/elbe/elbepack/xmldefaults.py", line 123, in <module>
>     "interpreter": find_kvm_exe()[0],
>   File "/home/elbe/elbepack/kvm.py", line 34, in find_kvm_exe
>     return fname, version
> UnboundLocalError: local variable 'version' referenced before assignment
> WARNING: exit code 1 from a shell command.
> DEBUG: Python function do_compile finished
>
> Signed-off-by: Manuel Traut <manut at linutronix.de>
> ---
>  elbepack/kvm.py | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/elbepack/kvm.py b/elbepack/kvm.py
> index 2b67d5c5..b236ff39 100644
> --- a/elbepack/kvm.py
> +++ b/elbepack/kvm.py
> @@ -17,6 +17,7 @@ kvm_exe_list = [
>  
>  
>  def find_kvm_exe():
> +    version = ""

Since elbepack/init/Makefile.mako parses the interpreterversion, it
would probably be better to set a default value that matches the other
defaults.

       version = "0.0.0"

>      for fname in kvm_exe_list:
>          if os.path.isfile(fname) and os.access(fname, os.X_OK):
>              # determine kvm version



More information about the elbe-devel mailing list