mirror of https://gitee.com/openkylin/libvirt.git
tools: console: Relax stream EOF handling
Regular VM shutdown triggers the error for existing session of virsh
console and it returns with non-zero exit code:
error: internal error: console stream EOF
The message and status code are misleading because there's no real
error. virStreamRecv returns 0 correctly when EOF is reached.
Existing implementations of esx, fd, and remote streams behave the same
for virStreamFinish and virStreamAbort: they close the stream. So, we
can continue to use virStreamAbort to handle EOF and errors from
virStreamRecv but additonally we can report error if virStreamAbort
fails.
Fixes: 29f2b5248c
("tools: console: pass stream/fd errors to user")
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
f6d6086dbf
commit
277c8c4c9b
|
@ -106,7 +106,9 @@ virConsoleShutdown(virConsolePtr con)
|
||||||
|
|
||||||
if (con->st) {
|
if (con->st) {
|
||||||
virStreamEventRemoveCallback(con->st);
|
virStreamEventRemoveCallback(con->st);
|
||||||
virStreamAbort(con->st);
|
if (virStreamAbort(con->st) < 0)
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
_("cannot terminate console stream"));
|
||||||
virStreamFree(con->st);
|
virStreamFree(con->st);
|
||||||
con->st = NULL;
|
con->st = NULL;
|
||||||
}
|
}
|
||||||
|
@ -172,10 +174,6 @@ virConsoleEventOnStream(virStreamPtr st,
|
||||||
if (got == -2)
|
if (got == -2)
|
||||||
goto cleanup; /* blocking */
|
goto cleanup; /* blocking */
|
||||||
if (got <= 0) {
|
if (got <= 0) {
|
||||||
if (got == 0)
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("console stream EOF"));
|
|
||||||
|
|
||||||
virConsoleShutdown(con);
|
virConsoleShutdown(con);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue