[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [PATCH rhel6-branch 10/11] Make kickstart network command reconfigure device in installer (#668395)



On 01/14/2011 02:33 AM, Chris Lumens wrote:
@@ -2181,4 +2229,80 @@ int wait_for_iface_activation(char *ifname) {
      return 3;
  }

+/*
+ * Wait for disconnection of iface by NetworkManager, return non-zero on error.
+ */
+int wait_for_iface_disconnection(char *ifname) {
...
+    devices = nm_client_get_devices(client);
+    for (i = 0; i<  devices->len; i++) {
+        NMDevice *candidate = g_ptr_array_index(devices, i);
+        const char *name = nm_device_get_iface(candidate);
+        if (!strcmp(name, ifname)) {
+            device = candidate;
+            break;
+        }
+    }
+    if (device == NULL) {
+        logMessage(ERROR, "%s (%d): network device %s not found",
+                   __func__, __LINE__, ifname);
+        g_object_unref(client);
+        return 3;
+    }
I've seen this same idiom in a couple places now, so it really seems
like the sort of thing that could get turned into a function.


It is only in wait_for_iface_activation. The wait_for_iface_disconnection
I added in this patch is actually only modified wait_for_iface_activation
(no UI message, shorter time-out, different log message). The idea of
consolidating the functions or code within popped in my mind,
but I considered it not worth it. I'd reconsider it next time when we
have 3 instances (I couldn't have imagined any third use case at that
moment).

Also, don't you need to free devices somewhere?  It doesn't appear we do
anywhere else in anaconda, though, so maybe not.  I'm not sure how
nm_client_get_devices behaves.


The array is owned by the client, so I should not. I must admit
that I just did it the way it had been done in anaconda so far
(which is correct in this point).


Radek


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]