[libvirt] [libvirt-glib] Log virStreamFinish error when it fails

GVirObjectStream::finalize() logs a critical() if virStreamFinish fails. This commit adds the libvirt error message to this critical to ease debugging. --- libvirt-gobject/libvirt-gobject-stream.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libvirt-gobject/libvirt-gobject-stream.c b/libvirt-gobject/libvirt-gobject-stream.c index fa1a32c..3c61fdb 100644 --- a/libvirt-gobject/libvirt-gobject-stream.c +++ b/libvirt-gobject/libvirt-gobject-stream.c @@ -217,8 +217,10 @@ static void gvir_stream_finalize(GObject *object) if (priv->handle) { gvir_stream_update_events(self); - if (virStreamFinish(priv->handle) < 0) - g_critical("cannot finish stream"); + if (virStreamFinish(priv->handle) < 0) { + virErrorPtr verr = virGetLastError(); + g_critical("cannot finish stream: %s", verr->message); + } virStreamFree(priv->handle); } -- 1.7.12.1

On 05.11.2012 14:21, Christophe Fergeau wrote:
GVirObjectStream::finalize() logs a critical() if virStreamFinish fails. This commit adds the libvirt error message to this critical to ease debugging. --- libvirt-gobject/libvirt-gobject-stream.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-stream.c b/libvirt-gobject/libvirt-gobject-stream.c index fa1a32c..3c61fdb 100644 --- a/libvirt-gobject/libvirt-gobject-stream.c +++ b/libvirt-gobject/libvirt-gobject-stream.c @@ -217,8 +217,10 @@ static void gvir_stream_finalize(GObject *object) if (priv->handle) { gvir_stream_update_events(self);
- if (virStreamFinish(priv->handle) < 0) - g_critical("cannot finish stream"); + if (virStreamFinish(priv->handle) < 0) { + virErrorPtr verr = virGetLastError(); + g_critical("cannot finish stream: %s", verr->message); + }
virStreamFree(priv->handle); }
ACK Michal

On Mon, Nov 05, 2012 at 02:29:27PM +0100, Michal Privoznik wrote:
On 05.11.2012 14:21, Christophe Fergeau wrote:
GVirObjectStream::finalize() logs a critical() if virStreamFinish fails. This commit adds the libvirt error message to this critical to ease debugging.
ACK
Actually I'm going to self-NACK this, and I'll be sending a more generic patch. Other places are checking the error from libvirt against NULL, and this does not address all the g_warning which don't show the libvirt error. I have a patch adding gvir_warning/gvir_critical functions which wrap g_warning/g_critical and append the error message from libvirt automatically. Christophe
participants (2)
-
Christophe Fergeau
-
Michal Privoznik