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

[PATCH rhel6-branch] Do not activate first ks network device in non-network installs.



To resotre rhel5 behaviour ... one more case found:
for media (non-network) installs kickstart network command should
not bring network up.

Related: rhbz#638131
---
 loader/kickstart.c |   14 ++++----------
 loader/kickstart.h |    2 +-
 loader/loader.c    |    6 ++++--
 loader/net.c       |   27 ++++++++++++++++++++++++---
 loader/net.h       |    1 +
 5 files changed, 34 insertions(+), 16 deletions(-)

diff --git a/loader/kickstart.c b/loader/kickstart.c
index b418d74..3007f86 100644
--- a/loader/kickstart.c
+++ b/loader/kickstart.c
@@ -370,13 +370,7 @@ int isKickstartFileRemote(char *ksFile) {
         location = ksFile + 3;
     }
 
-    if (!strncmp(location, "http", 4) ||
-        !strncmp(location, "ftp://";, 6) ||
-        !strncmp(location, "nfs:", 4)) {
-        return 1;
-    } else {
-        return 0;
-    }
+    return isURLRemote(location);
 }
 
 void getKickstartFile(struct loaderData_s *loaderData) {
@@ -543,16 +537,16 @@ static void setMediaCheck(struct loaderData_s * loaderData, int argc,
     return;
 }
 
-void addActivateToFirstKsNetworkCommand() {
+void markFirstKsNetworkCommand() {
     int i = 0;
 
     for (i = 0; i < numCommands; i++) {
         if (commands[i].code == KS_CMD_NETWORK) {
-            logMessage(INFO, "adding --activate to first kickstart network command");
+            logMessage(DEBUGLVL, "marking first kickstart network command");
             commands[i].argc++;
             commands[i].argv = g_realloc(commands[i].argv,
                     sizeof(gchar *) * (commands[i].argc + 1));
-            commands[i].argv[commands[i].argc -1] = "--activate";
+            commands[i].argv[commands[i].argc -1] = "--firstnetdev";
             commands[i].argv[commands[i].argc] = NULL;
             break;
         }
diff --git a/loader/kickstart.h b/loader/kickstart.h
index 2a3b334..24612cf 100644
--- a/loader/kickstart.h
+++ b/loader/kickstart.h
@@ -50,6 +50,6 @@ int isKickstartFileRemote(char *ksFile);
 void getKickstartFile(struct loaderData_s * loaderData);
 void runKickstart(struct loaderData_s * loaderData);
 int getKickstartFromBlockDevice(char *device, char *path);
-void addActivateToFirstKsNetworkCommand();
+void markFirstKsNetworkCommand();
 
 #endif
diff --git a/loader/loader.c b/loader/loader.c
index ac289a5..0154ce0 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -1521,7 +1521,7 @@ static char *doLoaderMain(struct loaderData_s *loaderData,
 
             case STEP_NETWORK: {
                 if (((installMethods[validMethods[loaderData->method]].type !=
-                       DEVICE_NETWORK) && (!hasGraphicalOverride()) &&
+                       DEVICE_NETWORK) &&
                       !FL_ASKNETWORK(flags) &&
                       !FL_EARLY_NETWORKING(flags) && 
                       !ibft_present()) ||
@@ -2049,6 +2049,8 @@ int main(int argc, char ** argv) {
         logMessage(INFO, "text mode forced due to serial/virtpconsole");
         flags |= LOADER_FLAGS_TEXT;
     }
+    if (hasGraphicalOverride())
+        flags |= LOADER_FLAGS_EARLY_NETWORKING;
     set_fw_search_path(&loaderData, "/firmware:/lib/firmware");
     start_fw_loader(&loaderData);
 
@@ -2238,7 +2240,7 @@ int main(int argc, char ** argv) {
             getKickstartFile(&loaderData);
         if (FL_KICKSTART(flags) && 
             (ksReadCommands((ksFile)?ksFile:loaderData.ksFile)!=LOADER_ERROR)) {
-            addActivateToFirstKsNetworkCommand();
+            markFirstKsNetworkCommand();
             runKickstart(&loaderData);
         }
     }
diff --git a/loader/net.c b/loader/net.c
index 5a09ef9..1531d4f 100644
--- a/loader/net.c
+++ b/loader/net.c
@@ -1524,7 +1524,7 @@ void setKickstartNetwork(struct loaderData_s * loaderData, int argc,
     gchar *bootProto = NULL, *device = NULL, *class = NULL, *ethtool = NULL;
     gchar *essid = NULL, *wepkey = NULL, *onboot = NULL, *gateway = NULL;
     gint mtu = 1500, dhcpTimeout = -1;
-    gboolean noipv4 = FALSE, noipv6 = FALSE, noDns = FALSE, noksdev = FALSE, activate = FALSE, nodefroute=FALSE;
+    gboolean noipv4 = FALSE, noipv6 = FALSE, noDns = FALSE, noksdev = FALSE, activate = FALSE, nodefroute=FALSE, firstnetdev=FALSE;
     GOptionContext *optCon = g_option_context_new(NULL);
     GError *optErr = NULL;
     struct in_addr addr;
@@ -1558,6 +1558,7 @@ void setKickstartNetwork(struct loaderData_s * loaderData, int argc,
         { "onboot", 0, 0, G_OPTION_ARG_STRING, &onboot, NULL, NULL },
         { "notksdevice", 0, 0, G_OPTION_ARG_NONE, &noksdev, NULL, NULL },
         { "activate", 0, 0, G_OPTION_ARG_NONE, &activate, NULL, NULL },
+        { "firstnetdev", 0, 0, G_OPTION_ARG_NONE, &firstnetdev, NULL, NULL },
         { "nodefroute", 0, 0, G_OPTION_ARG_NONE, &nodefroute, NULL, NULL },
         { "dhcptimeout", 0, 0, G_OPTION_ARG_INT, &dhcpTimeout, NULL, NULL },
         { NULL },
@@ -1712,8 +1713,13 @@ void setKickstartNetwork(struct loaderData_s * loaderData, int argc,
         iface.defroute = 0;
     }
 
-    if (!is_nm_connected()) {
-        logMessage(INFO, "activating because no network connection is available");
+    if (firstnetdev &&
+        (loaderData->method == METHOD_URL ||
+         loaderData->method == METHOD_NFS ||
+         isURLRemote(loaderData->instRepo) ||
+         FL_EARLY_NETWORKING(flags) ||
+         ibft_present())) {
+        logMessage(INFO, "activating first device from kickstart because network is needed");
         activateDevice(loaderData, &iface);
         return;
     }
@@ -2329,4 +2335,19 @@ int wait_for_iface_disconnection(char *ifname) {
     g_object_unref(client);
     return 3;
 }
+
+int isURLRemote(char *url) {
+    if (url == NULL) {
+        return 0;
+    }
+
+    if (!strncmp(url, "http", 4) ||
+        !strncmp(url, "ftp://";, 6) ||
+        !strncmp(url, "nfs:", 4)) {
+        return 1;
+    } else {
+        return 0;
+    }
+}
+
 /* vim:set shiftwidth=4 softtabstop=4: */
diff --git a/loader/net.h b/loader/net.h
index 308a116..a737e0c 100644
--- a/loader/net.h
+++ b/loader/net.h
@@ -82,5 +82,6 @@ int disconnectDevice(char *device);
 void splitHostname (char *str, char **host, char **port);
 int wait_for_iface_activation(char * ifname);
 int wait_for_iface_disconnection(char *ifname);
+int isURLRemote(char *url);
 
 #endif
-- 
1.7.2


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