From: Paolo Bonzini <pbonzini@redhat.com>
To: marcandre.lureau@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/3] char: clean up remaining chardevs when leaving
Date: Thu, 16 Jun 2016 14:19:30 +0200 [thread overview]
Message-ID: <ae2839ad-890e-debd-1b00-e0ba5b8464c6@redhat.com> (raw)
In-Reply-To: <1466075835-28494-2-git-send-email-marcandre.lureau@redhat.com>
On 16/06/2016 13:17, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> This helps to remove various chardev resources leaks when leaving qemu.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> 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, uint8_t *buf, int len);
> */
> void qemu_chr_be_event(CharDriverState *s, int event);
>
> +/**
> + * @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;
> }
>
> +void qemu_chr_cleanup(void)
> +{
> + CharDriverState *chr;
> +
> + QTAILQ_FOREACH(chr, &chardevs, next) {
> + qemu_chr_delete(chr);
> + }
> +}
> +
> QemuOptsList qemu_chardev_opts = {
> .name = "chardev",
> .implied_opt_name = "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();
Given the amount of exit(1) calls surviving in QEMU, it's probably
better to use atexit here.
Paolo
> return 0;
> }
>
next prev parent reply other threads:[~2016-06-16 12:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-16 11:17 [Qemu-devel] [PATCH 0/3] chardev cleanups marcandre.lureau
2016-06-16 11:17 ` [Qemu-devel] [PATCH 1/3] char: clean up remaining chardevs when leaving marcandre.lureau
2016-06-16 12:19 ` Paolo Bonzini [this message]
2016-06-16 12:25 ` Marc-André Lureau
2016-06-16 11:17 ` [Qemu-devel] [PATCH 2/3] socket: add listen feature marcandre.lureau
2016-06-16 11:17 ` [Qemu-devel] [PATCH 3/3] socket: unlink unix socket on remove marcandre.lureau
2016-06-16 12:28 ` Paolo Bonzini
2016-06-16 12:36 ` Marc-André Lureau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ae2839ad-890e-debd-1b00-e0ba5b8464c6@redhat.com \
--to=pbonzini@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).