core: show better error for software device creation failures (rh #1182923)
https://bugzilla.redhat.com/show_bug.cgi?id=1182923
This commit is contained in:
@@ -1028,6 +1028,7 @@ get_virtual_iface_name (NMManager *self,
|
|||||||
* system_create_virtual_device:
|
* system_create_virtual_device:
|
||||||
* @self: the #NMManager
|
* @self: the #NMManager
|
||||||
* @connection: the connection which might require a virtual device
|
* @connection: the connection which might require a virtual device
|
||||||
|
* @error: the error set when return value is NULL
|
||||||
*
|
*
|
||||||
* If @connection requires a virtual device and one does not yet exist for it,
|
* If @connection requires a virtual device and one does not yet exist for it,
|
||||||
* creates that device.
|
* creates that device.
|
||||||
@@ -1035,19 +1036,27 @@ get_virtual_iface_name (NMManager *self,
|
|||||||
* Returns: the #NMDevice if successfully created, %NULL if not
|
* Returns: the #NMDevice if successfully created, %NULL if not
|
||||||
*/
|
*/
|
||||||
static NMDevice *
|
static NMDevice *
|
||||||
system_create_virtual_device (NMManager *self, NMConnection *connection)
|
system_create_virtual_device (NMManager *self, NMConnection *connection, GError **error)
|
||||||
{
|
{
|
||||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
||||||
GError *error = NULL;
|
GError *local_err = NULL;
|
||||||
GSList *iter;
|
GSList *iter;
|
||||||
char *iface = NULL;
|
char *iface = NULL;
|
||||||
NMDevice *device = NULL, *parent = NULL;
|
NMDevice *device = NULL, *parent = NULL;
|
||||||
gboolean nm_owned = FALSE;
|
gboolean nm_owned = FALSE;
|
||||||
|
|
||||||
|
g_return_val_if_fail (NM_IS_MANAGER (self), NULL);
|
||||||
|
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||||
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||||
|
|
||||||
iface = get_virtual_iface_name (self, connection, &parent);
|
iface = get_virtual_iface_name (self, connection, &parent);
|
||||||
if (!iface) {
|
if (!iface) {
|
||||||
nm_log_dbg (LOGD_DEVICE, "(%s) failed to determine virtual interface name",
|
nm_log_dbg (LOGD_DEVICE, "(%s) failed to determine virtual interface name",
|
||||||
nm_connection_get_id (connection));
|
nm_connection_get_id (connection));
|
||||||
|
g_set_error_literal (error,
|
||||||
|
NM_MANAGER_ERROR,
|
||||||
|
NM_MANAGER_ERROR_FAILED,
|
||||||
|
"failed to determine virtual interface name");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1056,9 +1065,16 @@ system_create_virtual_device (NMManager *self, NMConnection *connection)
|
|||||||
NMDevice *candidate = iter->data;
|
NMDevice *candidate = iter->data;
|
||||||
|
|
||||||
if ( g_strcmp0 (nm_device_get_iface (candidate), iface) == 0
|
if ( g_strcmp0 (nm_device_get_iface (candidate), iface) == 0
|
||||||
|| nm_device_check_connection_compatible (candidate, connection))
|
|| nm_device_check_connection_compatible (candidate, connection)) {
|
||||||
|
nm_log_dbg (LOGD_DEVICE, "(%s) already created virtual interface name %s",
|
||||||
|
nm_connection_get_id (connection), iface);
|
||||||
|
g_set_error (error,
|
||||||
|
NM_MANAGER_ERROR,
|
||||||
|
NM_MANAGER_ERROR_FAILED,
|
||||||
|
"interface name '%s' already created", iface);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Block notification of link added since we're creating the device
|
/* Block notification of link added since we're creating the device
|
||||||
* explicitly here, otherwise adding the platform/kernel device would
|
* explicitly here, otherwise adding the platform/kernel device would
|
||||||
@@ -1072,14 +1088,15 @@ system_create_virtual_device (NMManager *self, NMConnection *connection)
|
|||||||
device = nm_device_factory_create_virtual_device_for_connection (NM_DEVICE_FACTORY (iter->data),
|
device = nm_device_factory_create_virtual_device_for_connection (NM_DEVICE_FACTORY (iter->data),
|
||||||
connection,
|
connection,
|
||||||
parent,
|
parent,
|
||||||
&error);
|
&local_err);
|
||||||
if (device || error) {
|
if (device || local_err) {
|
||||||
if (device)
|
if (device)
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (local_err);
|
||||||
else {
|
else {
|
||||||
nm_log_err (LOGD_DEVICE, "(%s) failed to create virtual device: %s",
|
nm_log_err (LOGD_DEVICE, "(%s) failed to create virtual device: %s",
|
||||||
nm_connection_get_id (connection), error ? error->message : "(unknown error)");
|
nm_connection_get_id (connection),
|
||||||
g_clear_error (&error);
|
local_err ? local_err->message : "(unknown error)");
|
||||||
|
g_propagate_error (error, local_err);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1095,6 +1112,16 @@ system_create_virtual_device (NMManager *self, NMConnection *connection)
|
|||||||
add_device (self, device, !nm_owned);
|
add_device (self, device, !nm_owned);
|
||||||
|
|
||||||
g_object_unref (device);
|
g_object_unref (device);
|
||||||
|
} else {
|
||||||
|
if (error && !*error)
|
||||||
|
nm_log_err (LOGD_DEVICE, "(%s:%s) NetworkManager plugin for '%s' unavailable",
|
||||||
|
nm_connection_get_id (connection), iface,
|
||||||
|
nm_connection_get_connection_type (connection));
|
||||||
|
g_set_error (error,
|
||||||
|
NM_MANAGER_ERROR,
|
||||||
|
NM_MANAGER_ERROR_FAILED,
|
||||||
|
"NetworkManager plugin for '%s' unavailable",
|
||||||
|
nm_connection_get_connection_type (connection));
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->ignore_link_added_cb--;
|
priv->ignore_link_added_cb--;
|
||||||
@@ -1119,7 +1146,7 @@ system_create_virtual_devices (NMManager *self)
|
|||||||
/* We only create a virtual interface if the connection can autoconnect */
|
/* We only create a virtual interface if the connection can autoconnect */
|
||||||
if ( nm_connection_is_virtual (connection)
|
if ( nm_connection_is_virtual (connection)
|
||||||
&& nm_settings_connection_can_autoconnect (NM_SETTINGS_CONNECTION (connection)))
|
&& nm_settings_connection_can_autoconnect (NM_SETTINGS_CONNECTION (connection)))
|
||||||
system_create_virtual_device (self, connection);
|
system_create_virtual_device (self, connection, NULL);
|
||||||
}
|
}
|
||||||
g_slist_free (connections);
|
g_slist_free (connections);
|
||||||
}
|
}
|
||||||
@@ -1136,7 +1163,7 @@ connection_added (NMSettings *settings,
|
|||||||
|
|
||||||
g_assert (s_con);
|
g_assert (s_con);
|
||||||
if (nm_setting_connection_get_autoconnect (s_con))
|
if (nm_setting_connection_get_autoconnect (s_con))
|
||||||
system_create_virtual_device (manager, connection);
|
system_create_virtual_device (manager, connection, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2608,6 +2635,7 @@ _internal_activate_device (NMManager *self, NMActiveConnection *active, GError *
|
|||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
NMConnection *master_connection = NULL;
|
NMConnection *master_connection = NULL;
|
||||||
NMActiveConnection *master_ac = NULL;
|
NMActiveConnection *master_ac = NULL;
|
||||||
|
GError *local_err = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (NM_IS_MANAGER (self), FALSE);
|
g_return_val_if_fail (NM_IS_MANAGER (self), FALSE);
|
||||||
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (active), FALSE);
|
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (active), FALSE);
|
||||||
@@ -2632,12 +2660,14 @@ _internal_activate_device (NMManager *self, NMActiveConnection *active, GError *
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
device = system_create_virtual_device (self, connection);
|
device = system_create_virtual_device (self, connection, &local_err);
|
||||||
if (!device) {
|
if (!device) {
|
||||||
g_set_error_literal (error,
|
g_set_error (error,
|
||||||
NM_MANAGER_ERROR,
|
NM_MANAGER_ERROR,
|
||||||
NM_MANAGER_ERROR_UNKNOWN_DEVICE,
|
NM_MANAGER_ERROR_UNKNOWN_DEVICE,
|
||||||
"Failed to create virtual interface");
|
"Failed to create virtual interface: %s",
|
||||||
|
local_err ? local_err->message : "(unknown)");
|
||||||
|
g_clear_error (&local_err);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user