[PATCH libvirt v1 0/3] Ensure full early console access with libvirt

Currently, early console output may be lost, e.g. if starting a guest with `virsh start --console` guest, which can make debugging of early failures very difficult (like zipl messages or disabled wait conditions happening early). This is because QEMU may emit serial console output before the libvirt console client starts to consume data from the pts. This can be prevented by starting the guest in paused state, connect to the console and then resume the guest. Note: There is still a problem in QEMU itself, see QEMU patch series `[PATCH] chardev/char-pty: Avoid losing bytes when the other side just (re-)connected` [1] Changelog: RFCv1->v1: + rebased on current master + worked in comments from Daniel [1] https://lists.gnu.org/archive/html/qemu-devel/2023-08/msg02725.html Marc Hartmayer (3): virsh: add `console --resume` support Improve `virsh start --console` behavior Improve `virsh create --console` behavior tools/virsh-console.c | 8 ++++ tools/virsh-console.h | 1 + tools/virsh-domain.c | 94 ++++++++++++++++++++++++++++++++----------- 3 files changed, 80 insertions(+), 23 deletions(-) base-commit: dd403f8873cf8de7675b89ed757a4228af7bc05e -- 2.34.1

This patch adds the command line flag `--resume` to the `virsh console` command. This resumes a paused guest after connecting to the console. This might be handy since it's a "common" pattern to start a guest paused, connect to the console, and then resume it so as not to miss any console messages. Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> --- tools/virsh-console.c | 8 ++++++++ tools/virsh-console.h | 1 + tools/virsh-domain.c | 14 ++++++++++---- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/tools/virsh-console.c b/tools/virsh-console.c index 6bfb44a190ec..e44a070e7045 100644 --- a/tools/virsh-console.c +++ b/tools/virsh-console.c @@ -401,6 +401,7 @@ int virshRunConsole(vshControl *ctl, virDomainPtr dom, const char *dev_name, + const bool resume_domain, unsigned int flags) { virConsole *con = NULL; @@ -476,6 +477,13 @@ virshRunConsole(vshControl *ctl, goto cleanup; } + if (resume_domain) { + if (virDomainResume(dom) != 0) { + vshError(ctl, _("Failed to resume domain '%1$s'"), virDomainGetName(dom)); + goto cleanup; + } + } + while (!con->quit) { if (virCondWait(&con->cond, &con->parent.lock) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/tools/virsh-console.h b/tools/virsh-console.h index e89484d24bf4..2d00ed90cf4a 100644 --- a/tools/virsh-console.h +++ b/tools/virsh-console.h @@ -27,6 +27,7 @@ int virshRunConsole(vshControl *ctl, virDomainPtr dom, const char *dev_name, + const bool resume_domain, unsigned int flags); #endif /* !WIN32 */ diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 7abafe2ba30c..5c3c6d18aebf 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -3012,6 +3012,10 @@ static const vshCmdOptDef opts_console[] = { .type = VSH_OT_BOOL, .help = N_("force console connection (disconnect already connected sessions)") }, + {.name = "resume", + .type = VSH_OT_BOOL, + .help = N_("resume a paused guest after connecting to console") + }, {.name = "safe", .type = VSH_OT_BOOL, .help = N_("only connect if safe console handling is supported") @@ -3022,6 +3026,7 @@ static const vshCmdOptDef opts_console[] = { static bool cmdRunConsole(vshControl *ctl, virDomainPtr dom, const char *name, + const bool resume_domain, unsigned int flags) { int state; @@ -3048,7 +3053,7 @@ cmdRunConsole(vshControl *ctl, virDomainPtr dom, vshPrintExtra(ctl, " (Ctrl + %c)", priv->escapeChar[1]); vshPrintExtra(ctl, "\n"); fflush(stdout); - if (virshRunConsole(ctl, dom, name, flags) == 0) + if (virshRunConsole(ctl, dom, name, resume_domain, flags) == 0) return true; return false; @@ -3059,6 +3064,7 @@ cmdConsole(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom = NULL; bool force = vshCommandOptBool(cmd, "force"); + bool resume = vshCommandOptBool(cmd, "resume"); bool safe = vshCommandOptBool(cmd, "safe"); unsigned int flags = 0; const char *name = NULL; @@ -3074,7 +3080,7 @@ cmdConsole(vshControl *ctl, const vshCmd *cmd) if (safe) flags |= VIR_DOMAIN_CONSOLE_SAFE; - return cmdRunConsole(ctl, dom, name, flags); + return cmdRunConsole(ctl, dom, name, resume, flags); } #endif /* WIN32 */ @@ -4136,7 +4142,7 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) vshPrintExtra(ctl, _("Domain '%1$s' started\n"), virDomainGetName(dom)); #ifndef WIN32 - if (console && !cmdRunConsole(ctl, dom, NULL, 0)) + if (console && !cmdRunConsole(ctl, dom, NULL, false, 0)) return false; #endif @@ -8232,7 +8238,7 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd) virDomainGetName(dom), from); #ifndef WIN32 if (console) - cmdRunConsole(ctl, dom, NULL, 0); + cmdRunConsole(ctl, dom, NULL, false, 0); #endif return true; } -- 2.34.1

