From patchwork Tue Oct 6 19:18:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 526919 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:4830:134:3::10]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5D9A4140D89 for ; Wed, 7 Oct 2015 06:21:04 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=VLWLeTs9; dkim-atps=neutral Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZjXms-0003Sz-KU for incoming@patchwork.ozlabs.org; Tue, 06 Oct 2015 15:21:02 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_20,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:45507) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjXmn-0003BX-SK for incoming@patchwork.ozlabs.org; Tue, 06 Oct 2015 15:20:30 -0400 Received: from localhost ([::1]:53297 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjXmn-0008Tj-2k for incoming@patchwork.ozlabs.org; Tue, 06 Oct 2015 15:20:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53192) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjXmT-0007xh-8A for qemu-devel@nongnu.org; Tue, 06 Oct 2015 15:20:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZjXmR-0001R1-Lr for qemu-devel@nongnu.org; Tue, 06 Oct 2015 15:20:09 -0400 Received: from mail-qg0-x232.google.com ([2607:f8b0:400d:c04::232]:34479) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjXmR-0001Qe-Iq for qemu-devel@nongnu.org; Tue, 06 Oct 2015 15:20:07 -0400 Received: by qgez77 with SMTP id z77so184211170qge.1 for ; Tue, 06 Oct 2015 12:20:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=QXB6lB0c7JpzeQUWPCBFSb2h82ZHEBy8xp2tHjtW6ts=; b=VLWLeTs9jLE9N5Pv55iPKOwWa/GiTUV1SXFzYgbsftRgrIZrLXSrcIaPfHz/TADTD1 J3ysK7KlAOmJDX8BYLaGyrToHm+Ktbuel4Ce0PQdnxNt0+5IZvZqWd7Biy4+2Snb/XRK XZneWdAK4n1e4ml3vHAS7vxOvezoAljXNa9kWE2Wq33p8ZeNR6GT2sj+uM++hqrJ21VU oQYbu3Pm3VhdWWNlbbfw9Wy6S+FFWznEtzT3WTXrrsmp8nFCZfi6zdA8UNK18T0KmP8H 1CBda+SaMAXY5vnEnQlOiynGzDcmsw0lqghYJuTuXIiOfBLAKid1PSQpPGZ4jAZMy4Ea Z3yQ== X-Received: by 10.140.146.3 with SMTP id 3mr52039272qhs.76.1444159207173; Tue, 06 Oct 2015 12:20:07 -0700 (PDT) Received: from localhost (bne75-h02-31-39-163-232.dsl.sta.abo.bbox.fr. [31.39.163.232]) by smtp.gmail.com with ESMTPSA id r26sm7567650qki.16.2015.10.06.12.20.05 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Oct 2015 12:20:06 -0700 (PDT) From: marcandre.lureau@redhat.com To: peter.maydell@linaro.org Date: Tue, 6 Oct 2015 21:18:57 +0200 Message-Id: <1444159184-18153-2-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1444159184-18153-1-git-send-email-marcandre.lureau@redhat.com> References: <1444159184-18153-1-git-send-email-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL 01/48] char: add qemu_chr_free() 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 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 From: Marc-André Lureau If a chardev is allowed to be created outside of QMP, then it must be also possible to free it. This is useful for ivshmem that creates chardev anonymously and must be able to free them. Signed-off-by: Marc-André Lureau Acked-by: Paolo Bonzini Reviewed-by: Claudio Fontana --- include/sysemu/char.h | 10 +++++++++- qemu-char.c | 9 +++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/include/sysemu/char.h b/include/sysemu/char.h index 832b7fe..5fd0a09 100644 --- a/include/sysemu/char.h +++ b/include/sysemu/char.h @@ -128,11 +128,19 @@ CharDriverState *qemu_chr_new(const char *label, const char *filename, /** * @qemu_chr_delete: * - * Destroy a character backend. + * Destroy a character backend and remove it from the list of + * identified character backends. */ void qemu_chr_delete(CharDriverState *chr); /** + * @qemu_chr_free: + * + * Destroy a character backend. + */ +void qemu_chr_free(CharDriverState *chr); + +/** * @qemu_chr_fe_set_echo: * * Ask the backend to override its normal echo setting. This only really diff --git a/qemu-char.c b/qemu-char.c index 653ea10..e6ed85c 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -3840,9 +3840,8 @@ void qemu_chr_fe_release(CharDriverState *s) s->avail_connections++; } -void qemu_chr_delete(CharDriverState *chr) +void qemu_chr_free(CharDriverState *chr) { - QTAILQ_REMOVE(&chardevs, chr, next); if (chr->chr_close) { chr->chr_close(chr); } @@ -3852,6 +3851,12 @@ void qemu_chr_delete(CharDriverState *chr) g_free(chr); } +void qemu_chr_delete(CharDriverState *chr) +{ + QTAILQ_REMOVE(&chardevs, chr, next); + qemu_chr_free(chr); +} + ChardevInfoList *qmp_query_chardev(Error **errp) { ChardevInfoList *chr_list = NULL;