From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55944) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UK74O-0004L7-0l for qemu-devel@nongnu.org; Mon, 25 Mar 2013 09:04:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UK74F-0000zF-Ss for qemu-devel@nongnu.org; Mon, 25 Mar 2013 09:04:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51131) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UK74F-0000ys-Lq for qemu-devel@nongnu.org; Mon, 25 Mar 2013 09:04:03 -0400 Message-ID: <51504C0F.40501@redhat.com> Date: Mon, 25 Mar 2013 14:07:27 +0100 From: Hans de Goede MIME-Version: 1.0 References: <1364128793-12689-1-git-send-email-hdegoede@redhat.com> <1364128793-12689-4-git-send-email-hdegoede@redhat.com> <87d2unodgq.fsf@codemonkey.ws> In-Reply-To: <87d2unodgq.fsf@codemonkey.ws> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 3/8] qemu-char: Add fe_open tracking List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Amit Shah , qemu-devel@nongnu.org Hi, On 03/25/2013 01:45 PM, Anthony Liguori wrote: > Hans de Goede writes: > >> Add tracking of the fe_open state to struct CharDriverState. >> >> Signed-off-by: Hans de Goede >> --- >> 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. Ok, will fix in the next iteration of this patchset. Regards, Hans