[libvirt] [v0.9.12-maint 10/11] conf: Remove console stream callback only when freeing console helper
Eric Blake
eblake at redhat.com
Wed Sep 11 21:01:50 UTC 2013
On 09/11/2013 08:17 AM, Peter Krempa wrote:
> Commit ba226d334acbc49f6751b430e0c4e00f69eef6bf tried to fix crash of
> the daemon when a domain with an open console was destroyed. The fix was
> wrong as it tried to remove the callback also when the stream was
> aborted, where at that point the fd stream driver was already freed and
> removed.
>
> This patch clears the callbacks with a helper right before the hash is
> freed, so that it doesn't interfere with other codepaths where the
> stream object is freed.
> ---
> src/conf/virconsole.c | 16 +++++++++++++---
> 1 file changed, 13 insertions(+), 3 deletions(-)
Missing the cherry-pick reference to
45edefc7a7bcbec988f54331ff37fc32e4bc2718
>
> diff --git a/src/conf/virconsole.c b/src/conf/virconsole.c
> index e665149..01f1c84 100644
> --- a/src/conf/virconsole.c
> +++ b/src/conf/virconsole.c
> @@ -222,9 +222,6 @@ static void virConsoleHashEntryFree(void *data,
> const char *pty = name;
> virStreamPtr st = data;
>
> - /* remove callback from stream */
> - virFDStreamSetInternalCloseCb(st, NULL, NULL, NULL);
> -
> /* free stream reference */
> virStreamFree(st);
>
> @@ -293,6 +290,18 @@ error:
> }
>
> /**
> + * Helper to clear stream callbacks when freeing the hash
> + */
> +static void virConsoleFreeClearCallbacks(void *payload,
> + const void *name ATTRIBUTE_UNUSED,
> + void *data ATTRIBUTE_UNUSED)
> +{
> + virStreamPtr st = payload;
> +
> + virFDStreamSetInternalCloseCb(st, NULL, NULL, NULL);
> +}
> +
> +/**
> * Free structures for handling open console streams.
> *
> * @cons Pointer to the private structure.
> @@ -303,6 +312,7 @@ void virConsoleFree(virConsolesPtr cons)
> return;
>
> virMutexLock(&cons->lock);
> + virHashForEach(cons->hash, virConsoleFreeClearCallbacks, NULL);
> virHashFree(cons->hash);
> virMutexUnlock(&cons->lock);
> virMutexDestroy(&cons->lock);
>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130911/2f98f02a/attachment-0001.sig>
More information about the libvir-list
mailing list