[libvirt] [[libvirt-glib PATCHv2] 4/4] Replace g_error with g_warning in constructors

Christophe Fergeau cfergeau at redhat.com
Tue Jan 31 11:00:23 UTC 2012


g_error generates a fatal error message, meaning it will abort
the currently running process. It's nicer to use g_warning here.
---
 libvirt-gobject/libvirt-gobject-domain.c         |    4 +++-
 libvirt-gobject/libvirt-gobject-network-filter.c |    4 +++-
 libvirt-gobject/libvirt-gobject-network.c        |    4 +++-
 libvirt-gobject/libvirt-gobject-secret.c         |    4 +++-
 libvirt-gobject/libvirt-gobject-storage-pool.c   |    4 +++-
 5 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
index 0f64833..e4d480a 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -134,7 +134,9 @@ static void gvir_domain_constructed(GObject *object)
 
     /* xxx we may want to turn this into an initable */
     if (virDomainGetUUIDString(priv->handle, priv->uuid) < 0) {
-        g_error("Failed to get domain UUID on %p", priv->handle);
+        virErrorPtr verr = virGetLastError();
+        g_warning("Failed to get domain UUID on %p: %s",
+                  priv->handle, verr->message);
     }
 }
 
diff --git a/libvirt-gobject/libvirt-gobject-network-filter.c b/libvirt-gobject/libvirt-gobject-network-filter.c
index efefdf4..eb9cc82 100644
--- a/libvirt-gobject/libvirt-gobject-network-filter.c
+++ b/libvirt-gobject/libvirt-gobject-network-filter.c
@@ -119,7 +119,9 @@ static void gvir_network_filter_constructed(GObject *object)
 
     /* xxx we may want to turn this into an initable */
     if (virNWFilterGetUUIDString(priv->handle, priv->uuid) < 0) {
-        g_error("Failed to get network filter UUID on %p", priv->handle);
+        virErrorPtr verr = virGetLastError();
+        g_warning("Failed to get network filter UUID on %p: %s",
+                  priv->handle, verr->message);
     }
 }
 
diff --git a/libvirt-gobject/libvirt-gobject-network.c b/libvirt-gobject/libvirt-gobject-network.c
index 43c1a52..dcd2300 100644
--- a/libvirt-gobject/libvirt-gobject-network.c
+++ b/libvirt-gobject/libvirt-gobject-network.c
@@ -118,7 +118,9 @@ static void gvir_network_constructed(GObject *object)
 
     /* xxx we may want to turn this into an initable */
     if (virNetworkGetUUIDString(priv->handle, priv->uuid) < 0) {
-        g_error("Failed to get network UUID on %p", priv->handle);
+        virErrorPtr verr = virGetLastError();
+        g_warning("Failed to get network UUID on %p: %s",
+                  priv->handle, verr->message);
     }
 }
 
diff --git a/libvirt-gobject/libvirt-gobject-secret.c b/libvirt-gobject/libvirt-gobject-secret.c
index bc5ee3b..cd819a5 100644
--- a/libvirt-gobject/libvirt-gobject-secret.c
+++ b/libvirt-gobject/libvirt-gobject-secret.c
@@ -119,7 +119,9 @@ static void gvir_secret_constructed(GObject *object)
 
     /* xxx we may want to turn this into an initable */
     if (virSecretGetUUIDString(priv->handle, priv->uuid) < 0) {
-        g_error("Failed to get secret UUID on %p", priv->handle);
+        virErrorPtr verr = virGetLastError();
+        g_warning("Failed to get secret UUID on %p: %s",
+                  priv->handle, verr->message);
     }
 }
 
diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c
index ef8617f..ffb8b26 100644
--- a/libvirt-gobject/libvirt-gobject-storage-pool.c
+++ b/libvirt-gobject/libvirt-gobject-storage-pool.c
@@ -129,7 +129,9 @@ static void gvir_storage_pool_constructed(GObject *object)
 
     /* xxx we may want to turn this into an initable */
     if (virStoragePoolGetUUIDString(priv->handle, priv->uuid) < 0) {
-        g_error("Failed to get storage pool UUID on %p", priv->handle);
+        virErrorPtr verr = virGetLastError();
+        g_warning("Failed to get storage pool UUID on %p: %s",
+                  priv->handle, verr->message);
     }
 }
 
-- 
1.7.7.6




More information about the libvir-list mailing list