python: honour message limit when using pre-opened socket
PATCH 1/1 python: honour message limit when using pre-opened socket
The default message recv limit in asyncio is smaller than our needs, so when opening connections we override it. This was done when opening a connection using a socket address, but was missed when using a pre-opened socket file descriptor.
This latent bug was exposed when the QEMUMachine class was enhanced to use socketpair() when no socket address was passed by:
commit bd4c0ef409140bd1be393407c04005ac077d4574
Author: Marc-André Lureau <[email protected]>
Date: Wed Jan 11 12:01:01 2023 +0400
python/qemu/machine: use socketpair() for QMP by default
--- python/qemu/qmp/protocol.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
python/qemu/qmp/protocol.py +4 -1
@@ -307,7 +307,10 @@ async def open_with_socket(self, sock: socket.socket) -> None: :raise StateError: When the `Runstate` is not `IDLE`. """ - self._reader, self._writer = await asyncio.open_connection(sock=sock) + self._reader, self._writer = await asyncio.open_connection( + sock=sock, + limit=self._limit, + ) self._set_state(Runstate.CONNECTING) @upper_half
Signature · 1 line
2.39.2
Quoted 8 lines · Daniel P. Berrangé
The default message recv limit in asyncio is smaller than our needs, so when opening connections we override it. This was done when opening a connection using a socket address, but was missed when using a pre-opened socket file descriptor.
This latent bug was exposed when the QEMUMachine class was enhanced to use
socketpair()when no socket address was passed by:
Quoted 8 lines
commit
bd4c0ef409140bd1be393407c04005ac077d4574
Author: Marc-André Lureau <[email protected]>
Date: Wed Jan 11 12:01:01 2023 +0400python/qemu/machine: use
socketpair()for QMP by defaultSigned-off-by Daniel P. Berrangé <[email protected]>
thanks
Quoted 26 lines
--- python/qemu/qmp/protocol.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)python/qemu/qmp/protocol.py +4
-3@@ -307,7 +307,10 @@ async def open_with_socket(self, sock: socket.socket) -> None: :raise StateError: When the `Runstate` is not `IDLE`. """ - self._reader, self._writer = await asyncio.open_connection(sock=sock) + self._reader, self._writer = await asyncio.open_connection( + sock=sock, + limit=self._limit, + ) self._set_state(Runstate.CONNECTING) @upper_half --2.39.2
Quoted 8 lines · Daniel P. Berrangé
The default message recv limit in asyncio is smaller than our needs, so when opening connections we override it. This was done when opening a connection using a socket address, but was missed when using a pre-opened socket file descriptor.
This latent bug was exposed when the QEMUMachine class was enhanced to use
socketpair()when no socket address was passed by:
Quoted 7 lines
commit
bd4c0ef409140bd1be393407c04005ac077d4574
Author: Marc-André Lureau<[email protected]>
Date: Wed Jan 11 12:01:01 2023 +0400python/qemu/machine: use
socketpair()for QMP by defaultSigned-off-by Daniel P. Berrangé<[email protected]>
Thanks!
Signature · 2 lines
Best regards, Vladimir
Quoted 18 lines · Vladimir Sementsov-Ogievskiy
Quoted 8 lines · Daniel P. Berrangé
The default message recv limit in asyncio is smaller than our needs, so when opening connections we override it. This was done when opening a connection using a socket address, but was missed when using a pre-opened socket file descriptor.
This latent bug was exposed when the QEMUMachine class was enhanced to use
socketpair()when no socket address was passed by:Quoted 7 lines
commit
bd4c0ef409140bd1be393407c04005ac077d4574
Author: Marc-André Lureau<[email protected]>
Date: Wed Jan 11 12:01:01 2023 +0400python/qemu/machine: use
socketpair()for QMP by defaultSigned-off-by Daniel P. Berrangé<[email protected]>
Quoted 8 lines
Thanks!
--
Best regards,
Vladimir
Thanks x3. Will stage in both places.
--js
Quoted 23 lines · John Snow
Quoted 20 lines · Vladimir Sementsov-Ogievskiy
Quoted 8 lines · Daniel P. Berrangé
The default message recv limit in asyncio is smaller than our needs, so when opening connections we override it. This was done when opening a connection using a socket address, but was missed when using a pre-opened socket file descriptor.
This latent bug was exposed when the QEMUMachine class was enhanced to use
socketpair()when no socket address was passed by:Quoted 7 lines
commit
bd4c0ef409140bd1be393407c04005ac077d4574
Author: Marc-André Lureau<[email protected]>
Date: Wed Jan 11 12:01:01 2023 +0400python/qemu/machine: use
socketpair()for QMP by defaultSigned-off-by Daniel P. Berrangé<[email protected]>
Quoted 9 lines
Quoted 6 lines
Thanks!
--
Best regards,
VladimirThanks x3. Will stage in both places.
... Realizing I let the two codebases diverge a bit more than I had meant to allow, and the "open with socket" rewrite I made never got brought back to qemu.git, tch. I believe this bug only exists in qemu.git because of that. I need to backport my changes to qemu.git and ensure that there isn't a problem with the revised code as it exists in qemu.qmp.
I'll have to fix that *before* I drop qemu.qmp from the qemu.git repo, which I am hoping will be soon after Paolo takes the new Python patches that create a venv during configure time.
--js
Quoted 42 lines · John Snow
Quoted 23 lines · John Snow
Quoted 20 lines · Vladimir Sementsov-Ogievskiy
Quoted 8 lines · Daniel P. Berrangé
The default message recv limit in asyncio is smaller than our needs, so when opening connections we override it. This was done when opening a connection using a socket address, but was missed when using a pre-opened socket file descriptor.
This latent bug was exposed when the QEMUMachine class was enhanced to use
socketpair()when no socket address was passed by:Quoted 7 lines
commit
bd4c0ef409140bd1be393407c04005ac077d4574
Author: Marc-André Lureau<[email protected]>
Date: Wed Jan 11 12:01:01 2023 +0400python/qemu/machine: use
socketpair()for QMP by defaultSigned-off-by Daniel P. Berrangé<[email protected]>Quoted 9 lines
Quoted 6 lines
Thanks!
--
Best regards,
VladimirThanks x3. Will stage in both places.
... Realizing I let the two codebases diverge a bit more than I had meant to allow, and the "open with socket" rewrite I made never got brought back to qemu.git, tch. I believe this bug only exists in qemu.git because of that. I need to backport my changes to qemu.git and ensure that there isn't a problem with the revised code as it exists in qemu.qmp.
Quoted 5 lines
I'll have to fix that *before* I drop qemu.qmp from the qemu.git repo, which I am hoping will be soon after Paolo takes the new Python patches that create a venv during configure time.
--js
OK, I've just sent two series:
(1) A MR for python-qemu-qmp here, which backports a few misc fixes from qemu.git back over to python-qemu-qmp;
https://gitlab.com/qemu-project/python-qemu-qmp/-/merge_requests/23
This needs approval from at least one person. If you're interested in becoming a "reviewer" there, let me know and I'll add you if you aren't already.
(2) A patchset for qemu.git that backports the socket changes that went into python-qemu-qmp.
https://lists.gnu.org/archive/html/qemu-devel/2023-05/msg04285.html
This should fix the bug described here in this series, and is necessary to merge before I swap the in-tree qemu.git for a vendored qemu.qmp package.
Review welcomed, but any changes we need will need to happen on the python-qemu-qmp repo first.
Dropping the in-tree qemu.qmp package is going to happen after the large series Paolo just sent a PR for,
https://lists.gnu.org/archive/html/qemu-devel/2023-05/msg04330.html
which adds a configure-time venv to the QEMU build system.
Hoping to drop qemu.qmp *this dev cycle* and release v0.0.3 for qemu.qmp and vendor it to qemu.git as a .whl file.
Thanks,
--js