qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 3/8] qemu-char: Add fe_open tracking


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH 3/8] qemu-char: Add fe_open tracking
Date: Mon, 25 Mar 2013 07:45:09 -0500
User-agent: Notmuch/0.13.2+93~ged93d79 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu)

Hans de Goede <address@hidden> writes:

> Add tracking of the fe_open state to struct CharDriverState.
>
> Signed-off-by: Hans de Goede <address@hidden>
> ---
>  include/char/char.h | 1 +
>  qemu-char.c         | 2 ++
>  2 files changed, 3 insertions(+)
>
> diff --git a/include/char/char.h b/include/char/char.h
> index dd8f39a..3174575 100644
> --- a/include/char/char.h
> +++ b/include/char/char.h
> @@ -75,6 +75,7 @@ struct CharDriverState {
>      char *label;
>      char *filename;
>      int be_open;
> +    int fe_open;
>      int avail_connections;
>      QemuOpts *opts;
>      QTAILQ_ENTRY(CharDriverState) next;
> diff --git a/qemu-char.c b/qemu-char.c
> index 55795d7..554d72f 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -3385,6 +3385,7 @@ void qemu_chr_fe_set_echo(struct CharDriverState *chr, 
> bool echo)
>  
>  void qemu_chr_fe_open(struct CharDriverState *chr)
>  {
> +    chr->fe_open = 1;
>      if (chr->chr_guest_open) {
>          chr->chr_guest_open(chr);
>      }
> @@ -3392,6 +3393,7 @@ void qemu_chr_fe_open(struct CharDriverState *chr)
>  
>  void qemu_chr_fe_close(struct CharDriverState *chr)
>  {
> +    chr->fe_open = 0;

Even though this gets rewritten later on, you should avoid calling the
callback when open is called when fe_open=1.  Something like

if (!chr->fe_open) {
    return;
}

Then later when this becomes set_fe_open() the backend doesn't need to
deal with double open/close.

Regards,

Anthony Liguori

>      if (chr->chr_guest_close) {
>          chr->chr_guest_close(chr);
>      }
> -- 
> 1.8.1.4



reply via email to

[Prev in Thread] Current Thread [Next in Thread]