mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
tools: console: cleanup console on errors in main thread
We only check now for virObjectWait failures in virshRunConsole but we'd better check and for other failures too. And we need to shutdown console on error in the main thread. Reviewed-by: Cole Robinson <crobinso@redhat.com> Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
This commit is contained in:
parent
98361cc3b9
commit
cbd9e3624d
@ -112,8 +112,10 @@ virConsoleShutdown(virConsolePtr con)
|
||||
virEventRemoveHandle(con->stdoutWatch);
|
||||
con->stdinWatch = -1;
|
||||
con->stdoutWatch = -1;
|
||||
if (!con->quit) {
|
||||
con->quit = true;
|
||||
virCondSignal(&con->cond);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -388,22 +390,35 @@ virshRunConsole(vshControl *ctl,
|
||||
if (virDomainOpenConsole(dom, dev_name, con->st, flags) < 0)
|
||||
goto cleanup;
|
||||
|
||||
con->stdinWatch = virEventAddHandle(STDIN_FILENO,
|
||||
virObjectRef(con);
|
||||
if ((con->stdinWatch = virEventAddHandle(STDIN_FILENO,
|
||||
VIR_EVENT_HANDLE_READABLE,
|
||||
virConsoleEventOnStdin,
|
||||
con,
|
||||
NULL);
|
||||
con->stdoutWatch = virEventAddHandle(STDOUT_FILENO,
|
||||
virObjectFreeCallback)) < 0) {
|
||||
virObjectUnref(con);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
virObjectRef(con);
|
||||
if ((con->stdoutWatch = virEventAddHandle(STDOUT_FILENO,
|
||||
0,
|
||||
virConsoleEventOnStdout,
|
||||
con,
|
||||
NULL);
|
||||
virObjectFreeCallback)) < 0) {
|
||||
virObjectUnref(con);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
virStreamEventAddCallback(con->st,
|
||||
virObjectRef(con);
|
||||
if (virStreamEventAddCallback(con->st,
|
||||
VIR_STREAM_EVENT_READABLE,
|
||||
virConsoleEventOnStream,
|
||||
con,
|
||||
NULL);
|
||||
virObjectFreeCallback) < 0) {
|
||||
virObjectUnref(con);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
while (!con->quit) {
|
||||
if (virCondWait(&con->cond, &con->parent.lock) < 0) {
|
||||
@ -415,6 +430,7 @@ virshRunConsole(vshControl *ctl,
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
virConsoleShutdown(con);
|
||||
virObjectUnlock(con);
|
||||
virObjectUnref(con);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user