qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: Lei Li <lilei@linux.vnet.ibm.com>
Cc: qemu-devel@nongnu.org, anthony@codemonkey.ws
Subject: Re: [Qemu-devel] [PATCH 1/4] monitor: introduce monitor_read_console
Date: Mon, 9 Sep 2013 15:13:31 -0400	[thread overview]
Message-ID: <20130909151331.4341483e@redhat.com> (raw)
In-Reply-To: <1378112508-8970-2-git-send-email-lilei@linux.vnet.ibm.com>

On Mon,  2 Sep 2013 17:01:45 +0800
Lei Li <lilei@linux.vnet.ibm.com> wrote:

> This patch introduces monitor_read_console(), which will drop
> into interactive mode with chardev ringbuf backend, and install
> a readline handler. When the handler is invoked, the given data
> will be written to ringbuf backend.
> 
> Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
> ---
>  include/monitor/monitor.h |    3 +++
>  monitor.c                 |   14 ++++++++++++++
>  2 files changed, 17 insertions(+), 0 deletions(-)
> 
> diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
> index 1942cc4..e6a6f47 100644
> --- a/include/monitor/monitor.h
> +++ b/include/monitor/monitor.h
> @@ -89,6 +89,9 @@ ReadLineState *monitor_get_rs(Monitor *mon);
>  int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func,
>                            void *opaque);
>  
> +int monitor_read_console(Monitor *mon, const char *device,
> +                         ReadLineFunc *readline_func, void *opaque);
> +
>  int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret);
>  
>  int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret);
> diff --git a/monitor.c b/monitor.c
> index 0aeaf6c..531095e 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -263,6 +263,20 @@ int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func,
>      }
>  }
>  
> +int monitor_read_console(Monitor *mon, const char *device,
> +                         ReadLineFunc *readline_func, void *opaque)
> +{
> +    char prompt[60];
> +
> +    if (!mon->rs) {
> +        return -1;
> +    }
> +
> +    snprintf(prompt, sizeof(prompt), "%s: ", device);

You can use g_strdup_printf() to avoid a fixed size buffer.

> +    readline_start(mon->rs, prompt, 0, readline_func, opaque);
> +    return 0;
> +}
> +
>  static gboolean monitor_unblocked(GIOChannel *chan, GIOCondition cond,
>                                    void *opaque)
>  {

  reply	other threads:[~2013-09-09 20:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-02  9:01 [Qemu-devel] [PATCH 0/4 RFC] Introduce console for ringbuf backend Lei Li
2013-09-02  9:01 ` [Qemu-devel] [PATCH 1/4] monitor: introduce monitor_read_console Lei Li
2013-09-09 19:13   ` Luiz Capitulino [this message]
2013-09-02  9:01 ` [Qemu-devel] [PATCH 2/4] hmp: factor out ringbuf_print_help() Lei Li
2013-09-09 19:15   ` Luiz Capitulino
2013-09-02  9:01 ` [Qemu-devel] [PATCH 3/4] qemu-char: export ringbuf_count Lei Li
2013-09-02  9:01 ` [Qemu-devel] [PATCH 4/4] hmp: add console support for ringbuf backend Lei Li
2013-09-09 20:27   ` Luiz Capitulino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130909151331.4341483e@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=lilei@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).