qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v6 2/7] qemu.py: fix is_running() return before


From: Amador Pahim
Subject: Re: [Qemu-devel] [PATCH v6 2/7] qemu.py: fix is_running() return before first launch()
Date: Tue, 1 Aug 2017 14:56:55 +0200

On Tue, Aug 1, 2017 at 12:50 PM, Eduardo Habkost <address@hidden> wrote:
> On Tue, Aug 01, 2017 at 11:09:25AM +0100, Stefan Hajnoczi wrote:
>> On Mon, Jul 31, 2017 at 10:51:05AM +0200, 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 retunt False instead. This patch fixes that.
>>
>> s/retunt/return/
>>

Ack

>> >
>> > Signed-off-by: Amador Pahim <address@hidden>
>> > ---
>> >  scripts/qemu.py | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/scripts/qemu.py b/scripts/qemu.py
>> > index 2f1984c93c..77565eb092 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.poll() is None)
>> > +        return self._popen is not None and (self._popen.poll() is None)
>>
>> The parentheses are inconsistent:
>>
>>   return (self._popen is not None) and (self._popen.poll() is None)

Parentheses are not needed here. I can remove the other one, if you want.

>>
>> An alternative:
>>
>>   return bool(self._popen and self._popen.poll())
>
> is_running() should be True only if self._popen.poll() is None
> (and not if it's 0), so the "self._popen.poll() is None" part is
> necessary.

+1

>
>
> --
> Eduardo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]