From: John Snow <jsnow@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>,
qemu-devel@nongnu.org, "Cleber Rosa" <crosa@redhat.com>,
"Wainer dos Santos Moschetta" <wainersm@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
Eduardo Habkost <ehabkost@redhat.com>,
qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: Re: [PATCH v4 00/16] python: add mypy support to python/qemu
Date: Wed, 1 Jul 2020 13:18:47 -0400 [thread overview]
Message-ID: <37df2b7e-0f3d-0789-606a-7f077e28d974@redhat.com> (raw)
In-Reply-To: <1adf70db-e9d4-a5ab-d28b-f57956877956@redhat.com>
On 6/29/20 10:30 AM, John Snow wrote:
>
>
> On 6/29/20 4:26 AM, Philippe Mathieu-Daudé wrote:
>> +Cleber/Wainer.
>>
>> On 6/26/20 10:41 PM, John Snow wrote:
>>> Based-on: 20200626202350.11060-1-jsnow@redhat.com
>>>
>>> This series modifies the python/qemu library to comply with mypy --strict.
>>> This requires my "refactor shutdown" patch as a pre-requisite.
>>>
>>> v4:
>>> 001/16:[----] [--] 'python/qmp.py: Define common types'
>>> 002/16:[----] [--] 'iotests.py: use qemu.qmp type aliases'
>>> 003/16:[----] [--] 'python/qmp.py: re-absorb MonitorResponseError'
>>> 004/16:[----] [--] 'python/qmp.py: Do not return None from cmd_obj'
>>> 005/16:[----] [--] 'python/qmp.py: add casts to JSON deserialization'
>>> 006/16:[----] [--] 'python/qmp.py: add QMPProtocolError'
>>> 007/16:[----] [--] 'python/machine.py: Fix monitor address typing'
>>> 008/16:[----] [--] 'python/machine.py: reorder __init__'
>>> 009/16:[----] [--] 'python/machine.py: Don't modify state in _base_args()'
>>> 010/16:[----] [--] 'python/machine.py: Handle None events in events_wait'
>>> 011/16:[----] [--] 'python/machine.py: use qmp.command'
>>> 012/16:[0010] [FC] 'python/machine.py: Add _qmp access shim'
>>> 013/16:[----] [-C] 'python/machine.py: fix _popen access'
>>> 014/16:[----] [--] 'python/qemu: make 'args' style arguments immutable'
>>> 015/16:[----] [--] 'iotests.py: Adjust HMP kwargs typing'
>>> 016/16:[----] [-C] 'python/qemu: Add mypy type annotations'
>>>
>>> - Rebased on "refactor shutdown" v4
>>> - Fixed _qmp access for scripts that disable QMP
>>
>> See:
>>
>> https://travis-ci.org/github/philmd/qemu/jobs/702507625#L5439
>>
>> / # uname -a
>> Linux buildroot 4.5.0-2-4kc-malta #1 Debian 4.5.5-1 (2016-05-29) mips
>> GNU/Linux
>> / # reboot
>> / # reboot: Restarting system
>>>>> {'execute': 'quit'}
>> qemu received signal 9; command: "mips-softmmu/qemu-system-mips -display
>> none -vga none -chardev
>> socket,id=mon,path=/tmp/tmpcojsc5u3/qemu-14540-monitor.sock -mon
>> chardev=mon,mode=control -machine malta -chardev
>> socket,id=console,path=/tmp/tmpcojsc5u3/qemu-14540-console.sock,server,nowait
>> -serial chardev:console -kernel
>> /tmp/avocado_xgmck2k5/avocado_job_83wkzs2f/12-tests_acceptance_boot_linux_console.py_BootLinuxConsole.test_mips_malta_cpio/boot/vmlinux-4.5.0-2-4kc-malta
>> -initrd
>> /tmp/avocado_xgmck2k5/avocado_job_83wkzs2f/12-tests_acceptance_boot_linux_console.py_BootLinuxConsole.test_mips_malta_cpiorootfs.cpio
>> -append printk.time=0 console=ttyS0 console=tty rdinit=/sbin/init
>> noreboot -no-reboot"
>>
>> Reproduced traceback from:
>> /home/travis/build/philmd/qemu/build/tests/venv/lib/python3.6/site-packages/avocado/core/test.py:886
>> Traceback (most recent call last):
>> File
>> "/home/travis/build/philmd/qemu/build/tests/acceptance/avocado_qemu/__init__.py",
>> line 195, in tearDown
>> vm.shutdown()
>> File "/home/travis/build/philmd/qemu/python/qemu/machine.py", line
>> 457, in shutdown
>> self._do_shutdown(has_quit)
>> File "/home/travis/build/philmd/qemu/python/qemu/machine.py", line
>> 434, in _do_shutdown
>> self._soft_shutdown(has_quit, timeout)
>> File "/home/travis/build/philmd/qemu/python/qemu/machine.py", line
>> 414, in _soft_shutdown
>> self._qmp.cmd('quit')
>> File "/home/travis/build/philmd/qemu/python/qemu/qmp.py", line 271, in cmd
>> return self.cmd_obj(qmp_cmd)
>> File "/home/travis/build/philmd/qemu/python/qemu/qmp.py", line 249, in
>> cmd_obj
>> self.__sock.sendall(json.dumps(qmp_cmd).encode('utf-8'))
>> BrokenPipeError: [Errno 32] Broken pipe
>>
>
> Might be racing between QMP going away and Python not being aware that
> the process has closed yet. It's the only explanation I have left.
>
> I wish I could reproduce this, though. When I submit jobs to Travis I am
> not seeing these failures.
>
> I'll see what I can do, but at this point I'll not re-send the patch
> series until I can conclusively fix your build testing.
>
> --js
>
OK, this is a very big mea culpa. There are two problems.
1. I should catch ConnectionReset and not ConnectionResetError; one is a
catch-all for socket problems and the other is a very specific errno
that does not include BrokenPipeError.
2. Even if I do, it can still race, actually. QEMU might be in the
middle of shutting down, but has already lost the control channel.
Solving the second problem as the interface is currently designed is
hard. You can wait, but then if the wait failed, you need to re-raise
the control channel error instead of the wait failure. IOW, you need to
wait in order to learn if the control channel error is "important" or not.
So, the architecture of this is starting to look wrong; _soft_shutdown
should keep clarity of purpose. Either it was able to to a nice, soft
shutdown -- or it wasn't.
I'm starting to think that the real problem is that machine.py shouldn't
try to hide connection errors on shutdown at all if we expected to be
able to issue a quit command.
Changing my mind rapidly that the right thing to do is to actually just
fix the test to understand that it should not try to issue a shutdown
command, but instead issue a wait command; and removing the race
condition from machine.py by simply reporting *all* shutdown errors.
(If callers expect shutdown errors, they can -- and should -- catch
those exceptions as desired!)
--js
prev parent reply other threads:[~2020-07-01 17:21 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-26 20:41 [PATCH v4 00/16] python: add mypy support to python/qemu John Snow
2020-06-26 20:41 ` [PATCH v4 01/16] python/qmp.py: Define common types John Snow
2020-06-26 20:41 ` [PATCH v4 02/16] iotests.py: use qemu.qmp type aliases John Snow
2020-06-26 20:41 ` [PATCH v4 03/16] python/qmp.py: re-absorb MonitorResponseError John Snow
2020-06-26 20:41 ` [PATCH v4 04/16] python/qmp.py: Do not return None from cmd_obj John Snow
2020-06-26 20:41 ` [PATCH v4 05/16] python/qmp.py: add casts to JSON deserialization John Snow
2020-06-26 20:41 ` [PATCH v4 06/16] python/qmp.py: add QMPProtocolError John Snow
2020-06-26 20:41 ` [PATCH v4 07/16] python/machine.py: Fix monitor address typing John Snow
2020-06-26 20:41 ` [PATCH v4 08/16] python/machine.py: reorder __init__ John Snow
2020-06-26 20:41 ` [PATCH v4 09/16] python/machine.py: Don't modify state in _base_args() John Snow
2020-06-26 20:41 ` [PATCH v4 10/16] python/machine.py: Handle None events in events_wait John Snow
2020-06-26 20:41 ` [PATCH v4 11/16] python/machine.py: use qmp.command John Snow
2020-06-26 20:41 ` [PATCH v4 12/16] python/machine.py: Add _qmp access shim John Snow
2020-06-26 20:41 ` [PATCH v4 13/16] python/machine.py: fix _popen access John Snow
2020-06-26 20:41 ` [PATCH v4 14/16] python/qemu: make 'args' style arguments immutable John Snow
2020-06-26 20:41 ` [PATCH v4 15/16] iotests.py: Adjust HMP kwargs typing John Snow
2020-06-26 20:41 ` [PATCH v4 16/16] python/qemu: Add mypy type annotations John Snow
2020-06-29 8:26 ` [PATCH v4 00/16] python: add mypy support to python/qemu Philippe Mathieu-Daudé
2020-06-29 14:30 ` John Snow
2020-07-01 17:18 ` John Snow [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=37df2b7e-0f3d-0789-606a-7f077e28d974@redhat.com \
--to=jsnow@redhat.com \
--cc=crosa@redhat.com \
--cc=ehabkost@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=wainersm@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).