1515 abort();
1516 zerror(zlogp, B_FALSE, "zone is already unmounted");
1517 rval = 0;
1518 break;
1519 }
1520 break;
1521
1522 case ZONE_STATE_READY:
1523 switch (cmd) {
1524 case Z_READY:
1525 /*
1526 * We could have two clients racing to ready this
1527 * zone; the second client loses, but his request
1528 * doesn't fail, since the zone is now in the desired
1529 * state.
1530 */
1531 zerror(zlogp, B_FALSE, "zone is already ready");
1532 rval = 0;
1533 break;
1534 case Z_BOOT:
1535 (void) strlcpy(boot_args, zargp->bootbuf,
1536 sizeof (boot_args));
1537 eventstream_write(Z_EVT_ZONE_BOOTING);
1538 rval = zone_bootup(zlogp, zargp->bootbuf, zstate,
1539 debug);
1540 audit_put_record(zlogp, uc, rval, "boot");
1541 if (rval != 0) {
1542 bringup_failure_recovery = B_TRUE;
1543 (void) zone_halt(zlogp, B_FALSE, B_TRUE,
1544 zstate, debug);
1545 eventstream_write(Z_EVT_ZONE_BOOTFAILED);
1546 }
1547 boot_args[0] = '\0';
1548 break;
1549 case Z_HALT:
1550 if (kernelcall) /* Invalid; can't happen */
1551 abort();
1552 if ((rval = zone_halt(zlogp, B_FALSE, B_FALSE, zstate,
1553 debug)) != 0)
1554 break;
1555 eventstream_write(Z_EVT_ZONE_HALTED);
1556 break;
1557 case Z_REBOOT:
1558 case Z_NOTE_UNINSTALLING:
1559 case Z_MOUNT:
1560 case Z_UNMOUNT:
1561 if (kernelcall) /* Invalid; can't happen */
1562 abort();
1563 zerror(zlogp, B_FALSE, "%s operation is invalid "
1564 "for zones in state '%s'", z_cmd_name(cmd),
1565 zone_state_str(zstate));
1566 rval = -1;
1567 break;
1568 }
1569 break;
1570
1571 case ZONE_STATE_MOUNTED:
1572 switch (cmd) {
1573 case Z_UNMOUNT:
1574 if (kernelcall) /* Invalid; can't happen */
1575 abort();
1576 rval = zone_halt(zlogp, B_TRUE, B_FALSE, zstate, debug);
1577 if (rval == 0) {
1578 eventstream_write(Z_EVT_ZONE_HALTED);
1579 (void) sema_post(&scratch_sem);
1588 rval = -1;
1589 break;
1590 }
1591 break;
1592
1593 case ZONE_STATE_RUNNING:
1594 case ZONE_STATE_SHUTTING_DOWN:
1595 case ZONE_STATE_DOWN:
1596 switch (cmd) {
1597 case Z_READY:
1598 if ((rval = zone_halt(zlogp, B_FALSE, B_TRUE, zstate,
1599 debug)) != 0)
1600 break;
1601 if ((rval = zone_ready(zlogp, Z_MNT_BOOT, zstate,
1602 debug)) == 0)
1603 eventstream_write(Z_EVT_ZONE_READIED);
1604 else
1605 eventstream_write(Z_EVT_ZONE_HALTED);
1606 break;
1607 case Z_BOOT:
1608 /*
1609 * We could have two clients racing to boot this
1610 * zone; the second client loses, but his request
1611 * doesn't fail, since the zone is now in the desired
1612 * state.
1613 */
1614 zerror(zlogp, B_FALSE, "zone is already booted");
1615 rval = 0;
1616 break;
1617 case Z_HALT:
1618 if ((rval = zone_halt(zlogp, B_FALSE, B_FALSE, zstate,
1619 debug)) != 0)
1620 break;
1621 eventstream_write(Z_EVT_ZONE_HALTED);
1622 break;
1623 case Z_REBOOT:
1624 (void) strlcpy(boot_args, zargp->bootbuf,
1625 sizeof (boot_args));
1626 eventstream_write(Z_EVT_ZONE_REBOOTING);
1627 if ((rval = zone_halt(zlogp, B_FALSE, B_TRUE, zstate,
1631 break;
1632 }
1633 if ((rval = zone_ready(zlogp, Z_MNT_BOOT, zstate,
1634 debug)) != 0) {
1635 eventstream_write(Z_EVT_ZONE_BOOTFAILED);
1636 boot_args[0] = '\0';
1637 break;
1638 }
1639 rval = zone_bootup(zlogp, zargp->bootbuf, zstate,
1640 debug);
1641 audit_put_record(zlogp, uc, rval, "reboot");
1642 if (rval != 0) {
1643 (void) zone_halt(zlogp, B_FALSE, B_TRUE,
1644 zstate, debug);
1645 eventstream_write(Z_EVT_ZONE_BOOTFAILED);
1646 }
1647 boot_args[0] = '\0';
1648 break;
1649 case Z_NOTE_UNINSTALLING:
1650 case Z_MOUNT:
1651 case Z_UNMOUNT:
1652 zerror(zlogp, B_FALSE, "%s operation is invalid "
1653 "for zones in state '%s'", z_cmd_name(cmd),
1654 zone_state_str(zstate));
1655 rval = -1;
1656 break;
1657 }
1658 break;
1659 default:
1660 abort();
1661 }
1662
1663 /*
1664 * Because the state of the zone may have changed, we make sure
1665 * to wake the console poller, which is in charge of initiating
1666 * the shutdown procedure as necessary.
1667 */
1668 eventstream_write(Z_EVT_NULL);
1669
1670 out:
|
1515 abort();
1516 zerror(zlogp, B_FALSE, "zone is already unmounted");
1517 rval = 0;
1518 break;
1519 }
1520 break;
1521
1522 case ZONE_STATE_READY:
1523 switch (cmd) {
1524 case Z_READY:
1525 /*
1526 * We could have two clients racing to ready this
1527 * zone; the second client loses, but his request
1528 * doesn't fail, since the zone is now in the desired
1529 * state.
1530 */
1531 zerror(zlogp, B_FALSE, "zone is already ready");
1532 rval = 0;
1533 break;
1534 case Z_BOOT:
1535 case Z_FORCEBOOT:
1536 (void) strlcpy(boot_args, zargp->bootbuf,
1537 sizeof (boot_args));
1538 eventstream_write(Z_EVT_ZONE_BOOTING);
1539 rval = zone_bootup(zlogp, zargp->bootbuf, zstate,
1540 debug);
1541 audit_put_record(zlogp, uc, rval, "boot");
1542 if (rval != 0) {
1543 bringup_failure_recovery = B_TRUE;
1544 (void) zone_halt(zlogp, B_FALSE, B_TRUE,
1545 zstate, debug);
1546 eventstream_write(Z_EVT_ZONE_BOOTFAILED);
1547 }
1548 boot_args[0] = '\0';
1549 break;
1550 case Z_HALT:
1551 if (kernelcall) /* Invalid; can't happen */
1552 abort();
1553 if ((rval = zone_halt(zlogp, B_FALSE, B_FALSE, zstate,
1554 debug)) != 0)
1555 break;
1556 eventstream_write(Z_EVT_ZONE_HALTED);
1557 break;
1558 case Z_REBOOT:
1559 case Z_NOTE_UNINSTALLING:
1560 case Z_MOUNT:
1561 case Z_FORCEMOUNT:
1562 case Z_UNMOUNT:
1563 if (kernelcall) /* Invalid; can't happen */
1564 abort();
1565 zerror(zlogp, B_FALSE, "%s operation is invalid "
1566 "for zones in state '%s'", z_cmd_name(cmd),
1567 zone_state_str(zstate));
1568 rval = -1;
1569 break;
1570 }
1571 break;
1572
1573 case ZONE_STATE_MOUNTED:
1574 switch (cmd) {
1575 case Z_UNMOUNT:
1576 if (kernelcall) /* Invalid; can't happen */
1577 abort();
1578 rval = zone_halt(zlogp, B_TRUE, B_FALSE, zstate, debug);
1579 if (rval == 0) {
1580 eventstream_write(Z_EVT_ZONE_HALTED);
1581 (void) sema_post(&scratch_sem);
1590 rval = -1;
1591 break;
1592 }
1593 break;
1594
1595 case ZONE_STATE_RUNNING:
1596 case ZONE_STATE_SHUTTING_DOWN:
1597 case ZONE_STATE_DOWN:
1598 switch (cmd) {
1599 case Z_READY:
1600 if ((rval = zone_halt(zlogp, B_FALSE, B_TRUE, zstate,
1601 debug)) != 0)
1602 break;
1603 if ((rval = zone_ready(zlogp, Z_MNT_BOOT, zstate,
1604 debug)) == 0)
1605 eventstream_write(Z_EVT_ZONE_READIED);
1606 else
1607 eventstream_write(Z_EVT_ZONE_HALTED);
1608 break;
1609 case Z_BOOT:
1610 case Z_FORCEBOOT:
1611 /*
1612 * We could have two clients racing to boot this
1613 * zone; the second client loses, but his request
1614 * doesn't fail, since the zone is now in the desired
1615 * state.
1616 */
1617 zerror(zlogp, B_FALSE, "zone is already booted");
1618 rval = 0;
1619 break;
1620 case Z_HALT:
1621 if ((rval = zone_halt(zlogp, B_FALSE, B_FALSE, zstate,
1622 debug)) != 0)
1623 break;
1624 eventstream_write(Z_EVT_ZONE_HALTED);
1625 break;
1626 case Z_REBOOT:
1627 (void) strlcpy(boot_args, zargp->bootbuf,
1628 sizeof (boot_args));
1629 eventstream_write(Z_EVT_ZONE_REBOOTING);
1630 if ((rval = zone_halt(zlogp, B_FALSE, B_TRUE, zstate,
1634 break;
1635 }
1636 if ((rval = zone_ready(zlogp, Z_MNT_BOOT, zstate,
1637 debug)) != 0) {
1638 eventstream_write(Z_EVT_ZONE_BOOTFAILED);
1639 boot_args[0] = '\0';
1640 break;
1641 }
1642 rval = zone_bootup(zlogp, zargp->bootbuf, zstate,
1643 debug);
1644 audit_put_record(zlogp, uc, rval, "reboot");
1645 if (rval != 0) {
1646 (void) zone_halt(zlogp, B_FALSE, B_TRUE,
1647 zstate, debug);
1648 eventstream_write(Z_EVT_ZONE_BOOTFAILED);
1649 }
1650 boot_args[0] = '\0';
1651 break;
1652 case Z_NOTE_UNINSTALLING:
1653 case Z_MOUNT:
1654 case Z_FORCEMOUNT:
1655 case Z_UNMOUNT:
1656 zerror(zlogp, B_FALSE, "%s operation is invalid "
1657 "for zones in state '%s'", z_cmd_name(cmd),
1658 zone_state_str(zstate));
1659 rval = -1;
1660 break;
1661 }
1662 break;
1663 default:
1664 abort();
1665 }
1666
1667 /*
1668 * Because the state of the zone may have changed, we make sure
1669 * to wake the console poller, which is in charge of initiating
1670 * the shutdown procedure as necessary.
1671 */
1672 eventstream_write(Z_EVT_NULL);
1673
1674 out:
|