changeset 13656:57f5c4bc231c

2085 with lots of zones, sometimes all of them don't boot on system boot Reviewed by: Robert Mustacchi <rm@joyent.com> Reviewed by: Gordon Ross <gordon.w.ross@gmail.com> Approved by: Richard Lowe <richlowe@richlowe.net>
author Jerry Jelinek <jerry.jelinek@joyent.com>
date Sat, 31 Mar 2012 22:09:43 -0400
parents 0461a7e94e53
children 5f6ef8da78ee
files usr/src/cmd/zoneadmd/zcons.c
diffstat 1 files changed, 19 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/zoneadmd/zcons.c	Sun Apr 01 21:19:32 2012 +0200
+++ b/usr/src/cmd/zoneadmd/zcons.c	Sat Mar 31 22:09:43 2012 -0400
@@ -22,6 +22,7 @@
 /*
  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
+ * Copyright 2012 Joyent, Inc.  All rights reserved.
  */
 
 /*
@@ -336,6 +337,7 @@
 	int ndevs;
 	int masterfd;
 	int slavefd;
+	int i;
 
 	/*
 	 * Don't re-setup console if it is working and ready already; just
@@ -421,11 +423,25 @@
 		(void) close(masterfd);
 		goto error;
 	}
-	if (ioctl(masterfd, ZC_HOLDSLAVE, (caddr_t)(intptr_t)slavefd) == 0)
-		rv = 0;
-	else
+	/*
+	 * This ioctl can occasionally return ENXIO if devfs doesn't have
+	 * everything plumbed up yet due to heavy zone startup load. Wait for
+	 * 1 sec. and retry a few times before we fail to boot the zone.
+	 */
+	for (i = 0; i < 5; i++) {
+		if (ioctl(masterfd, ZC_HOLDSLAVE, (caddr_t)(intptr_t)slavefd)
+		    == 0) {
+			rv = 0;
+			break;
+		} else if (errno != ENXIO) {
+			break;
+		}
+		(void) sleep(1);
+	}
+	if (rv != 0)
 		zerror(zlogp, B_TRUE, "ERROR: error while acquiring slave "
 		    "handle of zone console for %s", zone_name);
+
 	(void) close(slavefd);
 	(void) close(masterfd);