mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 21:34:54 +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);
|
virEventRemoveHandle(con->stdoutWatch);
|
||||||
con->stdinWatch = -1;
|
con->stdinWatch = -1;
|
||||||
con->stdoutWatch = -1;
|
con->stdoutWatch = -1;
|
||||||
|
if (!con->quit) {
|
||||||
con->quit = true;
|
con->quit = true;
|
||||||
virCondSignal(&con->cond);
|
virCondSignal(&con->cond);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -388,22 +390,35 @@ virshRunConsole(vshControl *ctl,
|
|||||||
if (virDomainOpenConsole(dom, dev_name, con->st, flags) < 0)
|
if (virDomainOpenConsole(dom, dev_name, con->st, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
con->stdinWatch = virEventAddHandle(STDIN_FILENO,
|
virObjectRef(con);
|
||||||
|
if ((con->stdinWatch = virEventAddHandle(STDIN_FILENO,
|
||||||
VIR_EVENT_HANDLE_READABLE,
|
VIR_EVENT_HANDLE_READABLE,
|
||||||
virConsoleEventOnStdin,
|
virConsoleEventOnStdin,
|
||||||
con,
|
con,
|
||||||
NULL);
|
virObjectFreeCallback)) < 0) {
|
||||||
con->stdoutWatch = virEventAddHandle(STDOUT_FILENO,
|
virObjectUnref(con);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
virObjectRef(con);
|
||||||
|
if ((con->stdoutWatch = virEventAddHandle(STDOUT_FILENO,
|
||||||
0,
|
0,
|
||||||
virConsoleEventOnStdout,
|
virConsoleEventOnStdout,
|
||||||
con,
|
con,
|
||||||
NULL);
|
virObjectFreeCallback)) < 0) {
|
||||||
|
virObjectUnref(con);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
virStreamEventAddCallback(con->st,
|
virObjectRef(con);
|
||||||
|
if (virStreamEventAddCallback(con->st,
|
||||||
VIR_STREAM_EVENT_READABLE,
|
VIR_STREAM_EVENT_READABLE,
|
||||||
virConsoleEventOnStream,
|
virConsoleEventOnStream,
|
||||||
con,
|
con,
|
||||||
NULL);
|
virObjectFreeCallback) < 0) {
|
||||||
|
virObjectUnref(con);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
while (!con->quit) {
|
while (!con->quit) {
|
||||||
if (virCondWait(&con->cond, &con->parent.lock) < 0) {
|
if (virCondWait(&con->cond, &con->parent.lock) < 0) {
|
||||||
@ -415,6 +430,7 @@ virshRunConsole(vshControl *ctl,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
virConsoleShutdown(con);
|
||||||
virObjectUnlock(con);
|
virObjectUnlock(con);
|
||||||
virObjectUnref(con);
|
virObjectUnref(con);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user