[PATCH v2] core: log when removing devices
- From: Dan Williams <dcbw redhat com>
- To: Dan Winship <danw gnome org>
- Cc: Network Manager <networkmanager-list gnome org>
- Subject: [PATCH v2] core: log when removing devices
- Date: Mon, 07 Apr 2014 14:46:03 -0500
From 9ec0f07d14937e199c977a3c9782f8d79cc456d9 Mon Sep 17 00:00:00 2001
From: Dan Williams <dcbw redhat com>
Date: Fri, 4 Apr 2014 15:09:45 -0500
Subject: [PATCH] core: log when removing devices
Nothing logs when and why devices get removed, if they never
change from the UNMANAGED state.
---
src/devices/adsl/nm-atm-manager.c | 3 ++-
src/devices/bluetooth/nm-device-bt.c | 2 +-
src/devices/nm-device-private.h | 2 ++
src/devices/nm-device.c | 9 ++++++++-
src/devices/wwan/nm-device-modem.c | 2 +-
src/nm-manager.c | 35 ++++++++++++++++++++++++++---------
6 files changed, 40 insertions(+), 13 deletions(-)
diff --git a/src/devices/adsl/nm-atm-manager.c b/src/devices/adsl/nm-atm-manager.c
index 908e961..14bc2bd 100644
--- a/src/devices/adsl/nm-atm-manager.c
+++ b/src/devices/adsl/nm-atm-manager.c
@@ -24,14 +24,15 @@
#include <gudev/gudev.h>
#include <gmodule.h>
#include "nm-atm-manager.h"
#include "nm-device-adsl.h"
#include "nm-device-factory.h"
#include "nm-logging.h"
+#include "nm-device-private.h"
typedef struct {
GUdevClient *client;
GSList *devices;
guint start_id;
} NMAtmManagerPrivate;
@@ -160,15 +161,15 @@ adsl_remove (NMAtmManager *self, GUdevDevice *udev_device)
* NAS bridge interface or PPPoE interface.
*/
if (g_strcmp0 (nm_device_get_iface (device), iface) != 0)
continue;
g_object_weak_unref (G_OBJECT (iter->data), device_destroyed, self);
priv->devices = g_slist_remove (priv->devices, device);
- g_signal_emit_by_name (device, NM_DEVICE_REMOVED);
+ nm_device_emit_removed (device, "kernel device removed");
break;
}
}
static gboolean
query_devices (NMAtmManager *self)
{
diff --git a/src/devices/bluetooth/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c
index 6998bb1..589fffb 100644
--- a/src/devices/bluetooth/nm-device-bt.c
+++ b/src/devices/bluetooth/nm-device-bt.c
@@ -925,15 +925,15 @@ deactivate (NMDevice *device)
if (NM_DEVICE_CLASS (nm_device_bt_parent_class)->deactivate)
NM_DEVICE_CLASS (nm_device_bt_parent_class)->deactivate (device);
}
static void
bluez_device_removed (NMBluezDevice *bdev, gpointer user_data)
{
- g_signal_emit_by_name (NM_DEVICE_BT (user_data), NM_DEVICE_REMOVED);
+ nm_device_emit_removed (NM_DEVICE (user_data), "bluez device removed");
}
/*****************************************************************************/
static gboolean
is_available (NMDevice *dev)
{
diff --git a/src/devices/nm-device-private.h b/src/devices/nm-device-private.h
index 8dae02e..40e2486 100644
--- a/src/devices/nm-device-private.h
+++ b/src/devices/nm-device-private.h
@@ -94,8 +94,10 @@ NMDevice *nm_device_master_get_slave_by_ifindex (NMDevice *dev, int ifindex);
void nm_device_master_check_slave_physical_port (NMDevice *dev, NMDevice *slave,
guint64 log_domain);
void nm_device_set_carrier (NMDevice *device, gboolean carrier);
void nm_device_emit_recheck_auto_activate (NMDevice *device);
+void nm_device_emit_removed (NMDevice *device, const char *reason);
+
#endif /* NM_DEVICE_PRIVATE_H */
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 817b924..bc290ff 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -2018,14 +2018,20 @@ nm_device_can_assume_connections (NMDevice *device)
void
nm_device_emit_recheck_auto_activate (NMDevice *self)
{
g_signal_emit (self, signals[RECHECK_AUTO_ACTIVATE], 0);
}
+void
+nm_device_emit_removed (NMDevice *device, const char *reason)
+{
+ g_signal_emit (device, signals[REMOVED], 0, reason);
+}
+
static void
dnsmasq_state_changed_cb (NMDnsMasqManager *manager, guint32 status, gpointer user_data)
{
NMDevice *self = NM_DEVICE (user_data);
switch (status) {
case NM_DNSMASQ_STATUS_DEAD:
@@ -6360,15 +6366,16 @@ nm_device_class_init (NMDeviceClass *klass)
G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_OBJECT);
signals[REMOVED] =
g_signal_new (NM_DEVICE_REMOVED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0, NULL, NULL, NULL,
- G_TYPE_NONE, 0);
+ G_TYPE_NONE, 1,
+ G_TYPE_STRING); /* reason */
signals[RECHECK_AUTO_ACTIVATE] =
g_signal_new (NM_DEVICE_RECHECK_AUTO_ACTIVATE,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0, NULL, NULL, NULL,
G_TYPE_NONE, 0);
diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c
index 39cc06f..b899380 100644
--- a/src/devices/wwan/nm-device-modem.c
+++ b/src/devices/wwan/nm-device-modem.c
@@ -196,15 +196,15 @@ modem_connected_cb (NMModem *modem, GParamSpec *pspec, gpointer user_data)
nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_FAILED,
NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER);
}
}
static void
modem_removed_cb (NMModem *modem, gpointer user_data)
{
- g_signal_emit_by_name (NM_DEVICE (user_data), NM_DEVICE_REMOVED);
+ nm_device_emit_removed (NM_DEVICE (user_data), "modem removed");
}
/*****************************************************************************/
NMModem *
nm_device_modem_get_modem (NMDeviceModem *self)
{
diff --git a/src/nm-manager.c b/src/nm-manager.c
index ea0663f..903357d 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.
*/
@@ -772,17 +783,17 @@ remove_device (NMManager *manager, NMDevice *device, gboolean quitting)
g_object_unref (device);
if (priv->startup)
check_if_startup_complete (manager);
}
static void
-device_removed_cb (NMDevice *device, gpointer user_data)
+device_removed_cb (NMDevice *device, const char *reason, gpointer user_data)
{
- remove_device (NM_MANAGER (user_data), device, FALSE);
+ remove_device (NM_MANAGER (user_data), device, FALSE, reason);
}
static void
aipd_handle_event (DBusGProxy *proxy,
const char *event,
const char *iface,
const char *address,
@@ -1773,17 +1784,23 @@ add_device (NMManager *self, NMDevice *device, gboolean generate_con)
* the child NMDevice entirely
*/
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);
- g_slist_free (remove);
+ if (remove) {
+ char *reason = g_strdup_printf ("child of %s", nm_device_get_iface (device));
+
+ for (iter = remove; iter; iter = iter->next)
+ remove_device (self, NM_DEVICE (iter->data), FALSE, reason);
+
+ g_free (reason);
+ 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);
@@ -2212,15 +2229,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)
@@ -4972,15 +4989,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_remove (priv->ac_cleanup_id);
priv->ac_cleanup_id = 0;
}
while (priv->active_connections)
--
1.9.0
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]