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@xxxxxxxxxxxxx> > Signed-off-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxx> > --- > 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