Received: from eggs.gnu.org ([2001:4830:134:3::10]:57551) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDVIc-0000LV-9o for qemu-devel@nongnu.org; Thu, 16 Jun 2016 07:17:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDVIV-0006Gh-1m for qemu-devel@nongnu.org; Thu, 16 Jun 2016 07:17:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59012) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDVIU-0006GU-SF for qemu-devel@nongnu.org; Thu, 16 Jun 2016 07:17:18 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 86C9D3B709 for ; Thu, 16 Jun 2016 11:17:18 +0000 (UTC) From: marcandre.lureau@redhat.com Date: Thu, 16 Jun 2016 13:17:13 +0200 Message-Id: <1466075835-28494-2-git-send-email-marcandre.lureau@redhat.com> In-Reply-To: <1466075835-28494-1-git-send-email-marcandre.lureau@redhat.com> References: <1466075835-28494-1-git-send-email-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 1/3] char: clean up remaining chardevs when leaving List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, berrange@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= From: Marc-Andr=C3=A9 Lureau This helps to remove various chardev resources leaks when leaving qemu. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/sysemu/char.h | 7 +++++++ qemu-char.c | 9 +++++++++ vl.c | 1 + 3 files changed, 17 insertions(+) diff --git a/include/sysemu/char.h b/include/sysemu/char.h index 372a6fd..8954be1 100644 --- a/include/sysemu/char.h +++ b/include/sysemu/char.h @@ -382,6 +382,13 @@ void qemu_chr_be_write_impl(CharDriverState *s, uint= 8_t *buf, int len); */ void qemu_chr_be_event(CharDriverState *s, int event); =20 +/** + * @qemu_chr_cleanup: + * + * Delete all chardevs (when leaving qemu) + */ +void qemu_chr_cleanup(void); + void qemu_chr_add_handlers(CharDriverState *s, IOCanReadHandler *fd_can_read, IOReadHandler *fd_read, diff --git a/qemu-char.c b/qemu-char.c index b13ecbb..bf098a1 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -4088,6 +4088,15 @@ CharDriverState *qemu_chr_find(const char *name) return NULL; } =20 +void qemu_chr_cleanup(void) +{ + CharDriverState *chr; + + QTAILQ_FOREACH(chr, &chardevs, next) { + qemu_chr_delete(chr); + } +} + QemuOptsList qemu_chardev_opts =3D { .name =3D "chardev", .implied_opt_name =3D "backend", diff --git a/vl.c b/vl.c index 45eff56..ac92b1d 100644 --- a/vl.c +++ b/vl.c @@ -4628,6 +4628,7 @@ int main(int argc, char **argv, char **envp) #ifdef CONFIG_TPM tpm_cleanup(); #endif + qemu_chr_cleanup(); =20 return 0; } --=20 2.7.4