int vshRunConsole(virDomainPtr dom,
const char *dev_name,
- const char *escape_seq)
+ const char *escape_seq,
+ unsigned int flags)
{
int ret = -1;
struct termios ttyattr, rawattr;
if (!con->st)
goto cleanup;
- if (virDomainOpenConsole(dom, dev_name, con->st, 0) < 0)
+ if (virDomainOpenConsole(dom, dev_name, con->st, flags) < 0)
goto cleanup;
if (virCondInit(&con->cond) < 0 || virMutexInit(&con->lock) < 0)
static const vshCmdOptDef opts_console[] = {
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
{"devname", VSH_OT_STRING, 0, N_("character device name")},
+ {"force", VSH_OT_BOOL, 0,
+ N_("force console connection (disconnect already connected sessions)")},
+ {"safe", VSH_OT_BOOL, 0,
+ N_("only connect if safe console handling is supported")},
{NULL, 0, 0, NULL}
};
static bool
-cmdRunConsole(vshControl *ctl, virDomainPtr dom, const char *name)
+cmdRunConsole(vshControl *ctl, virDomainPtr dom,
+ const char *name,
+ unsigned int flags)
{
bool ret = false;
int state;
vshPrintExtra(ctl, _("Connected to domain %s\n"), virDomainGetName(dom));
vshPrintExtra(ctl, _("Escape character is %s\n"), ctl->escapeChar);
fflush(stdout);
- if (vshRunConsole(dom, name, ctl->escapeChar) == 0)
+ if (vshRunConsole(dom, name, ctl->escapeChar, flags) == 0)
ret = true;
cleanup:
{
virDomainPtr dom;
bool ret = false;
+ bool force = vshCommandOptBool(cmd, "force");
+ bool safe = vshCommandOptBool(cmd, "safe");
+ unsigned int flags = 0;
const char *name = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
}
- ret = cmdRunConsole(ctl, dom, name);
+ if (force)
+ flags |= VIR_DOMAIN_CONSOLE_FORCE;
+ if (safe)
+ flags |= VIR_DOMAIN_CONSOLE_SAFE;
+
+ ret = cmdRunConsole(ctl, dom, name, flags);
cleanup:
virDomainFree(dom);
virDomainGetName(dom), from);
#ifndef WIN32
if (console)
- cmdRunConsole(ctl, dom, NULL);
+ cmdRunConsole(ctl, dom, NULL, 0);
#endif
virDomainFree(dom);
} else {
vshPrint(ctl, _("Domain %s started\n"),
virDomainGetName(dom));
#ifndef WIN32
- if (console && !cmdRunConsole(ctl, dom, NULL))
+ if (console && !cmdRunConsole(ctl, dom, NULL, 0))
goto cleanup;
#endif
The option I<--disable> disables autostarting.
-=item B<console> I<domain-id> [I<devname>]
+=item B<console> I<domain-id> [I<devname>] [I<--safe>] [I<--force>]
Connect the virtual serial console for the guest. The optional
I<devname> parameter refers to the device alias of an alternate
console, serial or parallel device configured for the guest.
If omitted, the primary console will be opened.
+If the flag I<--safe> is specified, the connection is only attempted
+if the driver supports safe console handling. This flag specifies that
+the server has to ensure exclusive access to console devices. Optionally
+the I<--force> flag may be specified, requesting to disconnect any existing
+sessions, such as in a case of a broken connection.
+
=item B<create> I<FILE> [I<--console>] [I<--paused>] [I<--autodestroy>]
Create a domain from an XML <file>. An easy way to create the XML