On 28/09/2023 17.37, Marc Hartmayer wrote:
This patch adds the command line flag `--resume` to the `virsh console` command. This resumes a paused guest after connecting to the console. This might be handy since it's a "common" pattern to start a guest paused, connect to the console, and then resume it so as not to miss any console messages.
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> --- tools/virsh-console.c | 8 ++++++++ tools/virsh-console.h | 1 + tools/virsh-domain.c | 14 ++++++++++---- 3 files changed, 19 insertions(+), 4 deletions(-)
Reviewed-by: Thomas Huth <thuth@redhat.com>

On 9/28/23 17:37, Marc Hartmayer wrote:
This patch adds the command line flag `--resume` to the `virsh console` command. This resumes a paused guest after connecting to the console. This might be handy since it's a "common" pattern to start a guest paused, connect to the console, and then resume it so as not to miss any console messages.
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> --- tools/virsh-console.c | 8 ++++++++ tools/virsh-console.h | 1 + tools/virsh-domain.c | 14 ++++++++++---- 3 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/tools/virsh-console.c b/tools/virsh-console.c index 6bfb44a190ec..e44a070e7045 100644 --- a/tools/virsh-console.c +++ b/tools/virsh-console.c @@ -401,6 +401,7 @@ int virshRunConsole(vshControl *ctl, virDomainPtr dom, const char *dev_name, + const bool resume_domain, unsigned int flags) { virConsole *con = NULL; @@ -476,6 +477,13 @@ virshRunConsole(vshControl *ctl, goto cleanup; }
+ if (resume_domain) { + if (virDomainResume(dom) != 0) { + vshError(ctl, _("Failed to resume domain '%1$s'"), virDomainGetName(dom));
Long line.
+ goto cleanup; + } + } + while (!con->quit) { if (virCondWait(&con->cond, &con->parent.lock) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/tools/virsh-console.h b/tools/virsh-console.h index e89484d24bf4..2d00ed90cf4a 100644 --- a/tools/virsh-console.h +++ b/tools/virsh-console.h @@ -27,6 +27,7 @@ int virshRunConsole(vshControl *ctl, virDomainPtr dom, const char *dev_name, + const bool resume_domain, unsigned int flags);
#endif /* !WIN32 */ diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 7abafe2ba30c..5c3c6d18aebf 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -3012,6 +3012,10 @@ static const vshCmdOptDef opts_console[] = { .type = VSH_OT_BOOL, .help = N_("force console connection (disconnect already connected sessions)") }, + {.name = "resume", + .type = VSH_OT_BOOL, + .help = N_("resume a paused guest after connecting to console") + },
New options must go hand in hand with manpage update. Michal

When starting a guest via libvirt (`virsh start --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 guest 2. attach the console 3. resume the guest Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> --- tools/virsh-domain.c | 50 +++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 5c3c6d18aebf..36670039444c 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -4059,12 +4059,27 @@ static const vshCmdOptDef opts_start[] = { {.name = NULL} }; +static int +virDomainCreateHelper(virDomainPtr dom, unsigned int nfds, int *fds, + unsigned int flags) +{ + /* Prefer older API unless we have to pass a flag. */ + if (nfds > 0) { + return virDomainCreateWithFiles(dom, nfds, fds, flags); + } else if (flags != 0) { + return virDomainCreateWithFlags(dom, flags); + } else { + return virDomainCreate(dom); + } +} + static bool cmdStart(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom = NULL; #ifndef WIN32 bool console = vshCommandOptBool(cmd, "console"); + bool resume_domain = false; #endif unsigned int flags = VIR_DOMAIN_NONE; int rc; @@ -4083,8 +4098,14 @@ cmdStart(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, "bypass-cache")) @@ -4096,12 +4117,7 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) /* We can emulate force boot, even for older servers that reject it. */ if (flags & VIR_DOMAIN_START_FORCE_BOOT) { - if (nfds > 0) { - rc = virDomainCreateWithFiles(dom, nfds, fds, flags); - } else { - rc = virDomainCreateWithFlags(dom, flags); - } - + rc = virDomainCreateHelper(dom, nfds, fds, flags); if (rc == 0) goto started; @@ -4124,14 +4140,18 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) flags &= ~VIR_DOMAIN_START_FORCE_BOOT; } - /* Prefer older API unless we have to pass a flag. */ - if (nfds > 0) { - rc = virDomainCreateWithFiles(dom, nfds, fds, flags); - } else if (flags != 0) { - rc = virDomainCreateWithFlags(dom, flags); - } else { - rc = virDomainCreate(dom); + rc = virDomainCreateHelper(dom, nfds, fds, flags); +#ifndef WIN32 + /* If the driver does not support the paused flag, let's fallback to the old + * behavior without the flag. */ + if (rc < 0 && resume_domain && last_error && last_error->code == VIR_ERR_INVALID_ARG) { + vshResetLibvirtError(); + + flags &= ~VIR_DOMAIN_START_PAUSED; + resume_domain = false; + rc = virDomainCreateHelper(dom, nfds, fds, flags); } +#endif if (rc < 0) { vshError(ctl, _("Failed to start domain '%1$s'"), virDomainGetName(dom)); @@ -4142,7 +4162,7 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) vshPrintExtra(ctl, _("Domain '%1$s' started\n"), virDomainGetName(dom)); #ifndef WIN32 - if (console && !cmdRunConsole(ctl, dom, NULL, false, 0)) + if (console && !cmdRunConsole(ctl, dom, NULL, resume_domain, 0)) return false; #endif -- 2.34.1

On 28/09/2023 17.37, Marc Hartmayer wrote:
When starting a guest via libvirt (`virsh start --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 guest 2. attach the console 3. resume the guest
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> --- tools/virsh-domain.c | 50 +++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 15 deletions(-)
Reviewed-by: Thomas Huth <thuth@redhat.com>

On 9/28/23 17:37, Marc Hartmayer wrote:
When starting a guest via libvirt (`virsh start --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 guest 2. attach the console 3. resume the guest
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> --- tools/virsh-domain.c | 50 +++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 15 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 5c3c6d18aebf..36670039444c 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -4059,12 +4059,27 @@ static const vshCmdOptDef opts_start[] = { {.name = NULL} };
+static int +virDomainCreateHelper(virDomainPtr dom, unsigned int nfds, int *fds, + unsigned int flags)
To make naming less confusing, we prefer 'virsh' prefix in virsh instead of 'vir'. It makes it obvious whether a function is a public libvirt API (virDomainCreate...) or a virsh helper (virshDomainCreate...)
+{ + /* Prefer older API unless we have to pass a flag. */ + if (nfds > 0) { + return virDomainCreateWithFiles(dom, nfds, fds, flags); + } else if (flags != 0) { + return virDomainCreateWithFlags(dom, flags); + } else { + return virDomainCreate(dom); + } +} + static bool cmdStart(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom = NULL; #ifndef WIN32 bool console = vshCommandOptBool(cmd, "console"); + bool resume_domain = false; #endif unsigned int flags = VIR_DOMAIN_NONE; int rc; @@ -4083,8 +4098,14 @@ cmdStart(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, "bypass-cache")) @@ -4096,12 +4117,7 @@ cmdStart(vshControl *ctl, const vshCmd *cmd)
/* We can emulate force boot, even for older servers that reject it. */ if (flags & VIR_DOMAIN_START_FORCE_BOOT) { - if (nfds > 0) { - rc = virDomainCreateWithFiles(dom, nfds, fds, flags); - } else { - rc = virDomainCreateWithFlags(dom, flags); - } - + rc = virDomainCreateHelper(dom, nfds, fds, flags); if (rc == 0) goto started;
@@ -4124,14 +4140,18 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) flags &= ~VIR_DOMAIN_START_FORCE_BOOT; }
- /* Prefer older API unless we have to pass a flag. */ - if (nfds > 0) { - rc = virDomainCreateWithFiles(dom, nfds, fds, flags); - } else if (flags != 0) { - rc = virDomainCreateWithFlags(dom, flags); - } else { - rc = virDomainCreate(dom); + rc = virDomainCreateHelper(dom, nfds, fds, flags); +#ifndef WIN32 + /* If the driver does not support the paused flag, let's fallback to the old + * behavior without the flag. */ + if (rc < 0 && resume_domain && last_error && last_error->code == VIR_ERR_INVALID_ARG) {
Long line. Michal

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@linux.ibm.com> Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> --- tools/virsh-domain.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 36670039444c..2f055df0d97d 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -8212,6 +8212,13 @@ static const vshCmdOptDef opts_create[] = { {.name = NULL} }; + +static virshDomain *virDomainCreateXMLHelper(virConnectPtr conn, const char *xmlDesc, unsigned int nfds, int *fds, unsigned int flags) { + if (nfds) + return virDomainCreateXMLWithFiles(conn, xmlDesc, nfds, fds, flags); + return virDomainCreateXML(conn, xmlDesc, flags); +} + static bool cmdCreate(vshControl *ctl, const vshCmd *cmd) { @@ -8220,6 +8227,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; @@ -8235,8 +8243,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")) @@ -8244,10 +8258,18 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "reset-nvram")) flags |= VIR_DOMAIN_START_RESET_NVRAM; - if (nfds) - dom = virDomainCreateXMLWithFiles(priv->conn, buffer, nfds, fds, flags); - else - dom = virDomainCreateXML(priv->conn, buffer, flags); + dom = virDomainCreateXMLHelper(priv->conn, buffer, nfds, fds, flags); +#ifndef WIN32 + /* If the driver does not support the paused flag, let's fallback to the old + * behavior without the flag. */ + if (!dom && resume_domain && last_error && last_error->code == VIR_ERR_INVALID_ARG) { + vshResetLibvirtError(); + + flags &= ~VIR_DOMAIN_START_PAUSED; + resume_domain = false; + dom = virDomainCreateXMLHelper(priv->conn, buffer, nfds, fds, flags); + } +#endif if (!dom) { vshError(ctl, _("Failed to create domain from %1$s"), from); @@ -8258,7 +8280,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

On 28/09/2023 17.37, Marc Hartmayer wrote:
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@linux.ibm.com> Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> --- tools/virsh-domain.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-)
Reviewed-by: Thomas Huth <thuth@redhat.com>

On 9/28/23 17:37, Marc Hartmayer wrote:
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@linux.ibm.com> Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> --- tools/virsh-domain.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 36670039444c..2f055df0d97d 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -8212,6 +8212,13 @@ static const vshCmdOptDef opts_create[] = { {.name = NULL} };
+ +static virshDomain *virDomainCreateXMLHelper(virConnectPtr conn, const char *xmlDesc, unsigned int nfds, int *fds, unsigned int flags) { + if (nfds) + return virDomainCreateXMLWithFiles(conn, xmlDesc, nfds, fds, flags); + return virDomainCreateXML(conn, xmlDesc, flags); +} +
s/virDomainCreate/virshDomainCreate/ Michal

On Thu, Sep 28, 2023 at 05:37 PM +0200, Marc Hartmayer <mhartmay@linux.ibm.com> wrote:
Currently, early console output may be lost, e.g. if starting a guest with `virsh start --console` guest, which can make debugging of early failures very difficult (like zipl messages or disabled wait conditions happening early). This is because QEMU may emit serial console output before the libvirt console client starts to consume data from the pts. This can be prevented by starting the guest in paused state, connect to the console and then resume the guest.
Note: There is still a problem in QEMU itself, see QEMU patch series `[PATCH] chardev/char-pty: Avoid losing bytes when the other side just (re-)connected` [1]
Changelog: RFCv1->v1: + rebased on current master + worked in comments from Daniel
[1] https://lists.gnu.org/archive/html/qemu-devel/2023-08/msg02725.html
Marc Hartmayer (3): virsh: add `console --resume` support Improve `virsh start --console` behavior Improve `virsh create --console` behavior
tools/virsh-console.c | 8 ++++ tools/virsh-console.h | 1 + tools/virsh-domain.c | 94 ++++++++++++++++++++++++++++++++----------- 3 files changed, 80 insertions(+), 23 deletions(-)
base-commit: dd403f8873cf8de7675b89ed757a4228af7bc05e -- 2.34.1
Polite ping and adding Daniel to CC - sry I missed that in the beginning. -- Kind regards / Beste Grüße Marc Hartmayer IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Gregor Pillen Geschäftsführung: David Faller Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

On Wed, Oct 11, 2023 at 10:05 AM +0200, "Marc Hartmayer" <mhartmay@linux.ibm.com> wrote:
On Thu, Sep 28, 2023 at 05:37 PM +0200, Marc Hartmayer <mhartmay@linux.ibm.com> wrote:
Currently, early console output may be lost, e.g. if starting a guest with `virsh start --console` guest, which can make debugging of early failures very difficult (like zipl messages or disabled wait conditions happening early). This is because QEMU may emit serial console output before the libvirt console client starts to consume data from the pts. This can be prevented by starting the guest in paused state, connect to the console and then resume the guest.
Note: There is still a problem in QEMU itself, see QEMU patch series `[PATCH] chardev/char-pty: Avoid losing bytes when the other side just (re-)connected` [1]
This patch is now accepted upstream.
Changelog: RFCv1->v1: + rebased on current master + worked in comments from Daniel
[1] https://lists.gnu.org/archive/html/qemu-devel/2023-08/msg02725.html
Marc Hartmayer (3): virsh: add `console --resume` support Improve `virsh start --console` behavior Improve `virsh create --console` behavior
tools/virsh-console.c | 8 ++++ tools/virsh-console.h | 1 + tools/virsh-domain.c | 94 ++++++++++++++++++++++++++++++++----------- 3 files changed, 80 insertions(+), 23 deletions(-)
base-commit: dd403f8873cf8de7675b89ed757a4228af7bc05e -- 2.34.1
Polite ping and adding Daniel to CC - sry I missed that in the beginning.
-- Kind regards / Beste Grüße Marc Hartmayer
IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Gregor Pillen Geschäftsführung: David Faller Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294
Very friendly ping. -- Kind regards / Beste Grüße Marc Hartmayer IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Gregor Pillen Geschäftsführung: David Faller Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

On 9/28/23 17:37, Marc Hartmayer wrote:
Currently, early console output may be lost, e.g. if starting a guest with `virsh start --console` guest, which can make debugging of early failures very difficult (like zipl messages or disabled wait conditions happening early). This is because QEMU may emit serial console output before the libvirt console client starts to consume data from the pts. This can be prevented by starting the guest in paused state, connect to the console and then resume the guest.
Note: There is still a problem in QEMU itself, see QEMU patch series `[PATCH] chardev/char-pty: Avoid losing bytes when the other side just (re-)connected` [1]
Changelog: RFCv1->v1: + rebased on current master + worked in comments from Daniel
[1] https://lists.gnu.org/archive/html/qemu-devel/2023-08/msg02725.html
Marc Hartmayer (3): virsh: add `console --resume` support Improve `virsh start --console` behavior Improve `virsh create --console` behavior
tools/virsh-console.c | 8 ++++ tools/virsh-console.h | 1 + tools/virsh-domain.c | 94 ++++++++++++++++++++++++++++++++----------- 3 files changed, 80 insertions(+), 23 deletions(-)
base-commit: dd403f8873cf8de7675b89ed757a4228af7bc05e
All 'issues' I've raised are trivial. I've fixed them and pushed. Sorry for leaving this to rot this long on the list. Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Michal

On Tue, Oct 24, 2023 at 02:12 PM +0200, Michal Prívozník <mprivozn@redhat.com> wrote:
On 9/28/23 17:37, Marc Hartmayer wrote:
Currently, early console output may be lost, e.g. if starting a guest with `virsh start --console` guest, which can make debugging of early failures very difficult (like zipl messages or disabled wait conditions happening early). This is because QEMU may emit serial console output before the libvirt console client starts to consume data from the pts. This can be prevented by starting the guest in paused state, connect to the console and then resume the guest.
Note: There is still a problem in QEMU itself, see QEMU patch series `[PATCH] chardev/char-pty: Avoid losing bytes when the other side just (re-)connected` [1]
Changelog: RFCv1->v1: + rebased on current master + worked in comments from Daniel
[1] https://lists.gnu.org/archive/html/qemu-devel/2023-08/msg02725.html
Marc Hartmayer (3): virsh: add `console --resume` support Improve `virsh start --console` behavior Improve `virsh create --console` behavior
tools/virsh-console.c | 8 ++++ tools/virsh-console.h | 1 + tools/virsh-domain.c | 94 ++++++++++++++++++++++++++++++++----------- 3 files changed, 80 insertions(+), 23 deletions(-)
base-commit: dd403f8873cf8de7675b89ed757a4228af7bc05e
All 'issues' I've raised are trivial. I've fixed them and pushed. Sorry for leaving this to rot this long on the list.
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Thanks a ton!
Michal
-- Kind regards / Beste Grüße Marc Hartmayer IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Gregor Pillen Geschäftsführung: David Faller Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

On Tue, Oct 24, 2023 at 05:14:41PM +0200, Marc Hartmayer wrote:
On Tue, Oct 24, 2023 at 02:12 PM +0200, Michal Prívozník <mprivozn@redhat.com> wrote:
On 9/28/23 17:37, Marc Hartmayer wrote:
Marc Hartmayer (3): virsh: add `console --resume` support Improve `virsh start --console` behavior Improve `virsh create --console` behavior
All 'issues' I've raised are trivial. I've fixed them and pushed. Sorry for leaving this to rot this long on the list.
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Thanks a ton!
Marc, can you please add a couple of lines about this change to the release notes (NEWS.rst)? It's a really nice improvement and we definitely want users to learn about it :) Thanks in advance! -- Andrea Bolognani / Red Hat / Virtualization

On Tue, Oct 24, 2023 at 09:29 AM -0700, Andrea Bolognani <abologna@redhat.com> wrote:
On Tue, Oct 24, 2023 at 05:14:41PM +0200, Marc Hartmayer wrote:
On Tue, Oct 24, 2023 at 02:12 PM +0200, Michal Prívozník <mprivozn@redhat.com> wrote:
On 9/28/23 17:37, Marc Hartmayer wrote:
Marc Hartmayer (3): virsh: add `console --resume` support Improve `virsh start --console` behavior Improve `virsh create --console` behavior
All 'issues' I've raised are trivial. I've fixed them and pushed. Sorry for leaving this to rot this long on the list.
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Thanks a ton!
Marc,
can you please add a couple of lines about this change to the release notes (NEWS.rst)? It's a really nice improvement and we definitely want users to learn about it :)
Thanks in advance!
Done.
-- Andrea Bolognani / Red Hat / Virtualization
-- Kind regards / Beste Grüße Marc Hartmayer IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Gregor Pillen Geschäftsführung: David Faller Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294
participants (4)
-
Andrea Bolognani
-
Marc Hartmayer
-
Michal Prívozník
-
Thomas Huth