CP-1711: Add kernel cmdline option no-dm-multipath-root to disable multipathing

If this option is present on the kernel command line then the initrd will not
create the multipath device mapper node and a normal single path boot will occur.

This option is being added just in case there is an issue with multipathing on 
particular hardware which could cause the host to fail to boot following an upgrade
that multipaths the root disk.

diff -ur mkinitrd-5.1.19.6.orig/nash/nash.c mkinitrd-5.1.19.6/nash/nash.c
--- mkinitrd-5.1.19.6.orig/nash/nash.c	2010-07-08 09:07:36.000000000 -0400
+++ mkinitrd-5.1.19.6/nash/nash.c	2010-07-08 09:10:44.000000000 -0400
@@ -1565,6 +1565,29 @@
     return nashMkPathBySpec(_nash_context, root, "/dev/root") < 0 ? 1 : 0;
 }
 
+/* XenServer: "hasKernArg" returns 0 if <arg> appears in /proc/cmdline.
+ * We can use this along with "cond" to make lines in /init conditional
+ * on the presence of switches in the kernel command line.
+ * In particular we can use this to turn off the dm-multipath node creation
+ * if there is a problem booting a dm-multipath root disk.
+ */
+static int
+hasKernArgCommand(char * cmd, char *end)
+{
+   char *arg;
+   if (!(cmd = getArg(cmd, end, &arg))) {
+        eprintf(
+            "usage: hasKernArg <arg>\n");
+        return 1;
+   }
+
+   if (getKernelArg(arg) == NULL)
+	   return 1;
+
+   /* arg is in kernel command line */
+   return 0;
+}
+
 /* XenServer: getrootwwid finds a slave device using the
  * root=LABEL or root=UUID option on the kernel command line,
  * and then uses /sbin/scsi_id to translate this into a multipath-tools
@@ -2671,6 +2694,7 @@
     { "mkdmnod", mkDMNodCommand },
     { "mknod", mknodCommand },
     { "mkrootdev", mkrootdevCommand },
+    { "hasKernArg", hasKernArgCommand },
     { "getrootwwid", getrootwwidCommand },
     { "mount", mountCommand },
     { "netname", netnameCommand },
--- mkinitrd-5.1.19.6/mkinitrd.orig	2010-07-12 06:38:53.000000000 -0400
+++ mkinitrd-5.1.19.6/mkinitrd	2010-07-12 06:41:24.000000000 -0400
@@ -1998,7 +1998,13 @@
     # kernel command line, and then uses /sbin/scsi_id to translate
     # this into a multipath-tools World Wide IDentifier.
     # The wwid is then appended to the callback command and exec'd.
-    emit "getrootwwid --exec '/sbin/multipath -v 0 '"
+    #
+    # hasKernArg is a nash extension that tests for the presence of
+    # a kernel command line arg.  Here we are using it to ensure
+    # that we do not create the device mapper multipath node if 
+    # no-dm-multipath-root is on the kernel command line
+    emit "hasKernArg no-dm-multipath-root"
+    emit "cond -ne 0 getrootwwid --exec '/sbin/multipath -v 0 '"
 
     emit "dmsetup ls --target multipath --exec 'kpartx -a -p p'"
 fi
