From patchwork Wed Dec 16 12:32:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 557444 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 A12D91402C9 for ; Wed, 16 Dec 2015 23:36:31 +1100 (AEDT) Received: from localhost ([::1]:46948 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9BJl-0001am-KU for incoming@patchwork.ozlabs.org; Wed, 16 Dec 2015 07:36:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33608) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9BGB-0004Or-5j for qemu-devel@nongnu.org; Wed, 16 Dec 2015 07:32:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9BG6-000153-90 for qemu-devel@nongnu.org; Wed, 16 Dec 2015 07:32:47 -0500 Received: from smtp.citrix.com ([66.165.176.89]:17866) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9BG6-00014u-10 for qemu-devel@nongnu.org; Wed, 16 Dec 2015 07:32:42 -0500 X-IronPort-AV: E=Sophos;i="5.20,436,1444694400"; d="scan'208";a="319670443" From: Ian Campbell To: , , Date: Wed, 16 Dec 2015 12:32:04 +0000 Message-ID: <1450269131-27735-2-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1450269131-27735-1-git-send-email-ian.campbell@citrix.com> References: <1450269007.4053.48.camel@citrix.com> <1450269131-27735-1-git-send-email-ian.campbell@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.165.176.89 Cc: Ian Campbell , qemu-devel@nongnu.org, stefano.stabellini@eu.citrix.com Subject: [Qemu-devel] [PATCH QEMU-XEN v7 1/8] xen_console: correctly cleanup primary console on teardown. 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 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; } }