vmspawn: stop the QMP pump on fatal errors

The next commit drains the QMP client before resuming the VM, while
boot-time devices are being set up. Callbacks report fatal setup errors
by logging them and requesting the event loop to exit. As the loop
isn't running yet, the pump would not notice and continue. Stop it
instead, and return the error.

Signed-off-by: Martin Pitt <martin@amutable.com>
(cherry picked from commit 50063acf50dc81b194780758d3cd2c5fb0a709f4)
This commit is contained in:
Martin Pitt
2026-10-16 17:24:51 +01:00
committed by Luca Boccassi
parent e4c45cae51
commit fddede73c7
+15 -3
View File
@@ -2014,7 +2014,21 @@ static int vmspawn_qmp_bridge_drain(VmspawnQmpBridge *bridge) {
assert(bridge);
while (!qmp_client_is_idle(bridge->qmp)) {
sd_event *event = qmp_client_get_event(bridge->qmp);
for (;;) {
int code;
/* Callbacks of fatal boot-time errors request the event loop to exit, but that isn't running
* yet; stop draining then. */
if (sd_event_get_exit_code(event, &code) >= 0) {
if (code < 0)
return code;
return log_error_errno(SYNTHETIC_ERRNO(ECANCELED), "Exit requested during QMP device setup.");
}
if (qmp_client_is_idle(bridge->qmp))
return 0;
r = qmp_client_process(bridge->qmp);
if (r < 0)
return log_error_errno(r, "Failed to process QMP messages: %m");
@@ -2025,8 +2039,6 @@ static int vmspawn_qmp_bridge_drain(VmspawnQmpBridge *bridge) {
if (r < 0)
return log_error_errno(r, "Failed to wait for QMP messages: %m");
}
return 0;
}
int vmspawn_qmp_probe_features(VmspawnQmpBridge *bridge) {