[libvirt] [PATCH v2] interface: report generic error message of lookup failure

Guannan Ren gren at redhat.com
Wed May 15 00:16:26 UTC 2013


"couldn't find interface named"
"couldn't find interface with MAC address"

use generic message as follows
"couldn't find interface with"
---
 src/interface/interface_backend_netcf.c | 16 ++++++++--------
 src/interface/interface_backend_udev.c  |  8 ++++----
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interface_backend_netcf.c
index cbba4fd..c6f3f42 100644
--- a/src/interface/interface_backend_netcf.c
+++ b/src/interface/interface_backend_netcf.c
@@ -104,12 +104,12 @@ static struct netcf_if *interfaceDriverGetNetcfIF(struct netcf *ncf, virInterfac
         int errcode = ncf_error(ncf, &errmsg, &details);
         if (errcode != NETCF_NOERROR) {
             virReportError(netcf_to_vir_err(errcode),
-                           _("couldn't find interface named '%s': %s%s%s"),
+                           _("couldn't find interface with '%s': %s%s%s"),
                            ifinfo->name, errmsg, details ? " - " : "",
                            details ? details : "");
         } else {
             virReportError(VIR_ERR_NO_INTERFACE,
-                           _("couldn't find interface named '%s'"),
+                           _("couldn't find interface with '%s'"),
                            ifinfo->name);
         }
     }
@@ -334,7 +334,7 @@ netcfConnectListAllInterfaces(virConnectPtr conn,
             int errcode = ncf_error(driver->netcf, &errmsg, &details);
             if (errcode != NETCF_NOERROR) {
                 virReportError(netcf_to_vir_err(errcode),
-                               _("couldn't find interface named '%s': %s%s%s"),
+                               _("couldn't find interface with '%s': %s%s%s"),
                                names[i], errmsg,
                                details ? " - " : "", details ? details : "");
                 goto cleanup;
@@ -342,7 +342,7 @@ netcfConnectListAllInterfaces(virConnectPtr conn,
                 /* Ignore the NETCF_NOERROR, as the interface is very likely
                  * deleted by other management apps (e.g. virt-manager).
                  */
-                VIR_WARN("couldn't find interface named '%s', might be "
+                VIR_WARN("couldn't find interface with '%s', might be "
                          "deleted by other process", names[i]);
                 continue;
             }
@@ -421,12 +421,12 @@ static virInterfacePtr netcfInterfaceLookupByName(virConnectPtr conn,
         int errcode = ncf_error(driver->netcf, &errmsg, &details);
         if (errcode != NETCF_NOERROR) {
             virReportError(netcf_to_vir_err(errcode),
-                           _("couldn't find interface named '%s': %s%s%s"),
+                           _("couldn't find interface with '%s': %s%s%s"),
                            name, errmsg,
                            details ? " - " : "", details ? details : "");
         } else {
             virReportError(VIR_ERR_NO_INTERFACE,
-                           _("couldn't find interface named '%s'"), name);
+                           _("couldn't find interface with '%s'"), name);
         }
         goto cleanup;
     }
@@ -454,14 +454,14 @@ static virInterfacePtr netcfInterfaceLookupByMACString(virConnectPtr conn,
         const char *errmsg, *details;
         int errcode = ncf_error(driver->netcf, &errmsg, &details);
         virReportError(netcf_to_vir_err(errcode),
-                       _("couldn't find interface with MAC address '%s': %s%s%s"),
+                       _("couldn't find interface with '%s': %s%s%s"),
                        macstr, errmsg, details ? " - " : "",
                        details ? details : "");
         goto cleanup;
     }
     if (niface == 0) {
         virReportError(VIR_ERR_NO_INTERFACE,
-                       _("couldn't find interface with MAC address '%s'"),
+                       _("couldn't find interface with '%s'"),
                        macstr);
         goto cleanup;
     }
diff --git a/src/interface/interface_backend_udev.c b/src/interface/interface_backend_udev.c
index 1fd7d46..e61be52 100644
--- a/src/interface/interface_backend_udev.c
+++ b/src/interface/interface_backend_udev.c
@@ -420,7 +420,7 @@ udevInterfaceLookupByName(virConnectPtr conn, const char *name)
     dev = udev_device_new_from_subsystem_sysname(udev, "net", name);
     if (!dev) {
         virReportError(VIR_ERR_NO_INTERFACE,
-                       _("couldn't find interface named '%s'"),
+                       _("couldn't find interface with '%s'"),
                        name);
         goto cleanup;
     }
@@ -467,7 +467,7 @@ udevInterfaceLookupByMACString(virConnectPtr conn, const char *macstr)
     /* Check that we got something back */
     if (!dev_entry) {
         virReportError(VIR_ERR_NO_INTERFACE,
-                       _("couldn't find interface with MAC address '%s'"),
+                       _("couldn't find interface with '%s'"),
                        macstr);
         goto cleanup;
     }
@@ -940,7 +940,7 @@ udevGetIfaceDef(struct udev *udev, const char *name)
     dev = udev_device_new_from_subsystem_sysname(udev, "net", name);
     if (!dev) {
         virReportError(VIR_ERR_NO_INTERFACE,
-                       _("couldn't find interface named '%s'"), name);
+                       _("couldn't find interface with '%s'"), name);
         goto error;
     }
 
@@ -1068,7 +1068,7 @@ udevInterfaceIsActive(virInterfacePtr ifinfo)
                                                  ifinfo->name);
     if (!dev) {
         virReportError(VIR_ERR_NO_INTERFACE,
-                       _("couldn't find interface named '%s'"),
+                       _("couldn't find interface with '%s'"),
                        ifinfo->name);
         status = -1;
         goto cleanup;
-- 
1.8.1.4




More information about the libvir-list mailing list