found 710517 0.9.12-11
fixed 710517 0.10.0
tags 710517 + patch
thanks

"Carpenter, Christopher" <[email protected]> writes:

> This bug seems to happen every time I try to virsh destroy (or use
> appropriate libvirt API call) while already having an open console via
> virsh console.

I also hit this issue.  It's not 100% reproducible for me, but almost.
In a production cluster hosting virtual machines it leads to cluster
fencing, ie. hard reboot of the affected host machine, as its VMs become
unmanageable when libvirtd dies.  So I consider this a serious bug, but
also an easy to fix one: upstream already fixed it as noted in the
upstream tracker (altough an unrelated commit is mentioned there by
mistake; I included the fixed line based on that info, not on testing).

I wonder why the original report indicated version 0.9.12-11.1, did that
version officially exist?  On the other hand, it's actually the version
given to my locally modified package (with the attached patch added to
fix this bug).  Anybody interested can get it from:
deb(-src) http://apt.niif.hu/debian wheezy main

As this bug affects wheezy, I hereby plea for including the fix in a
stable update.
-- 
Thanks,
Feri.

Description: Fix libvirtd crash when destroying a domain with attached console
Author: Peter Krempa <[email protected]>
Origin: upstream
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=969497
Applied-Upstream: ba226d334acbc49f6751b430e0c4e00f69eef6bf and 45edefc7a7bcbec988f54331ff37fc32e4bc2718
Last-Update: 2013-06-07
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/

This is two upstream commits squashed:

commit ba226d334acbc49f6751b430e0c4e00f69eef6bf
Author: Peter Krempa <[email protected]>
Date:   Fri Jul 27 14:50:54 2012 +0200

    conf: Remove callback from stream when freeing entries in console hash
    
    When a domain has a active console connection and is destroyed the
    callback is called on private data that no longer exist causing a
    segfault.

commit 45edefc7a7bcbec988f54331ff37fc32e4bc2718
Author: Peter Krempa <[email protected]>
Date:   Fri Aug 3 11:20:29 2012 +0200

    conf: Remove console stream callback only when freeing console helper
    
    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.
Index: libvirt-0.9.12/src/conf/virconsole.c
===================================================================
--- libvirt-0.9.12.orig/src/conf/virconsole.c	2012-02-28 07:39:38.000000000 +0100
+++ libvirt-0.9.12/src/conf/virconsole.c	2013-06-07 10:50:09.564085862 +0200
@@ -290,6 +290,18 @@
 }
 
 /**
+ * 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.
@@ -300,6 +312,7 @@
         return;
 
     virMutexLock(&cons->lock);
+    virHashForEach(cons->hash, virConsoleFreeClearCallbacks, NULL);
     virHashFree(cons->hash);
     virMutexUnlock(&cons->lock);
     virMutexDestroy(&cons->lock);

Reply via email to