When starting a guest via libvirt (`virsh create --console`), early
console output was missed because the guest was started first and then
the console was attached. This patch changes this to the following
sequence:
1. create a paused transient guest
2. attach the console
3. resume the guest
Reviewed-by: Boris Fiuczynski <fiuczy(a)linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay(a)linux.ibm.com>
---
tools/virsh-domain.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 3581161c6f53..5a97d44190c4 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -8207,6 +8207,7 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd)
g_autofree char *buffer = NULL;
#ifndef WIN32
bool console = vshCommandOptBool(cmd, "console");
+ bool resume_domain = false;
#endif
unsigned int flags = 0;
size_t nfds = 0;
@@ -8222,8 +8223,14 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd)
if (virshFetchPassFdsList(ctl, cmd, &nfds, &fds) < 0)
return false;
- if (vshCommandOptBool(cmd, "paused"))
+ if (vshCommandOptBool(cmd, "paused")) {
flags |= VIR_DOMAIN_START_PAUSED;
+#ifndef WIN32
+ } else if (console) {
+ flags |= VIR_DOMAIN_START_PAUSED;
+ resume_domain = true;
+#endif
+ }
if (vshCommandOptBool(cmd, "autodestroy"))
flags |= VIR_DOMAIN_START_AUTODESTROY;
if (vshCommandOptBool(cmd, "validate"))
@@ -8245,7 +8252,7 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd)
virDomainGetName(dom), from);
#ifndef WIN32
if (console)
- cmdRunConsole(ctl, dom, NULL, false, 0);
+ cmdRunConsole(ctl, dom, NULL, resume_domain, 0);
#endif
return true;
}
--
2.34.1