[[libvirt-glib PATCHv3] 3/3] Replace g_error with g_warning in constructors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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         |    9 ++++++++-
 libvirt-gobject/libvirt-gobject-network-filter.c |    9 ++++++++-
 libvirt-gobject/libvirt-gobject-network.c        |    9 ++++++++-
 libvirt-gobject/libvirt-gobject-secret.c         |    8 +++++++-
 libvirt-gobject/libvirt-gobject-storage-pool.c   |    8 +++++++-
 5 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
index 82da0c3..d9e4c00 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -134,7 +134,14 @@ 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();
+        if (verr) {
+            g_warning("Failed to get domain UUID on %p: %s",
+                      priv->handle, verr->message);
+        } else {
+            g_warning("Failed to get domain UUID on %p",
+                      priv->handle);
+        }
     }
 }
 
diff --git a/libvirt-gobject/libvirt-gobject-network-filter.c b/libvirt-gobject/libvirt-gobject-network-filter.c
index b1543a3..5956a3d 100644
--- a/libvirt-gobject/libvirt-gobject-network-filter.c
+++ b/libvirt-gobject/libvirt-gobject-network-filter.c
@@ -119,7 +119,14 @@ 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();
+        if (verr) {
+            g_warning("Failed to get network filter UUID on %p: %s",
+                      priv->handle, verr->message);
+        } else {
+            g_warning("Failed to get network filter UUID on %p",
+                      priv->handle);
+        }
     }
 }
 
diff --git a/libvirt-gobject/libvirt-gobject-network.c b/libvirt-gobject/libvirt-gobject-network.c
index 8cbea07..16cd2f1 100644
--- a/libvirt-gobject/libvirt-gobject-network.c
+++ b/libvirt-gobject/libvirt-gobject-network.c
@@ -118,7 +118,14 @@ 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();
+        if (verr) {
+            g_warning("Failed to get network UUID on %p: %s",
+                      priv->handle, verr->message);
+        } else {
+            g_warning("Failed to get network UUID on %p",
+                      priv->handle);
+        }
     }
 }
 
diff --git a/libvirt-gobject/libvirt-gobject-secret.c b/libvirt-gobject/libvirt-gobject-secret.c
index bc5ee3b..3c9da86 100644
--- a/libvirt-gobject/libvirt-gobject-secret.c
+++ b/libvirt-gobject/libvirt-gobject-secret.c
@@ -119,7 +119,13 @@ 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();
+        if (verr) {
+            g_warning("Failed to get secret UUID on %p: %s",
+                      priv->handle, verr->message);
+        } else {
+            g_warning("Failed to get secret UUID on %p", priv->handle);
+        }
     }
 }
 
diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c
index aa71029..db496f3 100644
--- a/libvirt-gobject/libvirt-gobject-storage-pool.c
+++ b/libvirt-gobject/libvirt-gobject-storage-pool.c
@@ -129,7 +129,13 @@ 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();
+        if (verr) {
+            g_warning("Failed to get storage pool UUID on %p: %s",
+                      priv->handle, verr->message);
+        } else {
+            g_warning("Failed to get storage pool UUID on %p", priv->handle);
+        }
     }
 }
 
-- 
1.7.7.6

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]