From patchwork Tue Jan 26 15:52:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 8124441 Return-Path: X-Original-To: patchwork-qemu-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 DCCA5BEEE5 for ; Tue, 26 Jan 2016 15:55:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4741220121 for ; Tue, 26 Jan 2016 15:55:02 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 959C42011E for ; Tue, 26 Jan 2016 15:55:01 +0000 (UTC) Received: from localhost ([::1]:44772 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO5xN-0002bi-0N for patchwork-qemu-devel@patchwork.kernel.org; Tue, 26 Jan 2016 10:55:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53864) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO5v9-0006dz-LL for qemu-devel@nongnu.org; Tue, 26 Jan 2016 10:52:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aO5v6-0000Dp-VC for qemu-devel@nongnu.org; Tue, 26 Jan 2016 10:52:43 -0500 Received: from smtp.citrix.com ([66.165.176.89]:34729) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO5v6-0000DV-QA for qemu-devel@nongnu.org; Tue, 26 Jan 2016 10:52:40 -0500 X-IronPort-AV: E=Sophos;i="5.22,350,1449532800"; d="scan'208";a="327722913" From: Stefano Stabellini To: Date: Tue, 26 Jan 2016 15:52:00 +0000 Message-ID: <1453823527-22312-1-git-send-email-stefano.stabellini@eu.citrix.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: 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 , xen-devel@lists.xensource.com, qemu-devel@nongnu.org, Stefano Stabellini Subject: [Qemu-devel] [PULL 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 From: Ian Campbell 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 --- 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; } }