Message ID | 1438043577-28636-2-git-send-email-marcandre.lureau@redhat.com |
---|---|
State | New |
Headers | show |
On 28/07/2015 02:32, Marc-André Lureau wrote: > From: Marc-André Lureau <marcandre.lureau@gmail.com> > > 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 <marcandre.lureau@redhat.com> > --- > 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 d956f8d..13e302b 100644 > --- a/qemu-char.c > +++ b/qemu-char.c > @@ -3843,9 +3843,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); > } > @@ -3855,6 +3854,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; > Acked-by: Paolo Bonzini <pbonzini@redhat.com>
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 d956f8d..13e302b 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -3843,9 +3843,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); } @@ -3855,6 +3854,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;