Re: [PATCH] core: log when removing devices

2014-04-07 Thread Dan Winship
On 04/04/2014 04:09 PM, Dan Williams wrote:
>  static void
>  device_removed_cb (NMDevice *device, gpointer user_data)
>  {
> - remove_device (NM_MANAGER (user_data), device, FALSE);
> + remove_device (NM_MANAGER (user_data), device, FALSE, "device request");
>  }

It might be better to add a reason string to the "removed" signal so
they can provide something more specific.

> + remove_device (self, NM_DEVICE (iter->data), FALSE, "parent 
> request");

That could also be clearer, maybe involving the parent ifname too.

-- Dan

___
networkmanager-list mailing list
networkmanager-list@gnome.org
https://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: [PATCH] core: log when removing devices

2014-04-04 Thread Thomas Haller
On Fri, 2014-04-04 at 15:09 -0500, Dan Williams wrote:
> Nothing logs when and why devices get removed, if they never
> change from the UNMANAGED state.
> 
> ---
>  src/nm-manager.c | 23 +--
>  1 file changed, 17 insertions(+), 6 deletions(-)



I like this patch


Acked-by: Thomas Haller 


signature.asc
Description: This is a digitally signed message part
___
networkmanager-list mailing list
networkmanager-list@gnome.org
https://mail.gnome.org/mailman/listinfo/networkmanager-list


[PATCH] core: log when removing devices

2014-04-04 Thread Dan Williams
Nothing logs when and why devices get removed, if they never
change from the UNMANAGED state.

---
 src/nm-manager.c | 23 +--
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/src/nm-manager.c b/src/nm-manager.c
index 9d08b89..255113c 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -127,15 +127,18 @@ static void impl_manager_get_logging (NMManager *manager,
 
 static void impl_manager_check_connectivity (NMManager *manager,
  DBusGMethodInvocation *context);
 
 #include "nm-manager-glue.h"
 
 static void add_device (NMManager *self, NMDevice *device, gboolean 
generate_con);
-static void remove_device (NMManager *self, NMDevice *device, gboolean 
quitting);
+static void remove_device (NMManager *self,
+   NMDevice *device,
+   gboolean quitting,
+   const char *reason);
 
 static void hostname_provider_init (NMHostnameProvider *provider_class);
 
 static NMActiveConnection *_new_active_connection (NMManager *self,
NMConnection *connection,
const char *specific_object,
NMDevice *device,
@@ -737,18 +740,26 @@ device_has_pending_action_changed (NMDevice *device,
GParamSpec *pspec,
NMManager *self)
 {
check_if_startup_complete (self);
 }
 
 static void
-remove_device (NMManager *manager, NMDevice *device, gboolean quitting)
+remove_device (NMManager *manager,
+   NMDevice *device,
+   gboolean quitting,
+   const char *reason)
 {
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
 
+   nm_log_info (LOGD_DEVICE,
+"(%s): removing device (%s)",
+nm_device_get_iface (device),
+reason);
+
if (nm_device_get_managed (device)) {
/* Leave configured interfaces up when quitting so they can be
 * taken over again if NM starts up, and to ensure connectivity 
while
 * NM is gone.  Assumed connections don't get taken down even 
if they
 * haven't been fully activated.
 */
 
@@ -774,15 +785,15 @@ remove_device (NMManager *manager, NMDevice *device, 
gboolean quitting)
if (priv->startup)
check_if_startup_complete (manager);
 }
 
 static void
 device_removed_cb (NMDevice *device, gpointer user_data)
 {
-   remove_device (NM_MANAGER (user_data), device, FALSE);
+   remove_device (NM_MANAGER (user_data), device, FALSE, "device request");
 }
 
 static void
 aipd_handle_event (DBusGProxy *proxy,
const char *event,
const char *iface,
const char *address,
@@ -1772,15 +1783,15 @@ add_device (NMManager *self, NMDevice *device, gboolean 
generate_con)
 */
for (iter = priv->devices; iter; iter = iter->next) {
iface = nm_device_get_ip_iface (iter->data);
if (nm_device_owns_iface (device, iface))
remove = g_slist_prepend (remove, iter->data);
}
for (iter = remove; iter; iter = iter->next)
-   remove_device (self, NM_DEVICE (iter->data), FALSE);
+   remove_device (self, NM_DEVICE (iter->data), FALSE, "parent 
request");
g_slist_free (remove);
 
priv->devices = g_slist_append (priv->devices, g_object_ref (device));
 
g_signal_connect (device, "state-changed",
  G_CALLBACK (manager_device_state_changed),
  self);
@@ -2203,15 +2214,15 @@ platform_link_removed_cb (NMPlatform *platform,
   gpointer user_data)
 {
NMManager *self = NM_MANAGER (user_data);
NMDevice *device;
 
device = find_device_by_ifindex (self, ifindex);
if (device)
-   remove_device (self, device, FALSE);
+   remove_device (self, device, FALSE, "link removed");
 }
 
 static void
 rfkill_manager_rfkill_changed_cb (NMRfkillManager *rfkill_mgr,
   RfKillType rtype,
   RfKillState udev_state,
   gpointer user_data)
@@ -4969,15 +4980,15 @@ dispose (GObject *object)
g_slist_free_full (priv->auth_chains, (GDestroyNotify) 
nm_auth_chain_unref);
priv->auth_chains = NULL;
 
nm_auth_changed_func_unregister (authority_changed_cb, manager);
 
/* Remove all devices */
while (priv->devices)
-   remove_device (manager, NM_DEVICE (priv->devices->data), TRUE);
+   remove_device (manager, NM_DEVICE (priv->devices->data), TRUE, 
"quitting");
 
if (priv->ac_cleanup_id) {
g_source_r