-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
socket: fixing possible mixed up response with events #210
Open
rouming
wants to merge
1
commit into
digitalocean:master
Choose a base branch
from
rouming:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Patch drains possible events on qmp socket until true "qmp_capabilities" response is received. This targets a nasty and rare problem in "Connect(), Run()" sequence, when asynchronous QEMU "event" just after the "qmp_capabilities" request is accepted as response and further any QMP request gets completed with response from the preceding "qmp_capabilities" response. The following QMP protocol sequence is possible: 1 read {"QMP": {"version": {"qemu": {"micro": 0, "minor": 1, "major": 5}, ...}" 2 write {"execute":"qmp_capabilities"} 3 read {"timestamp": {"seconds": xxx, "microseconds": xxx}, "event": "..."} 4 read {"return": {}} the 3. is unexpected by the current Connect() implementation and "event" is considered as a proper response on "qmp_capabilities", in other turn 4. is read in the go.mos.listen() and immediately pushed to the stream channel, so any further QMP command (Run() call) will be immediately completed by an empty response from line 4. The described problem of unexpected empty response line was observed on this code qmp.SocketMonitor sequence: Connect() Run('{"execute":"query-status"}') <<< Returns empty response Disconnect() The problem is very rare and was observed ~5 times on different machines over a fairly long period of time (several months), which corresponds to nature of the described rare protocol race. The current patch was tested on modified QEMU, where an aritifical sleep() was introduced in the qmp_marshal_qmp_capabilities() call just right after the qmp_qmp_capabilities() was invoked, so all further events can be accepted by the QMP socket: --- qapi/qapi-commands-control.c 2023-11-08 08:55:16.209007741 +0100 +++ qapi/qapi-commands-control.c.orig 2023-11-08 08:55:13.929005997 +0100 @@ -42,10 +42,6 @@ qmp_qmp_capabilities(arg.has_enable, arg.enable, &err); + printf(">>> BEFORE SLEEP 10\n"); + sleep(10); + printf(">>> AFTER SLEEP 10\n"); + error_propagate(errp, err); out: Any QMP event can be freely received by the QMP client, while the execution flow of the qmp_marshal_qmp_capabilities() was interrupted or scheduled out. The fix of the described is simple: read from the QMP socket until response is received and drop all possible events. Signed-off-by: Roman Penyaev <[email protected]>
rouming
added a commit
to rouming/eve
that referenced
this pull request
Nov 8, 2023
QEMU status is very crucial to EVE and any error or unexpected status leads to QEMU process is being stopped. There is an issue in the 3rd QMP library: digitalocean/go-qemu#210 And in order to be on a safe side and avoid these kind of problems in the future repeat status qeury several times. Signed-off-by: Roman Penyaev <[email protected]>
rouming
added a commit
to rouming/eve
that referenced
this pull request
Nov 8, 2023
QEMU status is very crucial to EVE and any error or unexpected status leads to QEMU process is being stopped. There is an issue in the 3rd QMP library: digitalocean/go-qemu#210 And in order to be on a safe side and avoid these kind of problems in the future repeat status qeury several times. Signed-off-by: Roman Penyaev <[email protected]>
rouming
added a commit
to rouming/eve
that referenced
this pull request
Nov 8, 2023
QEMU status is very crucial to EVE and any error or unexpected status leads to QEMU process is being stopped. There is an issue in the 3rd QMP library: digitalocean/go-qemu#210 And in order to be on a safe side and avoid these kind of problems in the future repeat status qeury several times. Signed-off-by: Roman Penyaev <[email protected]>
rouming
added a commit
to rouming/eve
that referenced
this pull request
Nov 8, 2023
QEMU status is very crucial to EVE and any error or unexpected status leads to QEMU process is being stopped. There is an issue in the 3rd QMP library: digitalocean/go-qemu#210 And in order to be on a safe side and avoid these kind of problems in the future repeat status qeury several times. Signed-off-by: Roman Penyaev <[email protected]>
rouming
added a commit
to rouming/eve
that referenced
this pull request
Nov 9, 2023
QEMU status is very crucial to EVE and any error or unexpected status leads to QEMU process is being stopped. There is an issue in the 3rd QMP library: digitalocean/go-qemu#210 And in order to be on a safe side and avoid these kind of problems in the future repeat status qeury several times. Signed-off-by: Roman Penyaev <[email protected]>
rouming
added a commit
to rouming/eve
that referenced
this pull request
Nov 9, 2023
QEMU status is very crucial to EVE and any error or unexpected status leads to QEMU process is being stopped. There is an issue in the 3rd QMP library: digitalocean/go-qemu#210 And in order to be on a safe side and avoid these kind of problems in the future repeat status qeury several times. Signed-off-by: Roman Penyaev <[email protected]>
rouming
added a commit
to rouming/eve
that referenced
this pull request
Nov 9, 2023
QEMU status is very crucial to EVE and any error or unexpected status leads to QEMU process is being stopped. There is an issue in the 3rd QMP library: digitalocean/go-qemu#210 And in order to be on a safe side and avoid these kind of problems in the future repeat status qeury several times. Signed-off-by: Roman Penyaev <[email protected]>
rouming
added a commit
to rouming/eve
that referenced
this pull request
Nov 9, 2023
QEMU status is very crucial to EVE and any error or unexpected status leads to QEMU process is being stopped. There is an issue in the 3rd QMP library: digitalocean/go-qemu#210 And in order to be on a safe side and avoid these kind of problems in the future repeat status qeury several times. Signed-off-by: Roman Penyaev <[email protected]>
rouming
added a commit
to rouming/eve
that referenced
this pull request
Nov 9, 2023
QEMU status is very crucial to EVE and any error or unexpected status leads to QEMU process is being stopped. There is an issue in the 3rd QMP library: digitalocean/go-qemu#210 And in order to be on a safe side and avoid these kind of problems in the future repeat status qeury several times. Signed-off-by: Roman Penyaev <[email protected]>
eriknordmark
pushed a commit
to lf-edge/eve
that referenced
this pull request
Nov 10, 2023
QEMU status is very crucial to EVE and any error or unexpected status leads to QEMU process is being stopped. There is an issue in the 3rd QMP library: digitalocean/go-qemu#210 And in order to be on a safe side and avoid these kind of problems in the future repeat status qeury several times. Signed-off-by: Roman Penyaev <[email protected]>
eriknordmark
pushed a commit
to lf-edge/eve
that referenced
this pull request
Nov 12, 2023
QEMU status is very crucial to EVE and any error or unexpected status leads to QEMU process is being stopped. There is an issue in the 3rd QMP library: digitalocean/go-qemu#210 And in order to be on a safe side and avoid these kind of problems in the future repeat status qeury several times. Signed-off-by: Roman Penyaev <[email protected]>
eriknordmark
pushed a commit
to lf-edge/eve
that referenced
this pull request
Nov 12, 2023
QEMU status is very crucial to EVE and any error or unexpected status leads to QEMU process is being stopped. There is an issue in the 3rd QMP library: digitalocean/go-qemu#210 And in order to be on a safe side and avoid these kind of problems in the future repeat status qeury several times. Signed-off-by: Roman Penyaev <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Patch drains possible events on qmp socket until true "qmp_capabilities" response is received.
This targets a nasty and rare problem in "Connect(), Run()" sequence, when asynchronous QEMU "event" just after the "qmp_capabilities" request is accepted as response and further any QMP request gets completed with response from the preceding "qmp_capabilities" response.
The following QMP protocol sequence is possible:
1 read {"QMP": {"version": {"qemu": {"micro": 0, "minor": 1, "major": 5}, ...}"
2 write {"execute":"qmp_capabilities"}
3 read {"timestamp": {"seconds": xxx, "microseconds": xxx}, "event": "any"}
4 read {"return": {}}
the 3. is unexpected by the current Connect() implementation and "event" is considered as a proper response on "qmp_capabilities", in other turn 4. is read in the go.mos.listen() and immediately pushed to the stream channel, so any further QMP command (Run() call) will be immediately completed by an empty response from line 4.
The described problem of unexpected empty response line was observed on this code qmp.SocketMonitor sequence:
Connect()
Run('{"execute":"query-status"}') <<< Returns empty response
Disconnect()
The problem is very rare and was observed ~5 times on different machines over a fairly long period of time (several months), which corresponds to nature of the described rare protocol race.
The current patch was tested on modified QEMU, where an aritifical sleep() was introduced in the qmp_marshal_qmp_capabilities() call just right after the qmp_qmp_capabilities() was invoked, so all further events can be accepted by the QMP socket:
Any QMP event can be freely received by the QMP client, while the execution flow of the qmp_marshal_qmp_capabilities() was interrupted or scheduled out.
The fix of the described is simple: read from the QMP socket until response is received and drop all possible events.