[PATCH] interface: reformat error logs

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

 



It was suggested during review of a different patch that the libvirt
interface driver API's should have "netcf:" in their log
messages. This patch eliminates that from all interface driver API
functions, and also eliminates the extra " - " in the case that netcf
returns no details in its error info (which *never* happens at
present, but could happen sometime in the future.
---
 src/interface/netcf_driver.c |   79 +++++++++++++++++++++++++-----------------
 1 files changed, 47 insertions(+), 32 deletions(-)

diff --git a/src/interface/netcf_driver.c b/src/interface/netcf_driver.c
index b5b4f79..dd15c9d 100644
--- a/src/interface/netcf_driver.c
+++ b/src/interface/netcf_driver.c
@@ -107,8 +107,9 @@ static struct netcf_if *interfaceDriverGetNetcfIF(struct netcf *ncf, virInterfac
         int errcode = ncf_error(ncf, &errmsg, &details);
         if (errcode != NETCF_NOERROR) {
             interfaceReportError(netcf_to_vir_err(errcode),
-                                 _("couldn't find interface named '%s' (netcf: %s - %s)"),
-                                 ifinfo->name, errmsg, details ? details : "");
+                                 _("couldn't find interface named '%s': %s%s%s"),
+                                 ifinfo->name, errmsg, details ? " - " : "",
+                                 details ? details : "");
         } else {
             interfaceReportError(VIR_ERR_NO_INTERFACE,
                                  _("couldn't find interface named '%s'"),
@@ -188,8 +189,8 @@ static int interfaceNumOfInterfaces(virConnectPtr conn)
         const char *errmsg, *details;
         int errcode = ncf_error(driver->netcf, &errmsg, &details);
         interfaceReportError(netcf_to_vir_err(errcode),
-                             _("failed to get number of interfaces on host (netcf: %s - %s)"),
-                            errmsg, details ? details : "");
+                             _("failed to get number of interfaces on host: %s%s%s"),
+                             errmsg, details ? " - " : "", details ? details : "");
     }
 
     interfaceDriverUnlock(driver);
@@ -208,8 +209,9 @@ static int interfaceListInterfaces(virConnectPtr conn, char **const names, int n
         const char *errmsg, *details;
         int errcode = ncf_error(driver->netcf, &errmsg, &details);
         interfaceReportError(netcf_to_vir_err(errcode),
-                             _("failed to list host interfaces (netcf: %s - %s)"),
-                            errmsg, details ? details : "");
+                             _("failed to list host interfaces: %s%s%s"),
+                             errmsg, details ? " - " : "",
+                             details ? details : "");
     }
 
     interfaceDriverUnlock(driver);
@@ -228,8 +230,9 @@ static int interfaceNumOfDefinedInterfaces(virConnectPtr conn)
         const char *errmsg, *details;
         int errcode = ncf_error(driver->netcf, &errmsg, &details);
         interfaceReportError(netcf_to_vir_err(errcode),
-                             _("failed to get number of defined interfaces on host (netcf: %s - %s)"),
-                            errmsg, details ? details : "");
+                             _("failed to get number of defined interfaces on host: %s%s%s"),
+                             errmsg, details ? " - " : "",
+                             details ? details : "");
     }
 
     interfaceDriverUnlock(driver);
@@ -248,8 +251,9 @@ static int interfaceListDefinedInterfaces(virConnectPtr conn, char **const names
         const char *errmsg, *details;
         int errcode = ncf_error(driver->netcf, &errmsg, &details);
         interfaceReportError(netcf_to_vir_err(errcode),
-                             _("failed to list host defined interfaces (netcf: %s - %s)"),
-                            errmsg, details ? details : "");
+                             _("failed to list host defined interfaces: %s%s%s"),
+                             errmsg, details ? " - " : "",
+                             details ? details : "");
     }
 
     interfaceDriverUnlock(driver);
@@ -271,8 +275,9 @@ static virInterfacePtr interfaceLookupByName(virConnectPtr conn,
         int errcode = ncf_error(driver->netcf, &errmsg, &details);
         if (errcode != NETCF_NOERROR) {
             interfaceReportError(netcf_to_vir_err(errcode),
-                                 _("couldn't find interface named '%s' (netcf: %s - %s)"),
-                                 name, errmsg, details ? details : "");
+                                 _("couldn't find interface named '%s': %s%s%s"),
+                                 name, errmsg,
+                                 details ? " - " : "", details ? details : "");
         } else {
             interfaceReportError(VIR_ERR_NO_INTERFACE,
                                  _("couldn't find interface named '%s'"), name);
@@ -303,8 +308,9 @@ static virInterfacePtr interfaceLookupByMACString(virConnectPtr conn,
         const char *errmsg, *details;
         int errcode = ncf_error(driver->netcf, &errmsg, &details);
         interfaceReportError(netcf_to_vir_err(errcode),
-                             _("couldn't find interface with MAC address '%s' (netcf: %s - %s)"),
-                             macstr, errmsg, details ? details : "");
+                             _("couldn't find interface with MAC address '%s': %s%s%s"),
+                             macstr, errmsg, details ? " - " : "",
+                             details ? details : "");
         goto cleanup;
     }
     if (niface == 0) {
@@ -353,8 +359,9 @@ static char *interfaceGetXMLDesc(virInterfacePtr ifinfo,
         const char *errmsg, *details;
         int errcode = ncf_error(driver->netcf, &errmsg, &details);
         interfaceReportError(netcf_to_vir_err(errcode),
-                             _("could not get interface XML description (netcf: %s - %s)"),
-                             errmsg, details ? details : "");
+                             _("could not get interface XML description: %s%s%s"),
+                             errmsg, details ? " - " : "",
+                             details ? details : "");
         goto cleanup;
     }
 
