From patchwork Fri Jan 13 09:59:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 135766 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7544EB6F71 for ; Fri, 13 Jan 2012 21:00:37 +1100 (EST) Received: from localhost ([::1]:40341 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rldw2-00051e-VE for incoming@patchwork.ozlabs.org; Fri, 13 Jan 2012 05:00:34 -0500 Received: from eggs.gnu.org ([140.186.70.92]:35598) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rldve-0004VK-UH for qemu-devel@nongnu.org; Fri, 13 Jan 2012 05:00:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RldvV-00022B-J8 for qemu-devel@nongnu.org; Fri, 13 Jan 2012 05:00:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:13890) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RldvV-000224-7I for qemu-devel@nongnu.org; Fri, 13 Jan 2012 05:00:01 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0D9xxrE008092 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 13 Jan 2012 04:59:59 -0500 Received: from localhost (ovpn-113-56.phx2.redhat.com [10.3.113.56]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q0D9xuqs004802; Fri, 13 Jan 2012 04:59:58 -0500 From: Amit Shah To: qemu list Date: Fri, 13 Jan 2012 15:29:47 +0530 Message-Id: <368d7a9f08f8eaef87993fa8def32d86bb310735.1326448718.git.amit.shah@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Amit Shah , Gerd Hoffmann , Markus Armbruster Subject: [Qemu-devel] [PATCH v2 1/2] qdev: Add a 'free' method to disassociate chardev from qdev device 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 When a device is removed, remove the association with a chardev, if any, so that the chardev can be re-used later for other devices. Reported-by: Qunfang Zhang Fix-suggested-by: Markus Armbruster Signed-off-by: Amit Shah --- hw/qdev-properties.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 663c2a0..02f0dae 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -680,6 +680,16 @@ static int parse_chr(DeviceState *dev, Property *prop, const char *str) return 0; } +static void free_chr(DeviceState *dev, Property *prop) +{ + CharDriverState **ptr = qdev_get_prop_ptr(dev, prop); + + if (*ptr) { + qemu_chr_add_handlers(*ptr, NULL, NULL, NULL, NULL); + } +} + + static int print_chr(DeviceState *dev, Property *prop, char *dest, size_t len) { CharDriverState **ptr = qdev_get_prop_ptr(dev, prop); @@ -699,6 +709,7 @@ PropertyInfo qdev_prop_chr = { .print = print_chr, .get = get_generic, .set = set_generic, + .free = free_chr, }; /* --- netdev device --- */