Skip to content

Commit

Permalink
vmside: fix waiting for gui-daemon
Browse files Browse the repository at this point in the history
libvchan_is_open() on server side before client got connected returns
VCHAN_WAITING (2), so check for this value instead of 0. Fortunately,
libvchan_read called later do wait for client connection if needed, so
it was working by a coincidence.

Also, don't try to reconnect when that initial waiting (or one of first
vchan reads/writes). Reconnection logic assume that X server is already
running, and generally gui-agent is fully initialized already, which
isn't true in such a case. Theoretically this could be handled by
resuming/restarting initialization procedure, but such a change is too
big at this stage of Qubes 4.0 development.

(cherry picked from commit 063e14f)
  • Loading branch information
marmarek committed Feb 10, 2018
1 parent 93efd48 commit a507a0b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions gui-agent/vmside.c
Original file line number Diff line number Diff line change
Expand Up @@ -1924,11 +1924,16 @@ void handle_guid_disconnect()
Ghandles *g = ghandles_for_vchan_reinitialize;
struct msg_xconf xconf;

if (!ghandles_for_vchan_reinitialize) {
fprintf(stderr, "gui-daemon disconnected before fully initialized, "
"cannot reconnect, exiting!\n");
exit(1);
}
libvchan_close(g->vchan);
wait_for_possible_dispvm_resume();
g->vchan = libvchan_server_init(0, 6000, 4096, 4096);
/* wait for gui daemon */
while (!libvchan_is_open(g->vchan))
while (libvchan_is_open(g->vchan) == VCHAN_WAITING)
libvchan_wait(g->vchan);
send_protocol_version(g->vchan);
/* discard */
Expand Down Expand Up @@ -1999,7 +2004,7 @@ int main(int argc, char **argv)
exit(1);
}
/* wait for gui daemon */
while (!libvchan_is_open(g.vchan))
while (libvchan_is_open(g.vchan) == VCHAN_WAITING)
libvchan_wait(g.vchan);
saved_argv = argv;
vchan_register_at_eof(handle_guid_disconnect);
Expand Down

0 comments on commit a507a0b

Please sign in to comment.