From 9d0e8e851fd69b1c5d258291e8f3182ee424f53e Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 29 Aug 2019 16:45:12 +0200 Subject: [PATCH 1/2] device: don't set nm-owned flag if realize() fails The nm-owned flag indicates whether the device was created by NM. If the realization step fails, the device was not created and so nm-owned should not be updated. (cherry picked from commit 4bc415642495a492aba2eccfc3e16b1da34df287) --- src/devices/nm-device.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index f07c4f09a5..823cf48a53 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -4151,11 +4151,12 @@ nm_device_create_and_realize (NMDevice *self, nm_auto_nmpobj const NMPObject *plink_keep_alive = NULL; NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); const NMPlatformLink *plink; + gboolean nm_owned; /* Must be set before device is realized */ plink = nm_platform_link_get_by_ifname (nm_device_get_platform (self), priv->iface); - priv->nm_owned = !plink || !link_type_compatible (self, plink->type, NULL, NULL); - _LOGD (LOGD_DEVICE, "create (is %snm-owned)", priv->nm_owned ? "" : "not "); + nm_owned = !plink || !link_type_compatible (self, plink->type, NULL, NULL); + _LOGD (LOGD_DEVICE, "create (is %snm-owned)", nm_owned ? "" : "not "); plink = NULL; /* Create any resources the device needs */ @@ -4168,6 +4169,8 @@ nm_device_create_and_realize (NMDevice *self, } } + priv->nm_owned = nm_owned; + realize_start_setup (self, plink, FALSE, /* assume_state_guess_assume */ From 5d45ac0650d806b92b5bdb10e251f307e1b5e5a2 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 29 Aug 2019 16:46:33 +0200 Subject: [PATCH 2/2] manager: keep device if realize() fails system_create_virtual_device() first creates the device (unrealized) and then, if there a connection for the device with autoconnect=yes, creates the backing resources. If this last step fails the device should continue to exist, even if in an unrealized state. https://bugzilla.redhat.com/show_bug.cgi?id=1686634 (cherry picked from commit f07aa329b20544c8ae2885c6a468e5670b687397) --- src/nm-manager.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/nm-manager.c b/src/nm-manager.c index 64cdb9aed2..869ae94ae6 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -2032,7 +2032,6 @@ system_create_virtual_device (NMManager *self, NMConnection *connection) "couldn't create the device: %s", error->message); g_error_free (error); - remove_device (self, device, FALSE); return NULL; }