@@ -407,8 +414,9 @@ static virInterfacePtr interfaceDefineXML(virConnectPtr conn,
         const char *errmsg, *details;
         int errcode = ncf_error(driver->netcf, &errmsg, &details);
         interfaceReportError(netcf_to_vir_err(errcode),
-                             _("could not get interface XML description (netcf: %s - %s)"),
-                             errmsg, details ? details : "");
+                             _("could not get interface XML description: %s%s%s"),
+                             errmsg, details ? " - " : "",
+                             details ? details : "");
         goto cleanup;
     }
 
@@ -440,8 +448,9 @@ static int interfaceUndefine(virInterfacePtr ifinfo) {
         const char *errmsg, *details;
         int errcode = ncf_error(driver->netcf, &errmsg, &details);
         interfaceReportError(netcf_to_vir_err(errcode),
-                             _("failed to undefine interface %s (netcf: %s - %s)"),
-                             ifinfo->name, errmsg, details ? details : "");
+                             _("failed to undefine interface %s: %s%s%s"),
+                             ifinfo->name, errmsg, details ? " - " : "",
+                             details ? details : "");
         goto cleanup;
     }
 
@@ -471,8 +480,9 @@ static int interfaceCreate(virInterfacePtr ifinfo,
         const char *errmsg, *details;
         int errcode = ncf_error(driver->netcf, &errmsg, &details);
         interfaceReportError(netcf_to_vir_err(errcode),
-                             _("failed to create (start) interface %s (netcf: %s - %s)"),
-                             ifinfo->name, errmsg, details ? details : "");
+                             _("failed to create (start) interface %s: %s%s%s"),
+                             ifinfo->name, errmsg, details ? " - " : "",
+                             details ? details : "");
         goto cleanup;
     }
 
@@ -502,8 +512,9 @@ static int interfaceDestroy(virInterfacePtr ifinfo,
         const char *errmsg, *details;
         int errcode = ncf_error(driver->netcf, &errmsg, &details);
         interfaceReportError(netcf_to_vir_err(errcode),
-                             _("failed to destroy (stop) interface %s (netcf: %s - %s)"),
-                             ifinfo->name, errmsg, details ? details : "");
+                             _("failed to destroy (stop) interface %s: %s%s%s"),
+                             ifinfo->name, errmsg, details ? " - " : "",
+                             details ? details : "");
         goto cleanup;
     }
 
@@ -532,8 +543,9 @@ static int interfaceIsActive(virInterfacePtr ifinfo)
         const char *errmsg, *details;
         int errcode = ncf_error(driver->netcf, &errmsg, &details);
         interfaceReportError(netcf_to_vir_err(errcode),
-                             _("failed to get status of interface %s (netcf: %s - %s)"),
-                             ifinfo->name, errmsg, details ? details : "");
+                             _("failed to get status of interface %s: %s%s%s"),
+                             ifinfo->name, errmsg, details ? " - " : "",
+                             details ? details : "");
         goto cleanup;
     }
 
@@ -560,8 +572,9 @@ static int interfaceChangeBegin(virConnectPtr conn, unsigned int flags)
         const char *errmsg, *details;
         int errcode = ncf_error(driver->netcf, &errmsg, &details);
         interfaceReportError(netcf_to_vir_err(errcode),
-                             _("failed to begin transaction: %s%s%s)"),
-                             errmsg, details ? " - " : "", details ? details : "");
+                             _("failed to begin transaction: %s%s%s"),
+                             errmsg, details ? " - " : "",
+                             details ? details : "");
     }
 
     interfaceDriverUnlock(driver);
@@ -582,8 +595,9 @@ static int interfaceChangeCommit(virConnectPtr conn, unsigned int flags)
         const char *errmsg, *details;
         int errcode = ncf_error(driver->netcf, &errmsg, &details);
         interfaceReportError(netcf_to_vir_err(errcode),
-                             _("failed to commit transaction: %s%s%s)"),
-                             errmsg, details ? " - " : "", details ? details : "");
+                             _("failed to commit transaction: %s%s%s"),
+                             errmsg, details ? " - " : "",
+                             details ? details : "");
     }
 
     interfaceDriverUnlock(driver);
@@ -604,8 +618,9 @@ static int interfaceChangeRollback(virConnectPtr conn, unsigned int flags)
         const char *errmsg, *details;
         int errcode = ncf_error(driver->netcf, &errmsg, &details);
         interfaceReportError(netcf_to_vir_err(errcode),
-                             _("failed to rollback transaction: %s%s%s)"),
-                             errmsg, details ? " - " : "", details ? details : "");
+                             _("failed to rollback transaction: %s%s%s"),
+                             errmsg, details ? " - " : "",
+                             details ? details : "");
     }
 
     interfaceDriverUnlock(driver);
-- 
1.7.3.4

--
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]