From patchwork Thu Jun 19 19:39:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 362000 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id DCF7714009D for ; Fri, 20 Jun 2014 06:23:04 +1000 (EST) Received: from localhost ([::1]:37596 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxiPL-0001YA-TV for incoming@patchwork.ozlabs.org; Thu, 19 Jun 2014 15:54:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47209) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxiCH-00059M-Tk for qemu-devel@nongnu.org; Thu, 19 Jun 2014 15:40:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxiCB-0007wL-PX for qemu-devel@nongnu.org; Thu, 19 Jun 2014 15:40:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23700) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxiCB-0007w3-GA for qemu-devel@nongnu.org; Thu, 19 Jun 2014 15:40:27 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5JJeL2W011230 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 19 Jun 2014 15:40:21 -0400 Received: from localhost (ovpn-113-20.phx2.redhat.com [10.3.113.20]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5JJeKOA011596; Thu, 19 Jun 2014 15:40:21 -0400 From: Luiz Capitulino To: peter.maydell@linaro.org Date: Thu, 19 Jun 2014 15:39:48 -0400 Message-Id: <1403206792-15387-37-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1403206792-15387-1-git-send-email-lcapitulino@redhat.com> References: <1403206792-15387-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, anthony@codemonkey.ws Subject: [Qemu-devel] [PULL 36/40] qemu-char: do not call chr_write directly X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Paolo Bonzini Make the mux always go through qemu_chr_fe_write, so that we'll get the mutex for the underlying chardev. Reviewed-by: Fam Zheng Signed-off-by: Paolo Bonzini Signed-off-by: Luiz Capitulino --- qemu-char.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 56a0a9a..26994aa 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -279,7 +279,7 @@ static int mux_chr_write(CharDriverState *chr, const uint8_t *buf, int len) MuxDriver *d = chr->opaque; int ret; if (!d->timestamps) { - ret = d->drv->chr_write(d->drv, buf, len); + ret = qemu_chr_fe_write(d->drv, buf, len); } else { int i; @@ -301,10 +301,10 @@ static int mux_chr_write(CharDriverState *chr, const uint8_t *buf, int len) (secs / 60) % 60, secs % 60, (int)(ti % 1000)); - d->drv->chr_write(d->drv, (uint8_t *)buf1, strlen(buf1)); + qemu_chr_fe_write(d->drv, (uint8_t *)buf1, strlen(buf1)); d->linestart = 0; } - ret += d->drv->chr_write(d->drv, buf+i, 1); + ret += qemu_chr_fe_write(d->drv, buf+i, 1); if (buf[i] == '\n') { d->linestart = 1; } @@ -339,13 +339,13 @@ static void mux_print_help(CharDriverState *chr) "\n\rEscape-Char set to Ascii: 0x%02x\n\r\n\r", term_escape_char); } - chr->chr_write(chr, (uint8_t *)cbuf, strlen(cbuf)); + qemu_chr_fe_write(chr, (uint8_t *)cbuf, strlen(cbuf)); for (i = 0; mux_help[i] != NULL; i++) { for (j=0; mux_help[i][j] != '\0'; j++) { if (mux_help[i][j] == '%') - chr->chr_write(chr, (uint8_t *)ebuf, strlen(ebuf)); + qemu_chr_fe_write(chr, (uint8_t *)ebuf, strlen(ebuf)); else - chr->chr_write(chr, (uint8_t *)&mux_help[i][j], 1); + qemu_chr_fe_write(chr, (uint8_t *)&mux_help[i][j], 1); } } } @@ -370,7 +370,7 @@ static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch) case 'x': { const char *term = "QEMU: Terminated\n\r"; - chr->chr_write(chr,(uint8_t *)term,strlen(term)); + qemu_chr_fe_write(chr, (uint8_t *)term, strlen(term)); exit(0); break; }