mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
virsh: Show 'connected to console' message later
Right now, we display the message before actually attempting to connect to the VM console. That operation, however, can fail for a number of reasons: for example, is the VM doesn't have a serial device, the output ends up looking like $ virsh console cirros Connected to domain 'cirros' Escape character is ^] (Ctrl + ]) error: internal error: cannot find character device <null> The initial message is misleading. Change things so that it's only printed if we actually successfully connected to the VM console. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
1e853a64dd
commit
16d37076be
@ -418,12 +418,6 @@ virshRunConsole(vshControl *ctl,
|
|||||||
|
|
||||||
sigemptyset(&sighandler.sa_mask);
|
sigemptyset(&sighandler.sa_mask);
|
||||||
|
|
||||||
/* Put STDIN into raw mode so that stuff typed does not echo to the screen
|
|
||||||
* (the TTY reads will result in it being echoed back already), and also
|
|
||||||
* ensure Ctrl-C, etc is blocked, and misc other bits */
|
|
||||||
if (vshTTYMakeRaw(ctl, true) < 0)
|
|
||||||
goto resettty;
|
|
||||||
|
|
||||||
if (!(con = virConsoleNew()))
|
if (!(con = virConsoleNew()))
|
||||||
goto resettty;
|
goto resettty;
|
||||||
|
|
||||||
@ -447,6 +441,19 @@ 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;
|
||||||
|
|
||||||
|
vshPrintExtra(ctl, _("Connected to domain '%1$s'\n"), virDomainGetName(dom));
|
||||||
|
vshPrintExtra(ctl, _("Escape character is %1$s"), priv->escapeChar);
|
||||||
|
if (priv->escapeChar[0] == '^')
|
||||||
|
vshPrintExtra(ctl, " (Ctrl + %c)", priv->escapeChar[1]);
|
||||||
|
vshPrintExtra(ctl, "\n");
|
||||||
|
fflush(stdout);
|
||||||
|
|
||||||
|
/* Put STDIN into raw mode so that stuff typed does not echo to the screen
|
||||||
|
* (the TTY reads will result in it being echoed back already), and also
|
||||||
|
* ensure Ctrl-C, etc is blocked, and misc other bits */
|
||||||
|
if (vshTTYMakeRaw(ctl, true) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
virObjectRef(con);
|
virObjectRef(con);
|
||||||
if ((con->stdinWatch = virEventAddHandle(STDIN_FILENO,
|
if ((con->stdinWatch = virEventAddHandle(STDIN_FILENO,
|
||||||
VIR_EVENT_HANDLE_READABLE,
|
VIR_EVENT_HANDLE_READABLE,
|
||||||
|
@ -3017,7 +3017,6 @@ cmdRunConsole(vshControl *ctl, virDomainPtr dom,
|
|||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
int state;
|
int state;
|
||||||
virshControl *priv = ctl->privData;
|
|
||||||
|
|
||||||
if ((state = virshDomainState(ctl, dom, NULL)) < 0) {
|
if ((state = virshDomainState(ctl, dom, NULL)) < 0) {
|
||||||
vshError(ctl, "%s", _("Unable to get domain status"));
|
vshError(ctl, "%s", _("Unable to get domain status"));
|
||||||
@ -3034,12 +3033,6 @@ cmdRunConsole(vshControl *ctl, virDomainPtr dom,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
vshPrintExtra(ctl, _("Connected to domain '%1$s'\n"), virDomainGetName(dom));
|
|
||||||
vshPrintExtra(ctl, _("Escape character is %1$s"), priv->escapeChar);
|
|
||||||
if (priv->escapeChar[0] == '^')
|
|
||||||
vshPrintExtra(ctl, " (Ctrl + %c)", priv->escapeChar[1]);
|
|
||||||
vshPrintExtra(ctl, "\n");
|
|
||||||
fflush(stdout);
|
|
||||||
if (virshRunConsole(ctl, dom, name, resume_domain, flags) == 0)
|
if (virshRunConsole(ctl, dom, name, resume_domain, flags) == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user