[Qemu-devel] [PATCH v8 01/13] qemu.py: fix is_running() return before first launch()

Amador Pahim posted 13 patches 8 years, 2 months ago
There is a newer version of this series
[Qemu-devel] [PATCH v8 01/13] qemu.py: fix is_running() return before first launch()
Posted by Amador Pahim 8 years, 2 months ago
is_running() returns None when called before the first time we
call launch():

    >>> import qemu
    >>> vm = qemu.QEMUMachine('qemu-system-x86_64')
    >>> vm.is_running()
    >>>

It should return False instead. This patch fixes that.

For consistence, this patch removes the parenthesis from the
second clause as it's not really needed.

Signed-off-by: Amador Pahim <apahim@redhat.com>
---
 scripts/qemu.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/qemu.py b/scripts/qemu.py
index 880e3e8219..0ae5d39414 100644
--- a/scripts/qemu.py
+++ b/scripts/qemu.py
@@ -86,7 +86,7 @@ class QEMUMachine(object):
             raise
 
     def is_running(self):
-        return self._popen and (self._popen.returncode is None)
+        return self._popen is not None and self._popen.returncode is None
 
     def exitcode(self):
         if self._popen is None:
-- 
2.13.5


Re: [Qemu-devel] [PATCH v8 01/13] qemu.py: fix is_running() return before first launch()
Posted by Fam Zheng 8 years, 2 months ago
On Fri, 09/01 13:28, Amador Pahim wrote:
> is_running() returns None when called before the first time we
> call launch():
> 
>     >>> import qemu
>     >>> vm = qemu.QEMUMachine('qemu-system-x86_64')
>     >>> vm.is_running()
>     >>>
> 
> It should return False instead. This patch fixes that.
> 
> For consistence, this patch removes the parenthesis from the
> second clause as it's not really needed.
> 
> Signed-off-by: Amador Pahim <apahim@redhat.com>

Reviewed-by: Fam Zheng <famz@redhat.com>