zoneadmd.c (5576:600b6e9b3a5b) | zoneadmd.c (5829:20241b1ccadc) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 6 unchanged lines hidden (view full) --- 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 6 unchanged lines hidden (view full) --- 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* |
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. | 23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. |
24 * Use is subject to license terms. 25 */ 26 27#pragma ident "%Z%%M% %I% %E% SMI" 28 29/* 30 * zoneadmd manages zones; one zoneadmd process is launched for each 31 * non-global zone on the system. This daemon juggles four jobs: --- 409 unchanged lines hidden (view full) --- 441} 442 443/* 444 * Bring a zone up to the pre-boot "ready" stage. The mount_cmd argument is 445 * 'true' if this is being invoked as part of the processing for the "mount" 446 * subcommand. 447 */ 448static int | 24 * Use is subject to license terms. 25 */ 26 27#pragma ident "%Z%%M% %I% %E% SMI" 28 29/* 30 * zoneadmd manages zones; one zoneadmd process is launched for each 31 * non-global zone on the system. This daemon juggles four jobs: --- 409 unchanged lines hidden (view full) --- 441} 442 443/* 444 * Bring a zone up to the pre-boot "ready" stage. The mount_cmd argument is 445 * 'true' if this is being invoked as part of the processing for the "mount" 446 * subcommand. 447 */ 448static int |
449zone_ready(zlog_t *zlogp, boolean_t mount_cmd) | 449zone_ready(zlog_t *zlogp, zone_mnt_t mount_cmd) |
450{ 451 int err; 452 453 if ((err = zonecfg_create_snapshot(zone_name)) != Z_OK) { 454 zerror(zlogp, B_FALSE, "unable to create snapshot: %s", 455 zonecfg_strerror(err)); 456 return (-1); 457 } 458 459 if ((zone_id = vplat_create(zlogp, mount_cmd)) == -1) { 460 if ((err = zonecfg_destroy_snapshot(zone_name)) != Z_OK) 461 zerror(zlogp, B_FALSE, "destroying snapshot: %s", 462 zonecfg_strerror(err)); 463 return (-1); 464 } 465 if (vplat_bringup(zlogp, mount_cmd, zone_id) != 0) { 466 bringup_failure_recovery = B_TRUE; | 450{ 451 int err; 452 453 if ((err = zonecfg_create_snapshot(zone_name)) != Z_OK) { 454 zerror(zlogp, B_FALSE, "unable to create snapshot: %s", 455 zonecfg_strerror(err)); 456 return (-1); 457 } 458 459 if ((zone_id = vplat_create(zlogp, mount_cmd)) == -1) { 460 if ((err = zonecfg_destroy_snapshot(zone_name)) != Z_OK) 461 zerror(zlogp, B_FALSE, "destroying snapshot: %s", 462 zonecfg_strerror(err)); 463 return (-1); 464 } 465 if (vplat_bringup(zlogp, mount_cmd, zone_id) != 0) { 466 bringup_failure_recovery = B_TRUE; |
467 (void) vplat_teardown(NULL, mount_cmd, B_FALSE); | 467 (void) vplat_teardown(NULL, (mount_cmd != Z_MNT_BOOT), B_FALSE); |
468 if ((err = zonecfg_destroy_snapshot(zone_name)) != Z_OK) 469 zerror(zlogp, B_FALSE, "destroying snapshot: %s", 470 zonecfg_strerror(err)); 471 return (-1); 472 } 473 474 return (0); 475} --- 551 unchanged lines hidden (view full) --- 1027 zerror(zlogp, B_FALSE, 1028 "%s operation is invalid for zones in state '%s'", 1029 z_cmd_name(cmd), zone_state_str(zstate)); 1030 break; 1031 1032 case ZONE_STATE_INSTALLED: 1033 switch (cmd) { 1034 case Z_READY: | 468 if ((err = zonecfg_destroy_snapshot(zone_name)) != Z_OK) 469 zerror(zlogp, B_FALSE, "destroying snapshot: %s", 470 zonecfg_strerror(err)); 471 return (-1); 472 } 473 474 return (0); 475} --- 551 unchanged lines hidden (view full) --- 1027 zerror(zlogp, B_FALSE, 1028 "%s operation is invalid for zones in state '%s'", 1029 z_cmd_name(cmd), zone_state_str(zstate)); 1030 break; 1031 1032 case ZONE_STATE_INSTALLED: 1033 switch (cmd) { 1034 case Z_READY: |
1035 rval = zone_ready(zlogp, B_FALSE); | 1035 rval = zone_ready(zlogp, Z_MNT_BOOT); |
1036 if (rval == 0) 1037 eventstream_write(Z_EVT_ZONE_READIED); 1038 break; 1039 case Z_BOOT: 1040 case Z_FORCEBOOT: 1041 eventstream_write(Z_EVT_ZONE_BOOTING); | 1036 if (rval == 0) 1037 eventstream_write(Z_EVT_ZONE_READIED); 1038 break; 1039 case Z_BOOT: 1040 case Z_FORCEBOOT: 1041 eventstream_write(Z_EVT_ZONE_BOOTING); |
1042 if ((rval = zone_ready(zlogp, B_FALSE)) == 0) | 1042 if ((rval = zone_ready(zlogp, Z_MNT_BOOT)) == 0) |
1043 rval = zone_bootup(zlogp, zargp->bootbuf); 1044 audit_put_record(zlogp, uc, rval, "boot"); 1045 if (rval != 0) { 1046 bringup_failure_recovery = B_TRUE; 1047 (void) zone_halt(zlogp, B_FALSE, B_FALSE); 1048 eventstream_write(Z_EVT_ZONE_BOOTFAILED); 1049 } 1050 break; --- 33 unchanged lines hidden (view full) --- 1084 if (!zone_isnative && !zone_iscluster) { 1085 zerror(zlogp, B_FALSE, 1086 "%s operation is invalid for branded " 1087 "zones", z_cmd_name(cmd)); 1088 rval = -1; 1089 break; 1090 } 1091 | 1043 rval = zone_bootup(zlogp, zargp->bootbuf); 1044 audit_put_record(zlogp, uc, rval, "boot"); 1045 if (rval != 0) { 1046 bringup_failure_recovery = B_TRUE; 1047 (void) zone_halt(zlogp, B_FALSE, B_FALSE); 1048 eventstream_write(Z_EVT_ZONE_BOOTFAILED); 1049 } 1050 break; --- 33 unchanged lines hidden (view full) --- 1084 if (!zone_isnative && !zone_iscluster) { 1085 zerror(zlogp, B_FALSE, 1086 "%s operation is invalid for branded " 1087 "zones", z_cmd_name(cmd)); 1088 rval = -1; 1089 break; 1090 } 1091 |
1092 rval = zone_ready(zlogp, B_TRUE); | 1092 rval = zone_ready(zlogp, 1093 strcmp(zargp->bootbuf, "-U") == 0 ? 1094 Z_MNT_UPDATE : Z_MNT_SCRATCH); |
1093 if (rval != 0) 1094 break; 1095 1096 eventstream_write(Z_EVT_ZONE_READIED); 1097 1098 /* Get a handle to the brand info for this zone */ 1099 if ((bh = brand_open(brand_name)) == NULL) { 1100 rval = -1; --- 103 unchanged lines hidden (view full) --- 1204 1205 case ZONE_STATE_RUNNING: 1206 case ZONE_STATE_SHUTTING_DOWN: 1207 case ZONE_STATE_DOWN: 1208 switch (cmd) { 1209 case Z_READY: 1210 if ((rval = zone_halt(zlogp, B_FALSE, B_TRUE)) != 0) 1211 break; | 1095 if (rval != 0) 1096 break; 1097 1098 eventstream_write(Z_EVT_ZONE_READIED); 1099 1100 /* Get a handle to the brand info for this zone */ 1101 if ((bh = brand_open(brand_name)) == NULL) { 1102 rval = -1; --- 103 unchanged lines hidden (view full) --- 1206 1207 case ZONE_STATE_RUNNING: 1208 case ZONE_STATE_SHUTTING_DOWN: 1209 case ZONE_STATE_DOWN: 1210 switch (cmd) { 1211 case Z_READY: 1212 if ((rval = zone_halt(zlogp, B_FALSE, B_TRUE)) != 0) 1213 break; |
1212 if ((rval = zone_ready(zlogp, B_FALSE)) == 0) | 1214 if ((rval = zone_ready(zlogp, Z_MNT_BOOT)) == 0) |
1213 eventstream_write(Z_EVT_ZONE_READIED); 1214 else 1215 eventstream_write(Z_EVT_ZONE_HALTED); 1216 break; 1217 case Z_BOOT: 1218 /* 1219 * We could have two clients racing to boot this 1220 * zone; the second client loses, but his request --- 12 unchanged lines hidden (view full) --- 1233 (void) strlcpy(boot_args, zargp->bootbuf, 1234 sizeof (boot_args)); 1235 eventstream_write(Z_EVT_ZONE_REBOOTING); 1236 if ((rval = zone_halt(zlogp, B_FALSE, B_TRUE)) != 0) { 1237 eventstream_write(Z_EVT_ZONE_BOOTFAILED); 1238 boot_args[0] = '\0'; 1239 break; 1240 } | 1215 eventstream_write(Z_EVT_ZONE_READIED); 1216 else 1217 eventstream_write(Z_EVT_ZONE_HALTED); 1218 break; 1219 case Z_BOOT: 1220 /* 1221 * We could have two clients racing to boot this 1222 * zone; the second client loses, but his request --- 12 unchanged lines hidden (view full) --- 1235 (void) strlcpy(boot_args, zargp->bootbuf, 1236 sizeof (boot_args)); 1237 eventstream_write(Z_EVT_ZONE_REBOOTING); 1238 if ((rval = zone_halt(zlogp, B_FALSE, B_TRUE)) != 0) { 1239 eventstream_write(Z_EVT_ZONE_BOOTFAILED); 1240 boot_args[0] = '\0'; 1241 break; 1242 } |
1241 if ((rval = zone_ready(zlogp, B_FALSE)) != 0) { | 1243 if ((rval = zone_ready(zlogp, Z_MNT_BOOT)) != 0) { |
1242 eventstream_write(Z_EVT_ZONE_BOOTFAILED); 1243 boot_args[0] = '\0'; 1244 break; 1245 } 1246 rval = zone_bootup(zlogp, zargp->bootbuf); 1247 audit_put_record(zlogp, uc, rval, "reboot"); 1248 if (rval != 0) { 1249 (void) zone_halt(zlogp, B_FALSE, B_TRUE); --- 592 unchanged lines hidden --- | 1244 eventstream_write(Z_EVT_ZONE_BOOTFAILED); 1245 boot_args[0] = '\0'; 1246 break; 1247 } 1248 rval = zone_bootup(zlogp, zargp->bootbuf); 1249 audit_put_record(zlogp, uc, rval, "reboot"); 1250 if (rval != 0) { 1251 (void) zone_halt(zlogp, B_FALSE, B_TRUE); --- 592 unchanged lines hidden --- |