From patchwork Fri Jan 15 13:23:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 8040491 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6DF0DBEEED for ; Fri, 15 Jan 2016 13:26:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 99ADC20459 for ; Fri, 15 Jan 2016 13:26:01 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C5D942044C for ; Fri, 15 Jan 2016 13:26:00 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aK4MG-0005F1-Oi; Fri, 15 Jan 2016 13:24:04 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aK4MB-00051y-RT for xen-devel@lists.xen.org; Fri, 15 Jan 2016 13:23:59 +0000 Received: from [85.158.139.211] by server-6.bemta-5.messagelabs.com id 6F/E1-22089-FE2F8965; Fri, 15 Jan 2016 13:23:59 +0000 X-Env-Sender: prvs=815b692d9=Ian.Campbell@citrix.com X-Msg-Ref: server-8.tower-206.messagelabs.com!1452864236!15862063!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 9667 invoked from network); 15 Jan 2016 13:23:58 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-8.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 15 Jan 2016 13:23:58 -0000 X-IronPort-AV: E=Sophos;i="5.22,299,1449532800"; d="scan'208";a="331644689" From: Ian Campbell To: , , Date: Fri, 15 Jan 2016 13:23:37 +0000 Message-ID: <1452864224-2554-2-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1452864224-2554-1-git-send-email-ian.campbell@citrix.com> References: <1452864168.32341.97.camel@citrix.com> <1452864224-2554-1-git-send-email-ian.campbell@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: Ian Campbell , qemu-devel@nongnu.org, stefano.stabellini@eu.citrix.com Subject: [Xen-devel] [PATCH QEMU-XEN v8 1/8] xen_console: correctly cleanup primary console on teardown. X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00, RCVD_IN_BRBL_LASTEXT, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP All of the work in con_disconnect applies to the primary console case (when xendev->dev is NULL). Therefore remove the early check and bail and allow it to fall through. All of the existing code is correctly conditional already. The ->dev and ->gnttabdev handles are either both set or neither. For consistency with con_initialise() with to the former here too. With this con_initialise and con_disconnect now mirror each other. Fix up a hard tab in the function while editing. Signed-off-by: Ian Campbell Reviewed-by: Stefano Stabellini --- v4: New patch based on feedback to "xen: Switch uses of xc_map_foreign_bulk to use libxenforeignmemory API." --- hw/char/xen_console.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/hw/char/xen_console.c b/hw/char/xen_console.c index eb7f450..63ade33 100644 --- a/hw/char/xen_console.c +++ b/hw/char/xen_console.c @@ -265,9 +265,6 @@ static void con_disconnect(struct XenDevice *xendev) { struct XenConsole *con = container_of(xendev, struct XenConsole, xendev); - if (!xendev->dev) { - return; - } if (con->chr) { qemu_chr_add_handlers(con->chr, NULL, NULL, NULL, NULL); qemu_chr_fe_release(con->chr); @@ -275,12 +272,12 @@ static void con_disconnect(struct XenDevice *xendev) xen_be_unbind_evtchn(&con->xendev); if (con->sring) { - if (!xendev->gnttabdev) { + if (!xendev->dev) { munmap(con->sring, XC_PAGE_SIZE); } else { xc_gnttab_munmap(xendev->gnttabdev, con->sring, 1); } - con->sring = NULL; + con->sring = NULL; } }