Print this page
OS-200 need a better mechanism for storing persistent zone_did
OS-511 make zonecfg device resource extensible, like the net resource
OS-224 add more zonecfg net properties
OS-216 store all net config info on zone
Reduce lint
OS-5139 cpu_cap is sometimes off by 1 when set with package fss or cap_cap direct update
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
OS-399 zone phys. mem. cap should be a rctl and have associated kstat

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/zonecfg/zonecfg.c
          +++ new/usr/src/cmd/zonecfg/zonecfg.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
  25   25   * Copyright 2014 Gary Mills
       26 + * Copyright 2016, Joyent Inc.
  26   27   */
  27   28  
  28   29  /*
  29   30   * zonecfg is a lex/yacc based command interpreter used to manage zone
  30   31   * configurations.  The lexer (see zonecfg_lex.l) builds up tokens, which
  31   32   * the grammar (see zonecfg_grammar.y) builds up into commands, some of
  32   33   * which takes resources and/or properties as arguments.  See the block
  33   34   * comments near the end of zonecfg_grammar.y for how the data structures
  34   35   * which keep track of these resources and properties are built up.
  35   36   *
↓ open down ↓ 191 lines elided ↑ open up ↑
 227  228          ALIAS_MAXSWAP,
 228  229          "scheduling-class",
 229  230          "ip-type",
 230  231          "defrouter",
 231  232          "hostid",
 232  233          "user",
 233  234          "auths",
 234  235          "fs-allowed",
 235  236          ALIAS_MAXPROCS,
 236  237          "allowed-address",
      238 +        ALIAS_ZFSPRI,
      239 +        "mac-addr",
      240 +        "vlan-id",
      241 +        "global-nic",
      242 +        "property",
 237  243          NULL
 238  244  };
 239  245  
 240  246  /* These *must* match the order of the PROP_VAL_ define's from zonecfg.h */
 241  247  static char *prop_val_types[] = {
 242  248          "simple",
 243  249          "complex",
 244  250          "list",
 245  251  };
 246  252  
↓ open down ↓ 152 lines elided ↑ open up ↑
 399  405          "clear raw",
 400  406          NULL
 401  407  };
 402  408  
 403  409  static const char *net_res_scope_cmds[] = {
 404  410          "cancel",
 405  411          "end",
 406  412          "exit",
 407  413          "help",
 408  414          "info",
      415 +        "add property ",
      416 +        "clear allowed-address",
      417 +        "clear defrouter",
      418 +        "clear global-nic",
      419 +        "clear mac-addr",
      420 +        "clear vlan-id",
      421 +        "remove property ",
 409  422          "set address=",
 410      -        "set physical=",
      423 +        "set allowed-address=",
 411  424          "set defrouter=",
      425 +        "set global-nic=",
      426 +        "set mac-addr=",
      427 +        "set physical=",
      428 +        "set vlan-id=",
 412  429          NULL
 413  430  };
 414  431  
 415  432  static const char *device_res_scope_cmds[] = {
 416  433          "cancel",
 417  434          "end",
 418  435          "exit",
 419  436          "help",
 420  437          "info",
      438 +        "add property ",
 421  439          "set match=",
 422  440          NULL
 423  441  };
 424  442  
 425  443  static const char *attr_res_scope_cmds[] = {
 426  444          "cancel",
 427  445          "end",
 428  446          "exit",
 429  447          "help",
 430  448          "info",
↓ open down ↓ 141 lines elided ↑ open up ↑
 572  590   * the multi-step process.  They should be initialized by add_resource() or
 573  591   * select_func() and filled in by add_property() or set_func().
 574  592   */
 575  593  static struct zone_fstab        old_fstab, in_progress_fstab;
 576  594  static struct zone_nwiftab      old_nwiftab, in_progress_nwiftab;
 577  595  static struct zone_devtab       old_devtab, in_progress_devtab;
 578  596  static struct zone_rctltab      old_rctltab, in_progress_rctltab;
 579  597  static struct zone_attrtab      old_attrtab, in_progress_attrtab;
 580  598  static struct zone_dstab        old_dstab, in_progress_dstab;
 581  599  static struct zone_psettab      old_psettab, in_progress_psettab;
 582      -static struct zone_mcaptab      old_mcaptab, in_progress_mcaptab;
 583  600  static struct zone_admintab     old_admintab, in_progress_admintab;
 584  601  
 585  602  static GetLine *gl;     /* The gl_get_line() resource object */
 586  603  
 587  604  static void bytes_to_units(char *str, char *buf, int bufsize);
 588  605  
 589  606  /* Functions begin here */
 590  607  
 591  608  static boolean_t
 592  609  initial_match(const char *line1, const char *line2, int word_end)
↓ open down ↓ 478 lines elided ↑ open up ↑
1071 1088                              /*CSTYLED*/
1072 1089                              "such as \"%s=5\".\n"), MNTOPT_RETRY);
1073 1090                          break;
1074 1091                  case RT_NET:
1075 1092                          (void) fprintf(fp, gettext("The '%s' resource scope is "
1076 1093                              "used to configure a network interface.\n"),
1077 1094                              rt_to_str(resource_scope));
1078 1095                          (void) fprintf(fp, gettext("Valid commands:\n"));
1079 1096                          (void) fprintf(fp, "\t%s %s=%s\n", cmd_to_str(CMD_SET),
1080 1097                              pt_to_str(PT_ADDRESS), gettext("<IP-address>"));
     1098 +                        (void) fprintf(fp, "\t%s %s (%s=<value>,%s=<value>)\n",
     1099 +                            cmd_to_str(CMD_ADD), pt_to_str(PT_NPROP),
     1100 +                            pt_to_str(PT_NAME), pt_to_str(PT_VALUE));
1081 1101                          (void) fprintf(fp, "\t%s %s=%s\n", cmd_to_str(CMD_SET),
1082 1102                              pt_to_str(PT_ALLOWED_ADDRESS),
1083 1103                              gettext("<IP-address>"));
1084 1104                          (void) fprintf(fp, "\t%s %s=%s\n", cmd_to_str(CMD_SET),
1085 1105                              pt_to_str(PT_PHYSICAL), gettext("<interface>"));
     1106 +                        (void) fprintf(fp, "\t%s %s=%s\n", cmd_to_str(CMD_SET),
     1107 +                            pt_to_str(PT_MAC), gettext("<mac-address>"));
     1108 +                        (void) fprintf(fp, "\t%s %s=%s\n", cmd_to_str(CMD_SET),
     1109 +                            pt_to_str(PT_GNIC), gettext("<global zone NIC>"));
     1110 +                        (void) fprintf(fp, "\t%s %s=%s\n", cmd_to_str(CMD_SET),
     1111 +                            pt_to_str(PT_VLANID), gettext("<vlan ID>"));
1086 1112                          (void) fprintf(fp, gettext("See ifconfig(1M) for "
1087 1113                              "details of the <interface> string.\n"));
1088 1114                          (void) fprintf(fp, gettext("%s %s is valid "
1089 1115                              "if the %s property is set to %s, otherwise it "
1090 1116                              "must not be set.\n"),
1091 1117                              cmd_to_str(CMD_SET), pt_to_str(PT_ADDRESS),
1092 1118                              pt_to_str(PT_IPTYPE), gettext("shared"));
1093      -                        (void) fprintf(fp, gettext("%s %s is valid "
1094      -                            "if the %s property is set to %s, otherwise it "
1095      -                            "must not be set.\n"),
1096      -                            cmd_to_str(CMD_SET), pt_to_str(PT_ALLOWED_ADDRESS),
     1119 +                        (void) fprintf(fp, gettext("%s (%s, %s, %s, %s) are "
     1120 +                            "valid if the %s property is set to %s, otherwise "
     1121 +                            "they must not be set.\n"),
     1122 +                            cmd_to_str(CMD_SET),
     1123 +                            pt_to_str(PT_ALLOWED_ADDRESS), pt_to_str(PT_MAC),
     1124 +                            pt_to_str(PT_VLANID), pt_to_str(PT_GNIC),
1097 1125                              pt_to_str(PT_IPTYPE), gettext("exclusive"));
1098 1126                          (void) fprintf(fp, gettext("\t%s %s=%s\n%s %s "
1099 1127                              "is valid if the %s or %s property is set, "
1100 1128                              "otherwise it must not be set\n"),
1101 1129                              cmd_to_str(CMD_SET),
1102 1130                              pt_to_str(PT_DEFROUTER), gettext("<IP-address>"),
1103 1131                              cmd_to_str(CMD_SET), pt_to_str(PT_DEFROUTER),
1104 1132                              gettext(pt_to_str(PT_ADDRESS)),
1105 1133                              gettext(pt_to_str(PT_ALLOWED_ADDRESS)));
1106 1134                          break;
1107 1135                  case RT_DEVICE:
1108 1136                          (void) fprintf(fp, gettext("The '%s' resource scope is "
1109 1137                              "used to configure a device node.\n"),
1110 1138                              rt_to_str(resource_scope));
1111 1139                          (void) fprintf(fp, gettext("Valid commands:\n"));
     1140 +                        (void) fprintf(fp, "\t%s %s (%s=<value>,%s=<value>)\n",
     1141 +                            cmd_to_str(CMD_ADD), pt_to_str(PT_NPROP),
     1142 +                            pt_to_str(PT_NAME), pt_to_str(PT_VALUE));
1112 1143                          (void) fprintf(fp, "\t%s %s=%s\n", cmd_to_str(CMD_SET),
1113 1144                              pt_to_str(PT_MATCH), gettext("<device-path>"));
1114 1145                          break;
1115 1146                  case RT_RCTL:
1116 1147                          (void) fprintf(fp, gettext("The '%s' resource scope is "
1117 1148                              "used to configure a resource control.\n"),
1118 1149                              rt_to_str(resource_scope));
1119 1150                          (void) fprintf(fp, gettext("Valid commands:\n"));
1120 1151                          (void) fprintf(fp, "\t%s %s=%s\n", cmd_to_str(CMD_SET),
1121 1152                              pt_to_str(PT_NAME), gettext("<string>"));
↓ open down ↓ 207 lines elided ↑ open up ↑
1329 1360                  (void) fprintf(fp, "\t%s\t%s\n", gettext("(global)"),
1330 1361                      pt_to_str(PT_MAXMSGIDS));
1331 1362                  (void) fprintf(fp, "\t%s\t%s\n", gettext("(global)"),
1332 1363                      pt_to_str(PT_MAXSEMIDS));
1333 1364                  (void) fprintf(fp, "\t%s\t%s\n", gettext("(global)"),
1334 1365                      pt_to_str(PT_SHARES));
1335 1366                  (void) fprintf(fp, "\t%s\t\t%s, %s, %s, %s, %s\n",
1336 1367                      rt_to_str(RT_FS), pt_to_str(PT_DIR),
1337 1368                      pt_to_str(PT_SPECIAL), pt_to_str(PT_RAW),
1338 1369                      pt_to_str(PT_TYPE), pt_to_str(PT_OPTIONS));
1339      -                (void) fprintf(fp, "\t%s\t\t%s, %s, %s|%s\n", rt_to_str(RT_NET),
     1370 +                (void) fprintf(fp, "\t%s\t\t%s, %s, %s, %s, %s, %s, %s %s\n",
     1371 +                    rt_to_str(RT_NET),
1340 1372                      pt_to_str(PT_ADDRESS), pt_to_str(PT_ALLOWED_ADDRESS),
1341      -                    pt_to_str(PT_PHYSICAL), pt_to_str(PT_DEFROUTER));
1342      -                (void) fprintf(fp, "\t%s\t\t%s\n", rt_to_str(RT_DEVICE),
1343      -                    pt_to_str(PT_MATCH));
     1373 +                    pt_to_str(PT_GNIC), pt_to_str(PT_MAC),
     1374 +                    pt_to_str(PT_PHYSICAL), pt_to_str(PT_NPROP),
     1375 +                    pt_to_str(PT_VLANID), pt_to_str(PT_DEFROUTER));
     1376 +                (void) fprintf(fp, "\t%s\t\t%s, %s\n", rt_to_str(RT_DEVICE),
     1377 +                    pt_to_str(PT_MATCH), pt_to_str(PT_NPROP));
1344 1378                  (void) fprintf(fp, "\t%s\t\t%s, %s\n", rt_to_str(RT_RCTL),
1345 1379                      pt_to_str(PT_NAME), pt_to_str(PT_VALUE));
1346 1380                  (void) fprintf(fp, "\t%s\t\t%s, %s, %s\n", rt_to_str(RT_ATTR),
1347 1381                      pt_to_str(PT_NAME), pt_to_str(PT_TYPE),
1348 1382                      pt_to_str(PT_VALUE));
1349 1383                  (void) fprintf(fp, "\t%s\t\t%s\n", rt_to_str(RT_DATASET),
1350 1384                      pt_to_str(PT_NAME));
1351 1385                  (void) fprintf(fp, "\t%s\t%s, %s\n", rt_to_str(RT_DCPU),
1352 1386                      pt_to_str(PT_NCPUS), pt_to_str(PT_IMPORTANCE));
1353 1387                  (void) fprintf(fp, "\t%s\t%s\n", rt_to_str(RT_PCAP),
↓ open down ↓ 34 lines elided ↑ open up ↑
1388 1422  /* returns Z_OK if successful, Z_foo from <libzonecfg.h> otherwise */
1389 1423  static int
1390 1424  initialize(boolean_t handle_expected)
1391 1425  {
1392 1426          int err;
1393 1427          char brandname[MAXNAMELEN];
1394 1428  
1395 1429          if (zonecfg_check_handle(handle) != Z_OK) {
1396 1430                  if ((err = zonecfg_get_handle(zone, handle)) == Z_OK) {
1397 1431                          got_handle = B_TRUE;
     1432 +
     1433 +                        (void) zonecfg_fix_obsolete(handle);
     1434 +
1398 1435                          if (zonecfg_get_brand(handle, brandname,
1399 1436                              sizeof (brandname)) != Z_OK) {
1400 1437                                  zerr("Zone %s is inconsistent: missing "
1401 1438                                      "brand attribute", zone);
1402 1439                                  exit(Z_ERR);
1403 1440                          }
1404 1441                          if ((brand = brand_open(brandname)) == NULL) {
1405 1442                                  zerr("Zone %s uses non-existent brand \"%s\"."
1406 1443                                      "  Unable to continue", zone, brandname);
1407 1444                                  exit(Z_ERR);
↓ open down ↓ 280 lines elided ↑ open up ↑
1688 1725                          (void) strlcpy(zone_template, "SUNWblank",
1689 1726                              sizeof (zone_template));
1690 1727                          break;
1691 1728                  case 'F':
1692 1729                          force = B_TRUE;
1693 1730                          break;
1694 1731                  case 't':
1695 1732                          (void) strlcpy(zone_template, optarg,
1696 1733                              sizeof (zone_template));
1697 1734                          break;
     1735 +                case 'X':
     1736 +                        (void) snprintf(zone_template, sizeof (zone_template),
     1737 +                            "%s/%s.xml", ZONE_CONFIG_ROOT, zone);
     1738 +                        err = zonecfg_get_xml_handle(zone_template, handle);
     1739 +                        if (err != Z_OK) {
     1740 +                                zone_perror(execname, err, B_TRUE);
     1741 +                                exit(Z_ERR);
     1742 +                        }
     1743 +                        got_handle = B_TRUE;
     1744 +                        need_to_commit = B_TRUE;
     1745 +                        return;
1698 1746                  default:
1699 1747                          short_usage(CMD_CREATE);
1700 1748                          arg_err = B_TRUE;
1701 1749                          break;
1702 1750                  }
1703 1751          }
1704 1752          if (arg_err)
1705 1753                  return;
1706 1754  
1707 1755          if (optind != cmd->cmd_argc) {
↓ open down ↓ 82 lines elided ↑ open up ↑
1790 1838  void
1791 1839  export_func(cmd_t *cmd)
1792 1840  {
1793 1841          struct zone_nwiftab nwiftab;
1794 1842          struct zone_fstab fstab;
1795 1843          struct zone_devtab devtab;
1796 1844          struct zone_attrtab attrtab;
1797 1845          struct zone_rctltab rctltab;
1798 1846          struct zone_dstab dstab;
1799 1847          struct zone_psettab psettab;
1800      -        struct zone_mcaptab mcaptab;
1801 1848          struct zone_rctlvaltab *valptr;
     1849 +        struct zone_res_attrtab *rap;
1802 1850          struct zone_admintab admintab;
1803 1851          int err, arg;
1804 1852          char zonepath[MAXPATHLEN], outfile[MAXPATHLEN], pool[MAXNAMELEN];
1805 1853          char bootargs[BOOTARGS_MAX];
1806 1854          char sched[MAXNAMELEN];
1807 1855          char brand[MAXNAMELEN];
1808 1856          char hostidp[HW_HOSTID_LEN];
1809 1857          char fsallowedp[ZONE_FS_ALLOWED_MAX];
1810 1858          char *limitpriv;
1811 1859          FILE *of;
↓ open down ↓ 149 lines elided ↑ open up ↑
1961 2009                  zone_perror(zone, err, B_FALSE);
1962 2010                  goto done;
1963 2011          }
1964 2012          while (zonecfg_getnwifent(handle, &nwiftab) == Z_OK) {
1965 2013                  (void) fprintf(of, "%s %s\n", cmd_to_str(CMD_ADD),
1966 2014                      rt_to_str(RT_NET));
1967 2015                  export_prop(of, PT_ADDRESS, nwiftab.zone_nwif_address);
1968 2016                  export_prop(of, PT_ALLOWED_ADDRESS,
1969 2017                      nwiftab.zone_nwif_allowed_address);
1970 2018                  export_prop(of, PT_PHYSICAL, nwiftab.zone_nwif_physical);
     2019 +                export_prop(of, PT_MAC, nwiftab.zone_nwif_mac);
     2020 +                export_prop(of, PT_VLANID, nwiftab.zone_nwif_vlan_id);
     2021 +                export_prop(of, PT_GNIC, nwiftab.zone_nwif_gnic);
1971 2022                  export_prop(of, PT_DEFROUTER, nwiftab.zone_nwif_defrouter);
     2023 +                for (rap = nwiftab.zone_nwif_attrp; rap != NULL;
     2024 +                    rap = rap->zone_res_attr_next) {
     2025 +                        fprintf(of, "%s %s (%s=%s,%s=\"%s\")\n",
     2026 +                            cmd_to_str(CMD_ADD), pt_to_str(PT_NPROP),
     2027 +                            pt_to_str(PT_NAME), rap->zone_res_attr_name,
     2028 +                            pt_to_str(PT_VALUE), rap->zone_res_attr_value);
     2029 +                }
1972 2030                  (void) fprintf(of, "%s\n", cmd_to_str(CMD_END));
1973 2031          }
1974 2032          (void) zonecfg_endnwifent(handle);
1975 2033  
1976 2034          if ((err = zonecfg_setdevent(handle)) != Z_OK) {
1977 2035                  zone_perror(zone, err, B_FALSE);
1978 2036                  goto done;
1979 2037          }
1980 2038          while (zonecfg_getdevent(handle, &devtab) == Z_OK) {
1981 2039                  (void) fprintf(of, "%s %s\n", cmd_to_str(CMD_ADD),
1982 2040                      rt_to_str(RT_DEVICE));
1983 2041                  export_prop(of, PT_MATCH, devtab.zone_dev_match);
     2042 +                for (rap = devtab.zone_dev_attrp; rap != NULL;
     2043 +                    rap = rap->zone_res_attr_next) {
     2044 +                        fprintf(of, "%s %s (%s=%s,%s=\"%s\")\n",
     2045 +                            cmd_to_str(CMD_ADD), pt_to_str(PT_NPROP),
     2046 +                            pt_to_str(PT_NAME), rap->zone_res_attr_name,
     2047 +                            pt_to_str(PT_VALUE), rap->zone_res_attr_value);
     2048 +                }
1984 2049                  (void) fprintf(of, "%s\n", cmd_to_str(CMD_END));
1985 2050          }
1986 2051          (void) zonecfg_enddevent(handle);
1987 2052  
1988      -        if (zonecfg_getmcapent(handle, &mcaptab) == Z_OK) {
1989      -                char buf[128];
1990      -
1991      -                (void) fprintf(of, "%s %s\n", cmd_to_str(CMD_ADD),
1992      -                    rt_to_str(RT_MCAP));
1993      -                bytes_to_units(mcaptab.zone_physmem_cap, buf, sizeof (buf));
1994      -                (void) fprintf(of, "%s %s=%s\n", cmd_to_str(CMD_SET),
1995      -                    pt_to_str(PT_PHYSICAL), buf);
1996      -                (void) fprintf(of, "%s\n", cmd_to_str(CMD_END));
1997      -        }
1998      -
1999 2053          if ((err = zonecfg_setrctlent(handle)) != Z_OK) {
2000 2054                  zone_perror(zone, err, B_FALSE);
2001 2055                  goto done;
2002 2056          }
2003 2057          while (zonecfg_getrctlent(handle, &rctltab) == Z_OK) {
2004 2058                  (void) fprintf(of, "%s rctl\n", cmd_to_str(CMD_ADD));
2005 2059                  export_prop(of, PT_NAME, rctltab.zone_rctl_name);
2006 2060                  for (valptr = rctltab.zone_rctl_valptr; valptr != NULL;
2007 2061                      valptr = valptr->zone_rctlval_next) {
2008 2062                          fprintf(of, "%s %s (%s=%s,%s=%s,%s=%s)\n",
↓ open down ↓ 133 lines elided ↑ open up ↑
2142 2196                  return (Z_ERR);
2143 2197          }
2144 2198          return (Z_OK);
2145 2199  }
2146 2200  
2147 2201  static void
2148 2202  add_resource(cmd_t *cmd)
2149 2203  {
2150 2204          int type;
2151 2205          struct zone_psettab tmp_psettab;
2152      -        struct zone_mcaptab tmp_mcaptab;
2153 2206          uint64_t tmp;
2154 2207          uint64_t tmp_mcap;
2155 2208          char pool[MAXNAMELEN];
2156 2209  
2157 2210          if ((type = cmd->cmd_res_type) == RT_UNKNOWN) {
2158 2211                  long_usage(CMD_ADD, B_TRUE);
2159 2212                  goto bad;
2160 2213          }
2161 2214  
2162 2215          switch (type) {
↓ open down ↓ 71 lines elided ↑ open up ↑
2234 2287  
2235 2288                  default:
2236 2289                          break;
2237 2290                  }
2238 2291                  return;
2239 2292          case RT_MCAP:
2240 2293                  /*
2241 2294                   * Make sure there isn't already a mem-cap entry or max-swap
2242 2295                   * or max-locked rctl.
2243 2296                   */
2244      -                if (zonecfg_lookup_mcap(handle, &tmp_mcaptab) == Z_OK ||
2245      -                    zonecfg_get_aliased_rctl(handle, ALIAS_MAXSWAP, &tmp_mcap)
2246      -                    == Z_OK ||
     2297 +                if (zonecfg_get_aliased_rctl(handle, ALIAS_MAXSWAP,
     2298 +                    &tmp_mcap) == Z_OK ||
     2299 +                    zonecfg_get_aliased_rctl(handle, ALIAS_MAXPHYSMEM,
     2300 +                    &tmp_mcap) == Z_OK ||
2247 2301                      zonecfg_get_aliased_rctl(handle, ALIAS_MAXLOCKEDMEM,
2248 2302                      &tmp_mcap) == Z_OK) {
2249 2303                          zerr(gettext("The %s resource or a related resource "
2250 2304                              "control already exists."), rt_to_str(RT_MCAP));
2251 2305                          goto bad;
2252 2306                  }
2253 2307                  if (global_zone)
2254 2308                          zerr(gettext("WARNING: Setting a global zone memory "
2255 2309                              "cap too low could deny\nservice "
2256 2310                              "to even the root user; "
2257 2311                              "this could render the system impossible\n"
2258 2312                              "to administer.  Please use caution."));
2259      -                bzero(&in_progress_mcaptab, sizeof (in_progress_mcaptab));
2260 2313                  return;
2261 2314          case RT_ADMIN:
2262 2315                  bzero(&in_progress_admintab, sizeof (in_progress_admintab));
2263 2316                  return;
2264 2317          default:
2265 2318                  zone_perror(rt_to_str(type), Z_NO_RESOURCE_TYPE, B_TRUE);
2266 2319                  long_usage(CMD_ADD, B_TRUE);
2267 2320                  usage(B_FALSE, HELP_RESOURCES);
2268 2321          }
2269 2322  bad:
↓ open down ↓ 82 lines elided ↑ open up ↑
2352 2405          }
2353 2406          err = zonecfg_add_rctl_value(&in_progress_rctltab, rctlvaltab);
2354 2407          if (err != Z_OK)
2355 2408                  zone_perror(pt_to_str(PT_VALUE), err, B_TRUE);
2356 2409          return;
2357 2410  
2358 2411  bad:
2359 2412          zonecfg_free_rctl_value_list(rctlvaltab);
2360 2413  }
2361 2414  
     2415 +/*
     2416 + * Resource attribute ("property" resource embedded on net or dev resource)
     2417 + */
2362 2418  static void
     2419 +do_res_attr(struct zone_res_attrtab **headp, complex_property_ptr_t cpp)
     2420 +{
     2421 +        complex_property_ptr_t cp;
     2422 +        struct zone_res_attrtab *np;
     2423 +        int err;
     2424 +        boolean_t seen_name = B_FALSE, seen_value = B_FALSE;
     2425 +
     2426 +        if ((np = calloc(1, sizeof (struct zone_res_attrtab))) == NULL) {
     2427 +                zone_perror(zone, Z_NOMEM, B_TRUE);
     2428 +                exit(Z_ERR);
     2429 +        }
     2430 +
     2431 +        for (cp = cpp; cp != NULL; cp = cp->cp_next) {
     2432 +                switch (cp->cp_type) {
     2433 +                case PT_NAME:
     2434 +                        if (seen_name) {
     2435 +                                zerr(gettext("%s already specified"),
     2436 +                                    pt_to_str(PT_NAME));
     2437 +                                goto bad;
     2438 +                        }
     2439 +                        (void) strlcpy(np->zone_res_attr_name, cp->cp_value,
     2440 +                            sizeof (np->zone_res_attr_name));
     2441 +                        seen_name = B_TRUE;
     2442 +                        break;
     2443 +                case PT_VALUE:
     2444 +                        if (seen_value) {
     2445 +                                zerr(gettext("%s already specified"),
     2446 +                                    pt_to_str(PT_VALUE));
     2447 +                                goto bad;
     2448 +                        }
     2449 +                        (void) strlcpy(np->zone_res_attr_value, cp->cp_value,
     2450 +                            sizeof (np->zone_res_attr_value));
     2451 +                        seen_value = B_TRUE;
     2452 +                        break;
     2453 +                default:
     2454 +                        zone_perror(pt_to_str(PT_NPROP), Z_NO_PROPERTY_TYPE,
     2455 +                            B_TRUE);
     2456 +                        long_usage(CMD_ADD, B_TRUE);
     2457 +                        usage(B_FALSE, HELP_PROPS);
     2458 +                        zonecfg_free_res_attr_list(np);
     2459 +                        return;
     2460 +                }
     2461 +        }
     2462 +
     2463 +        if (!seen_name)
     2464 +                zerr(gettext("%s not specified"), pt_to_str(PT_NAME));
     2465 +        if (!seen_value)
     2466 +                zerr(gettext("%s not specified"), pt_to_str(PT_VALUE));
     2467 +
     2468 +        err = zonecfg_add_res_attr(headp, np);
     2469 +        if (err != Z_OK)
     2470 +                zone_perror(pt_to_str(PT_NPROP), err, B_TRUE);
     2471 +        return;
     2472 +
     2473 +bad:
     2474 +        zonecfg_free_res_attr_list(np);
     2475 +}
     2476 +
     2477 +static void
2363 2478  add_property(cmd_t *cmd)
2364 2479  {
2365 2480          char *prop_id;
2366 2481          int err, res_type, prop_type;
2367 2482          property_value_ptr_t pp;
2368 2483          list_property_ptr_t l;
2369 2484  
2370 2485          res_type = resource_scope;
2371 2486          prop_type = cmd->cmd_prop_name[0];
2372 2487          if (res_type == RT_UNKNOWN || prop_type == PT_UNKNOWN) {
↓ open down ↓ 46 lines elided ↑ open up ↑
2419 2534                                  if (prop_id == NULL)
2420 2535                                          break;
2421 2536                                  err = zonecfg_add_fs_option(
2422 2537                                      &in_progress_fstab, prop_id);
2423 2538                                  if (err != Z_OK)
2424 2539                                          zone_perror(pt_to_str(prop_type), err,
2425 2540                                              B_TRUE);
2426 2541                          }
2427 2542                  }
2428 2543                  return;
     2544 +        case RT_NET:
     2545 +                if (prop_type != PT_NPROP) {
     2546 +                        zone_perror(pt_to_str(prop_type), Z_NO_PROPERTY_TYPE,
     2547 +                            B_TRUE);
     2548 +                        long_usage(CMD_ADD, B_TRUE);
     2549 +                        usage(B_FALSE, HELP_PROPS);
     2550 +                        return;
     2551 +                }
     2552 +                pp = cmd->cmd_property_ptr[0];
     2553 +                if (pp->pv_type != PROP_VAL_COMPLEX) {
     2554 +                        zerr(gettext("A %s value was expected here."),
     2555 +                            pvt_to_str(PROP_VAL_COMPLEX));
     2556 +                        saw_error = B_TRUE;
     2557 +                        return;
     2558 +                }
     2559 +
     2560 +                do_res_attr(&(in_progress_nwiftab.zone_nwif_attrp),
     2561 +                    pp->pv_complex);
     2562 +                return;
     2563 +        case RT_DEVICE:
     2564 +                if (prop_type != PT_NPROP) {
     2565 +                        zone_perror(pt_to_str(prop_type), Z_NO_PROPERTY_TYPE,
     2566 +                            B_TRUE);
     2567 +                        long_usage(CMD_ADD, B_TRUE);
     2568 +                        usage(B_FALSE, HELP_PROPS);
     2569 +                        return;
     2570 +                }
     2571 +                pp = cmd->cmd_property_ptr[0];
     2572 +                if (pp->pv_type != PROP_VAL_COMPLEX) {
     2573 +                        zerr(gettext("A %s value was expected here."),
     2574 +                            pvt_to_str(PROP_VAL_COMPLEX));
     2575 +                        saw_error = B_TRUE;
     2576 +                        return;
     2577 +                }
     2578 +
     2579 +                do_res_attr(&(in_progress_devtab.zone_dev_attrp),
     2580 +                    pp->pv_complex);
     2581 +                return;
2429 2582          case RT_RCTL:
2430 2583                  if (prop_type != PT_VALUE) {
2431 2584                          zone_perror(pt_to_str(prop_type), Z_NO_PROPERTY_TYPE,
2432 2585                              B_TRUE);
2433 2586                          long_usage(CMD_ADD, B_TRUE);
2434 2587                          usage(B_FALSE, HELP_PROPS);
2435 2588                          return;
2436 2589                  }
2437 2590                  pp = cmd->cmd_property_ptr[0];
2438 2591                  if (pp->pv_type != PROP_VAL_COMPLEX &&
↓ open down ↓ 84 lines elided ↑ open up ↑
2523 2676                          zerr(gettext("Cannot add a %s resource to the "
2524 2677                              "global zone."), rt_to_str(cmd->cmd_res_type));
2525 2678                          saw_error = B_TRUE;
2526 2679                          return;
2527 2680                  }
2528 2681  
2529 2682                  global_scope = B_FALSE;
2530 2683                  resource_scope = cmd->cmd_res_type;
2531 2684                  end_op = CMD_ADD;
2532 2685                  add_resource(cmd);
2533      -        } else
     2686 +        } else {
2534 2687                  add_property(cmd);
     2688 +        }
2535 2689  }
2536 2690  
2537 2691  /*
2538 2692   * This routine has an unusual implementation, because it tries very
2539 2693   * hard to succeed in the face of a variety of failure modes.
2540 2694   * The most common and most vexing occurs when the index file and
2541 2695   * the /etc/zones/<zonename.xml> file are not both present.  In
2542 2696   * this case, delete must eradicate as much of the zone state as is left
2543 2697   * so that the user can later create a new zone with the same name.
2544 2698   */
↓ open down ↓ 177 lines elided ↑ open up ↑
2722 2876                  case PT_ALLOWED_ADDRESS:
2723 2877                          (void) strlcpy(nwiftab->zone_nwif_allowed_address,
2724 2878                              pp->pv_simple,
2725 2879                              sizeof (nwiftab->zone_nwif_allowed_address));
2726 2880                          break;
2727 2881                  case PT_PHYSICAL:
2728 2882                          (void) strlcpy(nwiftab->zone_nwif_physical,
2729 2883                              pp->pv_simple,
2730 2884                              sizeof (nwiftab->zone_nwif_physical));
2731 2885                          break;
     2886 +                case PT_MAC:
     2887 +                        (void) strlcpy(nwiftab->zone_nwif_mac,
     2888 +                            pp->pv_simple,
     2889 +                            sizeof (nwiftab->zone_nwif_mac));
     2890 +                        break;
     2891 +                case PT_VLANID:
     2892 +                        (void) strlcpy(nwiftab->zone_nwif_vlan_id,
     2893 +                            pp->pv_simple,
     2894 +                            sizeof (nwiftab->zone_nwif_vlan_id));
     2895 +                        break;
     2896 +                case PT_GNIC:
     2897 +                        (void) strlcpy(nwiftab->zone_nwif_gnic,
     2898 +                            pp->pv_simple,
     2899 +                            sizeof (nwiftab->zone_nwif_gnic));
     2900 +                        break;
2732 2901                  case PT_DEFROUTER:
2733 2902                          (void) strlcpy(nwiftab->zone_nwif_defrouter,
2734 2903                              pp->pv_simple,
2735 2904                              sizeof (nwiftab->zone_nwif_defrouter));
2736 2905                          break;
2737 2906                  default:
2738 2907                          zone_perror(pt_to_str(cmd->cmd_prop_name[i]),
2739 2908                              Z_NO_PROPERTY_TYPE, B_TRUE);
2740 2909                          return (Z_INSUFFICIENT_SPEC);
2741 2910                  }
↓ open down ↓ 497 lines elided ↑ open up ↑
3239 3408                  z_cmd_rt_perror(CMD_REMOVE, RT_PCAP, err, B_TRUE);
3240 3409          else
3241 3410                  need_to_commit = B_TRUE;
3242 3411  }
3243 3412  
3244 3413  static void
3245 3414  remove_mcap()
3246 3415  {
3247 3416          int err, res1, res2, res3;
3248 3417          uint64_t tmp;
3249      -        struct zone_mcaptab mcaptab;
3250 3418          boolean_t revert = B_FALSE;
3251 3419  
3252      -        res1 = zonecfg_lookup_mcap(handle, &mcaptab);
     3420 +        res1 = zonecfg_get_aliased_rctl(handle, ALIAS_MAXPHYSMEM, &tmp);
3253 3421          res2 = zonecfg_get_aliased_rctl(handle, ALIAS_MAXSWAP, &tmp);
3254 3422          res3 = zonecfg_get_aliased_rctl(handle, ALIAS_MAXLOCKEDMEM, &tmp);
3255 3423  
3256 3424          /* if none of these exist, there is no resource to remove */
3257 3425          if (res1 != Z_OK && res2 != Z_OK && res3 != Z_OK) {
3258 3426                  zerr("%s %s: %s", cmd_to_str(CMD_REMOVE), rt_to_str(RT_MCAP),
3259 3427                      zonecfg_strerror(Z_NO_RESOURCE_TYPE));
3260 3428                  saw_error = B_TRUE;
3261 3429                  return;
3262 3430          }
3263 3431          if (res1 == Z_OK) {
3264      -                if ((err = zonecfg_delete_mcap(handle)) != Z_OK) {
     3432 +                if ((err = zonecfg_rm_aliased_rctl(handle, ALIAS_MAXPHYSMEM))
     3433 +                    != Z_OK) {
3265 3434                          z_cmd_rt_perror(CMD_REMOVE, RT_MCAP, err, B_TRUE);
3266 3435                          revert = B_TRUE;
3267 3436                  } else {
3268 3437                          need_to_commit = B_TRUE;
3269 3438                  }
3270 3439          }
     3440 +
3271 3441          if (res2 == Z_OK) {
3272 3442                  if ((err = zonecfg_rm_aliased_rctl(handle, ALIAS_MAXSWAP))
3273 3443                      != Z_OK) {
3274 3444                          z_cmd_rt_perror(CMD_REMOVE, RT_MCAP, err, B_TRUE);
3275 3445                          revert = B_TRUE;
3276 3446                  } else {
3277 3447                          need_to_commit = B_TRUE;
3278 3448                  }
3279 3449          }
3280 3450          if (res3 == Z_OK) {
↓ open down ↓ 122 lines elided ↑ open up ↑
3403 3573          }
3404 3574  }
3405 3575  
3406 3576  static void
3407 3577  remove_property(cmd_t *cmd)
3408 3578  {
3409 3579          char *prop_id;
3410 3580          int err, res_type, prop_type;
3411 3581          property_value_ptr_t pp;
3412 3582          struct zone_rctlvaltab *rctlvaltab;
     3583 +        struct zone_res_attrtab *np;
3413 3584          complex_property_ptr_t cx;
3414 3585  
3415 3586          res_type = resource_scope;
3416 3587          prop_type = cmd->cmd_prop_name[0];
3417 3588          if (res_type == RT_UNKNOWN || prop_type == PT_UNKNOWN) {
3418 3589                  long_usage(CMD_REMOVE, B_TRUE);
3419 3590                  return;
3420 3591          }
3421 3592  
3422 3593          if (cmd->cmd_prop_nv_pairs != 1) {
↓ open down ↓ 40 lines elided ↑ open up ↑
3463 3634                                  if (prop_id == NULL)
3464 3635                                          break;
3465 3636                                  err = zonecfg_remove_fs_option(
3466 3637                                      &in_progress_fstab, prop_id);
3467 3638                                  if (err != Z_OK)
3468 3639                                          zone_perror(pt_to_str(prop_type), err,
3469 3640                                              B_TRUE);
3470 3641                          }
3471 3642                  }
3472 3643                  return;
     3644 +        case RT_NET:            /* FALLTHRU */
     3645 +        case RT_DEVICE:
     3646 +                if (prop_type != PT_NPROP) {
     3647 +                        zone_perror(pt_to_str(prop_type), Z_NO_PROPERTY_TYPE,
     3648 +                            B_TRUE);
     3649 +                        long_usage(CMD_REMOVE, B_TRUE);
     3650 +                        usage(B_FALSE, HELP_PROPS);
     3651 +                        return;
     3652 +                }
     3653 +                pp = cmd->cmd_property_ptr[0];
     3654 +                if (pp->pv_type != PROP_VAL_COMPLEX) {
     3655 +                        zerr(gettext("A %s value was expected here."),
     3656 +                            pvt_to_str(PROP_VAL_COMPLEX));
     3657 +                        saw_error = B_TRUE;
     3658 +                        return;
     3659 +                }
     3660 +
     3661 +                np = alloca(sizeof (struct zone_res_attrtab));
     3662 +                for (cx = pp->pv_complex; cx != NULL; cx = cx->cp_next) {
     3663 +                        switch (cx->cp_type) {
     3664 +                        case PT_NAME:
     3665 +                                (void) strlcpy(np->zone_res_attr_name,
     3666 +                                    cx->cp_value,
     3667 +                                    sizeof (np->zone_res_attr_name));
     3668 +                                break;
     3669 +                        case PT_VALUE:
     3670 +                                (void) strlcpy(np->zone_res_attr_value,
     3671 +                                    cx->cp_value,
     3672 +                                    sizeof (np->zone_res_attr_value));
     3673 +                                break;
     3674 +                        default:
     3675 +                                zone_perror(pt_to_str(prop_type),
     3676 +                                    Z_NO_PROPERTY_TYPE, B_TRUE);
     3677 +                                long_usage(CMD_REMOVE, B_TRUE);
     3678 +                                usage(B_FALSE, HELP_PROPS);
     3679 +                                return;
     3680 +                        }
     3681 +                }
     3682 +                np->zone_res_attr_next = NULL;
     3683 +
     3684 +                if (res_type == RT_NET) {
     3685 +                        err = zonecfg_remove_res_attr(
     3686 +                            &(in_progress_nwiftab.zone_nwif_attrp), np);
     3687 +                } else {                                /* RT_DEVICE */
     3688 +                        err = zonecfg_remove_res_attr(
     3689 +                            &(in_progress_devtab.zone_dev_attrp), np);
     3690 +                }
     3691 +                if (err != Z_OK)
     3692 +                        zone_perror(pt_to_str(prop_type), err, B_TRUE);
     3693 +                return;
3473 3694          case RT_RCTL:
3474 3695                  if (prop_type != PT_VALUE) {
3475 3696                          zone_perror(pt_to_str(prop_type), Z_NO_PROPERTY_TYPE,
3476 3697                              B_TRUE);
3477 3698                          long_usage(CMD_REMOVE, B_TRUE);
3478 3699                          usage(B_FALSE, HELP_PROPS);
3479 3700                          return;
3480 3701                  }
3481 3702                  pp = cmd->cmd_property_ptr[0];
3482 3703                  if (pp->pv_type != PROP_VAL_COMPLEX) {
↓ open down ↓ 32 lines elided ↑ open up ↑
3515 3736                                  return;
3516 3737                          }
3517 3738                  }
3518 3739                  rctlvaltab->zone_rctlval_next = NULL;
3519 3740                  err = zonecfg_remove_rctl_value(&in_progress_rctltab,
3520 3741                      rctlvaltab);
3521 3742                  if (err != Z_OK)
3522 3743                          zone_perror(pt_to_str(prop_type), err, B_TRUE);
3523 3744                  zonecfg_free_rctl_value_list(rctlvaltab);
3524 3745                  return;
3525      -        case RT_NET:
3526      -                if (prop_type != PT_DEFROUTER) {
3527      -                        zone_perror(pt_to_str(prop_type), Z_NO_PROPERTY_TYPE,
3528      -                            B_TRUE);
3529      -                        long_usage(CMD_REMOVE, B_TRUE);
3530      -                        usage(B_FALSE, HELP_PROPS);
3531      -                        return;
3532      -                } else {
3533      -                        bzero(&in_progress_nwiftab.zone_nwif_defrouter,
3534      -                            sizeof (in_progress_nwiftab.zone_nwif_defrouter));
3535      -                        return;
3536      -                }
3537 3746          default:
3538 3747                  zone_perror(rt_to_str(res_type), Z_NO_RESOURCE_TYPE, B_TRUE);
3539 3748                  long_usage(CMD_REMOVE, B_TRUE);
3540 3749                  usage(B_FALSE, HELP_RESOURCES);
3541 3750                  return;
3542 3751          }
3543 3752  }
3544 3753  
3545 3754  void
3546 3755  remove_func(cmd_t *cmd)
↓ open down ↓ 42 lines elided ↑ open up ↑
3589 3798          case RT_DCPU:
3590 3799                  if (prop_type == PT_IMPORTANCE) {
3591 3800                          in_progress_psettab.zone_importance[0] = '\0';
3592 3801                          need_to_commit = B_TRUE;
3593 3802                          return;
3594 3803                  }
3595 3804                  break;
3596 3805          case RT_MCAP:
3597 3806                  switch (prop_type) {
3598 3807                  case PT_PHYSICAL:
3599      -                        in_progress_mcaptab.zone_physmem_cap[0] = '\0';
3600      -                        need_to_commit = B_TRUE;
     3808 +                        remove_aliased_rctl(PT_PHYSICAL, ALIAS_MAXPHYSMEM);
3601 3809                          return;
3602 3810                  case PT_SWAP:
3603 3811                          remove_aliased_rctl(PT_SWAP, ALIAS_MAXSWAP);
3604 3812                          return;
3605 3813                  case PT_LOCKED:
3606 3814                          remove_aliased_rctl(PT_LOCKED, ALIAS_MAXLOCKEDMEM);
3607 3815                          return;
3608 3816                  }
3609 3817                  break;
     3818 +        case RT_NET:
     3819 +                switch (prop_type) {
     3820 +                case PT_ALLOWED_ADDRESS:
     3821 +                        in_progress_nwiftab.zone_nwif_allowed_address[0] = '\0';
     3822 +                        need_to_commit = B_TRUE;
     3823 +                        return;
     3824 +                case PT_DEFROUTER:
     3825 +                        in_progress_nwiftab.zone_nwif_defrouter[0] = '\0';
     3826 +                        need_to_commit = B_TRUE;
     3827 +                        return;
     3828 +                case PT_GNIC:
     3829 +                        in_progress_nwiftab.zone_nwif_gnic[0] = '\0';
     3830 +                        need_to_commit = B_TRUE;
     3831 +                        return;
     3832 +                case PT_MAC:
     3833 +                        in_progress_nwiftab.zone_nwif_mac[0] = '\0';
     3834 +                        need_to_commit = B_TRUE;
     3835 +                        return;
     3836 +                case PT_VLANID:
     3837 +                        in_progress_nwiftab.zone_nwif_vlan_id[0] = '\0';
     3838 +                        need_to_commit = B_TRUE;
     3839 +                        return;
     3840 +                }
     3841 +                break;
3610 3842          default:
3611 3843                  break;
3612 3844          }
3613 3845  
3614 3846          zone_perror(pt_to_str(prop_type), Z_CLEAR_DISALLOW, B_TRUE);
3615 3847  }
3616 3848  
3617 3849  static void
3618 3850  clear_global(cmd_t *cmd)
3619 3851  {
↓ open down ↓ 112 lines elided ↑ open up ↑
3732 3964  
3733 3965                  clear_global(cmd);
3734 3966          } else {
3735 3967                  clear_property(cmd);
3736 3968          }
3737 3969  }
3738 3970  
3739 3971  void
3740 3972  select_func(cmd_t *cmd)
3741 3973  {
3742      -        int type, err, res;
     3974 +        int type, err;
3743 3975          uint64_t limit;
3744 3976          uint64_t tmp;
3745 3977  
3746 3978          if (zone_is_read_only(CMD_SELECT))
3747 3979                  return;
3748 3980  
3749 3981          assert(cmd != NULL);
3750 3982  
3751 3983          if (global_scope) {
3752 3984                  global_scope = B_FALSE;
↓ open down ↓ 74 lines elided ↑ open up ↑
3827 4059                  return;
3828 4060          case RT_PCAP:
3829 4061                  if ((err = zonecfg_get_aliased_rctl(handle, ALIAS_CPUCAP, &tmp))
3830 4062                      != Z_OK) {
3831 4063                          z_cmd_rt_perror(CMD_SELECT, RT_PCAP, err, B_TRUE);
3832 4064                          global_scope = B_TRUE;
3833 4065                  }
3834 4066                  return;
3835 4067          case RT_MCAP:
3836 4068                  /* if none of these exist, there is no resource to select */
3837      -                if ((res = zonecfg_lookup_mcap(handle, &old_mcaptab)) != Z_OK &&
     4069 +                if (zonecfg_get_aliased_rctl(handle, ALIAS_MAXPHYSMEM, &limit)
     4070 +                    != Z_OK &&
3838 4071                      zonecfg_get_aliased_rctl(handle, ALIAS_MAXSWAP, &limit)
3839 4072                      != Z_OK &&
3840 4073                      zonecfg_get_aliased_rctl(handle, ALIAS_MAXLOCKEDMEM, &limit)
3841 4074                      != Z_OK) {
3842 4075                          z_cmd_rt_perror(CMD_SELECT, RT_MCAP, Z_NO_RESOURCE_TYPE,
3843 4076                              B_TRUE);
3844 4077                          global_scope = B_TRUE;
3845 4078                  }
3846      -                if (res == Z_OK)
3847      -                        bcopy(&old_mcaptab, &in_progress_mcaptab,
3848      -                            sizeof (struct zone_mcaptab));
3849      -                else
3850      -                        bzero(&in_progress_mcaptab,
3851      -                            sizeof (in_progress_mcaptab));
3852 4079                  return;
3853 4080          case RT_ADMIN:
3854 4081                  if ((err = fill_in_admintab(cmd, &old_admintab, B_FALSE))
3855 4082                      != Z_OK) {
3856 4083                          z_cmd_rt_perror(CMD_SELECT, RT_ADMIN, err,
3857 4084                              B_TRUE);
3858 4085                          global_scope = B_TRUE;
3859 4086                  }
3860 4087                  bcopy(&old_admintab, &in_progress_admintab,
3861 4088                      sizeof (struct zone_admintab));
↓ open down ↓ 246 lines elided ↑ open up ↑
4108 4335  
4109 4336  void
4110 4337  set_func(cmd_t *cmd)
4111 4338  {
4112 4339          char *prop_id;
4113 4340          int arg, err, res_type, prop_type;
4114 4341          property_value_ptr_t pp;
4115 4342          boolean_t autoboot;
4116 4343          zone_iptype_t iptype;
4117 4344          boolean_t force_set = B_FALSE;
4118      -        size_t physmem_size = sizeof (in_progress_mcaptab.zone_physmem_cap);
4119 4345          uint64_t mem_cap, mem_limit;
4120      -        float cap;
     4346 +        double cap;
4121 4347          char *unitp;
4122 4348          struct zone_psettab tmp_psettab;
4123 4349          boolean_t arg_err = B_FALSE;
4124 4350  
4125 4351          if (zone_is_read_only(CMD_SET))
4126 4352                  return;
4127 4353  
4128 4354          assert(cmd != NULL);
4129 4355  
4130 4356          optind = opterr = 0;
↓ open down ↓ 81 lines elided ↑ open up ↑
4212 4438                          saw_error = B_TRUE;
4213 4439                          return;
4214 4440                  }
4215 4441          }
4216 4442  
4217 4443          pp = cmd->cmd_property_ptr[0];
4218 4444          /*
4219 4445           * A nasty expression but not that complicated:
4220 4446           * 1. fs options are simple or list (tested below)
4221 4447           * 2. rctl value's are complex or list (tested below)
     4448 +         * 3. net attr's are complex (tested below)
4222 4449           * Anything else should be simple.
4223 4450           */
4224 4451          if (!(res_type == RT_FS && prop_type == PT_OPTIONS) &&
4225 4452              !(res_type == RT_RCTL && prop_type == PT_VALUE) &&
     4453 +            !(res_type == RT_NET && prop_type == PT_NPROP) &&
4226 4454              (pp->pv_type != PROP_VAL_SIMPLE ||
4227 4455              (prop_id = pp->pv_simple) == NULL)) {
4228 4456                  zerr(gettext("A %s value was expected here."),
4229 4457                      pvt_to_str(PROP_VAL_SIMPLE));
4230 4458                  saw_error = B_TRUE;
4231 4459                  return;
4232 4460          }
4233 4461          if (prop_type == PT_UNKNOWN) {
4234 4462                  long_usage(CMD_SET, B_TRUE);
4235 4463                  return;
↓ open down ↓ 239 lines elided ↑ open up ↑
4475 4703                          break;
4476 4704                  case PT_PHYSICAL:
4477 4705                          if (validate_net_physical_syntax(prop_id) != Z_OK) {
4478 4706                                  saw_error = B_TRUE;
4479 4707                                  return;
4480 4708                          }
4481 4709                          (void) strlcpy(in_progress_nwiftab.zone_nwif_physical,
4482 4710                              prop_id,
4483 4711                              sizeof (in_progress_nwiftab.zone_nwif_physical));
4484 4712                          break;
     4713 +                case PT_MAC:
     4714 +                        (void) strlcpy(in_progress_nwiftab.zone_nwif_mac,
     4715 +                            prop_id,
     4716 +                            sizeof (in_progress_nwiftab.zone_nwif_mac));
     4717 +                        break;
     4718 +                case PT_VLANID:
     4719 +                        (void) strlcpy(in_progress_nwiftab.zone_nwif_vlan_id,
     4720 +                            prop_id,
     4721 +                            sizeof (in_progress_nwiftab.zone_nwif_vlan_id));
     4722 +                        break;
     4723 +                case PT_GNIC:
     4724 +                        (void) strlcpy(in_progress_nwiftab.zone_nwif_gnic,
     4725 +                            prop_id,
     4726 +                            sizeof (in_progress_nwiftab.zone_nwif_gnic));
     4727 +                        break;
4485 4728                  case PT_DEFROUTER:
4486 4729                          if (validate_net_address_syntax(prop_id, B_TRUE)
4487 4730                              != Z_OK) {
4488 4731                                  saw_error = B_TRUE;
4489 4732                                  return;
4490 4733                          }
4491 4734                          (void) strlcpy(in_progress_nwiftab.zone_nwif_defrouter,
4492 4735                              prop_id,
4493 4736                              sizeof (in_progress_nwiftab.zone_nwif_defrouter));
4494 4737                          break;
     4738 +                case PT_NPROP:
     4739 +                        if (pp->pv_type != PROP_VAL_COMPLEX) {
     4740 +                                zerr(gettext("A %s value was expected here."),
     4741 +                                    pvt_to_str(PROP_VAL_COMPLEX));
     4742 +                                saw_error = B_TRUE;
     4743 +                                return;
     4744 +                        }
     4745 +                        zonecfg_free_res_attr_list(
     4746 +                            in_progress_nwiftab.zone_nwif_attrp);
     4747 +                        in_progress_nwiftab.zone_nwif_attrp = NULL;
     4748 +                        if (!(pp->pv_type == PROP_VAL_LIST &&
     4749 +                            pp->pv_list == NULL))
     4750 +                                add_property(cmd);
     4751 +                        break;
4495 4752                  default:
4496 4753                          zone_perror(pt_to_str(prop_type), Z_NO_PROPERTY_TYPE,
4497 4754                              B_TRUE);
4498 4755                          long_usage(CMD_SET, B_TRUE);
4499 4756                          usage(B_FALSE, HELP_PROPS);
4500 4757                          return;
4501 4758                  }
4502 4759                  return;
4503 4760          case RT_DEVICE:
4504 4761                  switch (prop_type) {
4505 4762                  case PT_MATCH:
4506 4763                          (void) strlcpy(in_progress_devtab.zone_dev_match,
4507 4764                              prop_id,
4508 4765                              sizeof (in_progress_devtab.zone_dev_match));
4509 4766                          break;
     4767 +                case PT_NPROP:
     4768 +                        if (pp->pv_type != PROP_VAL_COMPLEX) {
     4769 +                                zerr(gettext("A %s value was expected here."),
     4770 +                                    pvt_to_str(PROP_VAL_COMPLEX));
     4771 +                                saw_error = B_TRUE;
     4772 +                                return;
     4773 +                        }
     4774 +                        zonecfg_free_res_attr_list(
     4775 +                            in_progress_devtab.zone_dev_attrp);
     4776 +                        in_progress_devtab.zone_dev_attrp = NULL;
     4777 +                        if (!(pp->pv_type == PROP_VAL_LIST &&
     4778 +                            pp->pv_list == NULL))
     4779 +                                add_property(cmd);
     4780 +                        break;
4510 4781                  default:
4511 4782                          zone_perror(pt_to_str(prop_type), Z_NO_PROPERTY_TYPE,
4512 4783                              B_TRUE);
4513 4784                          long_usage(CMD_SET, B_TRUE);
4514 4785                          usage(B_FALSE, HELP_PROPS);
4515 4786                          return;
4516 4787                  }
4517 4788                  return;
4518 4789          case RT_RCTL:
4519 4790                  switch (prop_type) {
↓ open down ↓ 123 lines elided ↑ open up ↑
4643 4914                          long_usage(CMD_SET, B_TRUE);
4644 4915                          usage(B_FALSE, HELP_PROPS);
4645 4916                          return;
4646 4917                  }
4647 4918  
4648 4919                  /*
4649 4920                   * We already checked that an rctl alias is allowed in
4650 4921                   * the add_resource() function.
4651 4922                   */
4652 4923  
4653      -                if ((cap = strtof(prop_id, &unitp)) <= 0 || *unitp != '\0' ||
4654      -                    (int)(cap * 100) < 1) {
     4924 +                if ((cap = strtod(prop_id, &unitp)) <= 0 || *unitp != '\0' ||
     4925 +                    (cap * 100.0) < 1) {
4655 4926                          zerr(gettext("%s property is out of range."),
4656 4927                              pt_to_str(PT_NCPUS));
4657 4928                          saw_error = B_TRUE;
4658 4929                          return;
4659 4930                  }
     4931 +                cap *= 100.0;
4660 4932  
     4933 +                /* To avoid rounding issues add .5 to force correct value. */
4661 4934                  if ((err = zonecfg_set_aliased_rctl(handle, ALIAS_CPUCAP,
4662      -                    (int)(cap * 100))) != Z_OK)
     4935 +                    (uint_t)(cap + 0.5))) != Z_OK) {
4663 4936                          zone_perror(zone, err, B_TRUE);
4664      -                else
     4937 +                } else {
4665 4938                          need_to_commit = B_TRUE;
     4939 +                }
4666 4940                  return;
4667 4941          case RT_MCAP:
4668 4942                  switch (prop_type) {
4669 4943                  case PT_PHYSICAL:
     4944 +                        /*
     4945 +                         * We have to check if an rctl is allowed here since
     4946 +                         * there might already be a rctl defined that blocks
     4947 +                         * the alias.
     4948 +                         */
     4949 +                        if (!zonecfg_aliased_rctl_ok(handle,
     4950 +                            ALIAS_MAXPHYSMEM)) {
     4951 +                                zone_perror(pt_to_str(PT_LOCKED),
     4952 +                                    Z_ALIAS_DISALLOW, B_FALSE);
     4953 +                                saw_error = B_TRUE;
     4954 +                                return;
     4955 +                        }
     4956 +
4670 4957                          if (!zonecfg_valid_memlimit(prop_id, &mem_cap)) {
4671      -                                zerr(gettext("A positive number with a "
     4958 +                                zerr(gettext("A non-negative number with a "
4672 4959                                      "required scale suffix (K, M, G or T) was "
4673      -                                    "expected here."));
     4960 +                                    "expected\nhere."));
4674 4961                                  saw_error = B_TRUE;
4675      -                        } else if (mem_cap < ONE_MB) {
4676      -                                zerr(gettext("%s value is too small.  It must "
4677      -                                    "be at least 1M."), pt_to_str(PT_PHYSICAL));
4678      -                                saw_error = B_TRUE;
4679 4962                          } else {
4680      -                                snprintf(in_progress_mcaptab.zone_physmem_cap,
4681      -                                    physmem_size, "%llu", mem_cap);
     4963 +                                if ((err = zonecfg_set_aliased_rctl(handle,
     4964 +                                    ALIAS_MAXPHYSMEM, mem_cap)) != Z_OK)
     4965 +                                        zone_perror(zone, err, B_TRUE);
     4966 +                                else
     4967 +                                        need_to_commit = B_TRUE;
4682 4968                          }
4683 4969                          break;
4684 4970                  case PT_SWAP:
4685 4971                          /*
4686 4972                           * We have to check if an rctl is allowed here since
4687 4973                           * there might already be a rctl defined that blocks
4688 4974                           * the alias.
4689 4975                           */
4690 4976                          if (!zonecfg_aliased_rctl_ok(handle, ALIAS_MAXSWAP)) {
4691 4977                                  zone_perror(pt_to_str(PT_MAXSWAP),
↓ open down ↓ 332 lines elided ↑ open up ↑
5024 5310           * nothing to output.
5025 5311           */
5026 5312          if (!output && cmd->cmd_prop_nv_pairs > 0)
5027 5313                  (void) printf(gettext("No such %s resource.\n"),
5028 5314                      rt_to_str(RT_FS));
5029 5315  }
5030 5316  
5031 5317  static void
5032 5318  output_net(FILE *fp, struct zone_nwiftab *nwiftab)
5033 5319  {
     5320 +        struct zone_res_attrtab *np;
     5321 +
5034 5322          (void) fprintf(fp, "%s:\n", rt_to_str(RT_NET));
5035 5323          output_prop(fp, PT_ADDRESS, nwiftab->zone_nwif_address, B_TRUE);
5036 5324          output_prop(fp, PT_ALLOWED_ADDRESS,
5037 5325              nwiftab->zone_nwif_allowed_address, B_TRUE);
5038      -        output_prop(fp, PT_PHYSICAL, nwiftab->zone_nwif_physical, B_TRUE);
5039 5326          output_prop(fp, PT_DEFROUTER, nwiftab->zone_nwif_defrouter, B_TRUE);
     5327 +        output_prop(fp, PT_GNIC, nwiftab->zone_nwif_gnic, B_TRUE);
     5328 +        output_prop(fp, PT_MAC, nwiftab->zone_nwif_mac, B_TRUE);
     5329 +        output_prop(fp, PT_PHYSICAL, nwiftab->zone_nwif_physical, B_TRUE);
     5330 +        output_prop(fp, PT_VLANID, nwiftab->zone_nwif_vlan_id, B_TRUE);
     5331 +
     5332 +        for (np = nwiftab->zone_nwif_attrp; np != NULL;
     5333 +            np = np->zone_res_attr_next) {
     5334 +                fprintf(fp, "\t%s: (%s=%s,%s=\"%s\")\n",
     5335 +                    pt_to_str(PT_NPROP),
     5336 +                    pt_to_str(PT_NAME), np->zone_res_attr_name,
     5337 +                    pt_to_str(PT_VALUE), np->zone_res_attr_value);
     5338 +        }
5040 5339  }
5041 5340  
5042 5341  static void
5043 5342  info_net(zone_dochandle_t handle, FILE *fp, cmd_t *cmd)
5044 5343  {
5045 5344          struct zone_nwiftab lookup, user;
5046 5345          boolean_t output = B_FALSE;
5047 5346  
5048 5347          if (zonecfg_setnwifent(handle) != Z_OK)
5049 5348                  return;
↓ open down ↓ 22 lines elided ↑ open up ↑
5072 5371           * nothing to output.
5073 5372           */
5074 5373          if (!output && cmd->cmd_prop_nv_pairs > 0)
5075 5374                  (void) printf(gettext("No such %s resource.\n"),
5076 5375                      rt_to_str(RT_NET));
5077 5376  }
5078 5377  
5079 5378  static void
5080 5379  output_dev(FILE *fp, struct zone_devtab *devtab)
5081 5380  {
     5381 +        struct zone_res_attrtab *np;
     5382 +
5082 5383          (void) fprintf(fp, "%s:\n", rt_to_str(RT_DEVICE));
5083 5384          output_prop(fp, PT_MATCH, devtab->zone_dev_match, B_TRUE);
     5385 +
     5386 +        for (np = devtab->zone_dev_attrp; np != NULL;
     5387 +            np = np->zone_res_attr_next) {
     5388 +                fprintf(fp, "\t%s: (%s=%s,%s=\"%s\")\n",
     5389 +                    pt_to_str(PT_NPROP),
     5390 +                    pt_to_str(PT_NAME), np->zone_res_attr_name,
     5391 +                    pt_to_str(PT_VALUE), np->zone_res_attr_value);
     5392 +        }
5084 5393  }
5085 5394  
5086 5395  static void
5087 5396  info_dev(zone_dochandle_t handle, FILE *fp, cmd_t *cmd)
5088 5397  {
5089 5398          struct zone_devtab lookup, user;
5090 5399          boolean_t output = B_FALSE;
5091 5400  
5092 5401          if (zonecfg_setdevent(handle) != Z_OK)
5093 5402                  return;
↓ open down ↓ 238 lines elided ↑ open up ↑
5332 5641  
5333 5642          /* check if we should output a fraction.  snprintf will round for us */
5334 5643          if (save % 1024 != 0 && ((save >> 10) < 10))
5335 5644                  (void) snprintf(buf, bufsize, "%2.1f%c", ((float)save / 1024),
5336 5645                      *up);
5337 5646          else
5338 5647                  (void) snprintf(buf, bufsize, "%llu%c", num, *up);
5339 5648  }
5340 5649  
5341 5650  static void
5342      -output_mcap(FILE *fp, struct zone_mcaptab *mcaptab, int showswap,
     5651 +output_mcap(FILE *fp, int showphys, uint64_t maxphys, int showswap,
5343 5652      uint64_t maxswap, int showlocked, uint64_t maxlocked)
5344 5653  {
5345 5654          char buf[128];
5346 5655  
5347 5656          (void) fprintf(fp, "%s:\n", rt_to_str(RT_MCAP));
5348      -        if (mcaptab->zone_physmem_cap[0] != '\0') {
5349      -                bytes_to_units(mcaptab->zone_physmem_cap, buf, sizeof (buf));
5350      -                output_prop(fp, PT_PHYSICAL, buf, B_TRUE);
     5657 +
     5658 +        if (showphys == Z_OK) {
     5659 +                (void) snprintf(buf, sizeof (buf), "%llu", maxphys);
     5660 +                bytes_to_units(buf, buf, sizeof (buf));
     5661 +                /* Print directly since "physical" also is a net property. */
     5662 +                (void) fprintf(fp, "\t[%s: %s]\n", pt_to_str(PT_PHYSICAL), buf);
5351 5663          }
5352 5664  
5353 5665          if (showswap == Z_OK) {
5354 5666                  (void) snprintf(buf, sizeof (buf), "%llu", maxswap);
5355 5667                  bytes_to_units(buf, buf, sizeof (buf));
5356 5668                  output_prop(fp, PT_SWAP, buf, B_TRUE);
5357 5669          }
5358 5670  
5359 5671          if (showlocked == Z_OK) {
5360 5672                  (void) snprintf(buf, sizeof (buf), "%llu", maxlocked);
↓ open down ↓ 1 lines elided ↑ open up ↑
5362 5674                  output_prop(fp, PT_LOCKED, buf, B_TRUE);
5363 5675          }
5364 5676  }
5365 5677  
5366 5678  static void
5367 5679  info_mcap(zone_dochandle_t handle, FILE *fp)
5368 5680  {
5369 5681          int res1, res2, res3;
5370 5682          uint64_t swap_limit;
5371 5683          uint64_t locked_limit;
5372      -        struct zone_mcaptab lookup;
     5684 +        uint64_t phys_limit;
5373 5685  
5374      -        bzero(&lookup, sizeof (lookup));
5375      -        res1 = zonecfg_getmcapent(handle, &lookup);
     5686 +        res1 = zonecfg_get_aliased_rctl(handle, ALIAS_MAXPHYSMEM, &phys_limit);
5376 5687          res2 = zonecfg_get_aliased_rctl(handle, ALIAS_MAXSWAP, &swap_limit);
5377 5688          res3 = zonecfg_get_aliased_rctl(handle, ALIAS_MAXLOCKEDMEM,
5378 5689              &locked_limit);
5379 5690  
5380 5691          if (res1 == Z_OK || res2 == Z_OK || res3 == Z_OK)
5381      -                output_mcap(fp, &lookup, res2, swap_limit, res3, locked_limit);
     5692 +                output_mcap(fp, res1, phys_limit, res2, swap_limit,
     5693 +                    res3, locked_limit);
5382 5694  }
5383 5695  
5384 5696  static void
5385 5697  output_auth(FILE *fp, struct zone_admintab *admintab)
5386 5698  {
5387 5699          (void) fprintf(fp, "%s:\n", rt_to_str(RT_ADMIN));
5388 5700          output_prop(fp, PT_USER, admintab->zone_admin_user, B_TRUE);
5389 5701          output_prop(fp, PT_AUTHS, admintab->zone_admin_auths, B_TRUE);
5390 5702  }
5391 5703  
↓ open down ↓ 30 lines elided ↑ open up ↑
5422 5734                  (void) printf(gettext("No such %s resource.\n"),
5423 5735                      rt_to_str(RT_ADMIN));
5424 5736  }
5425 5737  
5426 5738  void
5427 5739  info_func(cmd_t *cmd)
5428 5740  {
5429 5741          FILE *fp = stdout;
5430 5742          boolean_t need_to_close = B_FALSE;
5431 5743          int type;
5432      -        int res1, res2;
     5744 +        int res1, res2, res3;
5433 5745          uint64_t swap_limit;
5434 5746          uint64_t locked_limit;
     5747 +        uint64_t phys_limit;
5435 5748  
5436 5749          assert(cmd != NULL);
5437 5750  
5438 5751          if (initialize(B_TRUE) != Z_OK)
5439 5752                  return;
5440 5753  
5441 5754          /* don't page error output */
5442 5755          if (interactive_mode) {
5443 5756                  if ((fp = pager_open()) != NULL)
5444 5757                          need_to_close = B_TRUE;
↓ open down ↓ 27 lines elided ↑ open up ↑
5472 5785                          output_pset(fp, &in_progress_psettab);
5473 5786                          break;
5474 5787                  case RT_PCAP:
5475 5788                          output_pcap(fp);
5476 5789                          break;
5477 5790                  case RT_MCAP:
5478 5791                          res1 = zonecfg_get_aliased_rctl(handle, ALIAS_MAXSWAP,
5479 5792                              &swap_limit);
5480 5793                          res2 = zonecfg_get_aliased_rctl(handle,
5481 5794                              ALIAS_MAXLOCKEDMEM, &locked_limit);
5482      -                        output_mcap(fp, &in_progress_mcaptab, res1, swap_limit,
     5795 +                        res3 = zonecfg_get_aliased_rctl(handle,
     5796 +                            ALIAS_MAXPHYSMEM, &phys_limit);
     5797 +                        output_mcap(fp, res3, phys_limit, res1, swap_limit,
5483 5798                              res2, locked_limit);
5484 5799                          break;
5485 5800                  case RT_ADMIN:
5486 5801                          output_auth(fp, &in_progress_admintab);
5487 5802                          break;
5488 5803                  }
5489 5804                  goto cleanup;
5490 5805          }
5491 5806  
5492 5807          type = cmd->cmd_res_type;
↓ open down ↓ 601 lines elided ↑ open up ↑
6094 6409  
6095 6410          if (!global_scope) {
6096 6411                  zerr(gettext("resource specification incomplete"));
6097 6412                  saw_error = B_TRUE;
6098 6413                  if (ret_val == Z_OK)
6099 6414                          ret_val = Z_INSUFFICIENT_SPEC;
6100 6415          }
6101 6416  
6102 6417          if (save) {
6103 6418                  if (ret_val == Z_OK) {
     6419 +                        /*
     6420 +                         * If the zone doesn't yet have a debug ID, set one now.
     6421 +                         */
     6422 +                        if (zonecfg_get_did(handle) == -1)
     6423 +                                zonecfg_set_did(handle);
     6424 +
6104 6425                          if ((ret_val = zonecfg_save(handle)) == Z_OK) {
6105 6426                                  need_to_commit = B_FALSE;
6106 6427                                  (void) strlcpy(revert_zone, zone,
6107 6428                                      sizeof (revert_zone));
6108 6429                          }
6109 6430                  } else {
6110 6431                          zerr(gettext("Zone %s failed to verify"), zone);
6111 6432                  }
6112 6433          }
6113 6434          if (ret_val != Z_OK)
↓ open down ↓ 154 lines elided ↑ open up ↑
6268 6589          struct zone_fstab tmp_fstab;
6269 6590          struct zone_nwiftab tmp_nwiftab;
6270 6591          struct zone_devtab tmp_devtab;
6271 6592          struct zone_rctltab tmp_rctltab;
6272 6593          struct zone_attrtab tmp_attrtab;
6273 6594          struct zone_dstab tmp_dstab;
6274 6595          struct zone_admintab tmp_admintab;
6275 6596          int err, arg, res1, res2, res3;
6276 6597          uint64_t swap_limit;
6277 6598          uint64_t locked_limit;
     6599 +        uint64_t phys_limit;
6278 6600          uint64_t proc_cap;
6279 6601  
6280 6602          assert(cmd != NULL);
6281 6603  
6282 6604          optind = 0;
6283 6605          while ((arg = getopt(cmd->cmd_argc, cmd->cmd_argv, "?")) != EOF) {
6284 6606                  switch (arg) {
6285 6607                  case '?':
6286 6608                          longer_usage(CMD_END);
6287 6609                          arg_err = B_TRUE;
↓ open down ↓ 283 lines elided ↑ open up ↑
6571 6893                      != Z_OK) {
6572 6894                          zerr(gettext("%s not specified"), pt_to_str(PT_NCPUS));
6573 6895                          saw_error = B_TRUE;
6574 6896                          validation_failed = B_TRUE;
6575 6897                          return;
6576 6898                  }
6577 6899                  err = Z_OK;
6578 6900                  break;
6579 6901          case RT_MCAP:
6580 6902                  /* Make sure everything was filled in. */
6581      -                res1 = strlen(in_progress_mcaptab.zone_physmem_cap) == 0 ?
6582      -                    Z_ERR : Z_OK;
     6903 +                res1 = zonecfg_get_aliased_rctl(handle, ALIAS_MAXPHYSMEM,
     6904 +                    &phys_limit);
6583 6905                  res2 = zonecfg_get_aliased_rctl(handle, ALIAS_MAXSWAP,
6584 6906                      &swap_limit);
6585 6907                  res3 = zonecfg_get_aliased_rctl(handle, ALIAS_MAXLOCKEDMEM,
6586 6908                      &locked_limit);
6587 6909  
6588 6910                  if (res1 != Z_OK && res2 != Z_OK && res3 != Z_OK) {
6589 6911                          zerr(gettext("No property was specified.  One of %s, "
6590 6912                              "%s or %s is required."), pt_to_str(PT_PHYSICAL),
6591 6913                              pt_to_str(PT_SWAP), pt_to_str(PT_LOCKED));
6592 6914                          saw_error = B_TRUE;
6593 6915                          return;
6594 6916                  }
6595 6917  
6596 6918                  /* if phys & locked are both set, verify locked <= phys */
6597 6919                  if (res1 == Z_OK && res3 == Z_OK) {
6598      -                        uint64_t phys_limit;
6599      -                        char *endp;
6600      -
6601      -                        phys_limit = strtoull(
6602      -                            in_progress_mcaptab.zone_physmem_cap, &endp, 10);
6603 6920                          if (phys_limit < locked_limit) {
6604 6921                                  zerr(gettext("The %s cap must be less than or "
6605 6922                                      "equal to the %s cap."),
6606 6923                                      pt_to_str(PT_LOCKED),
6607 6924                                      pt_to_str(PT_PHYSICAL));
6608 6925                                  saw_error = B_TRUE;
6609 6926                                  return;
6610 6927                          }
6611 6928                  }
6612 6929  
6613 6930                  err = Z_OK;
6614      -                if (res1 == Z_OK) {
6615      -                        /*
6616      -                         * We could be ending from either an add operation
6617      -                         * or a select operation.  Since all of the properties
6618      -                         * within this resource are optional, we always use
6619      -                         * modify on the mcap entry.  zonecfg_modify_mcap()
6620      -                         * will handle both adding and modifying a memory cap.
6621      -                         */
6622      -                        err = zonecfg_modify_mcap(handle, &in_progress_mcaptab);
6623      -                } else if (end_op == CMD_SELECT) {
6624      -                        /*
6625      -                         * If we're ending from a select and the physical
6626      -                         * memory cap is empty then the user could have cleared
6627      -                         * the physical cap value, so try to delete the entry.
6628      -                         */
6629      -                        (void) zonecfg_delete_mcap(handle);
6630      -                }
6631 6931                  break;
6632 6932          case RT_ADMIN:
6633 6933                  /* First make sure everything was filled in. */
6634 6934                  if (end_check_reqd(in_progress_admintab.zone_admin_user,
6635 6935                      PT_USER, &validation_failed) == Z_OK) {
6636 6936                          if (getpwnam(in_progress_admintab.zone_admin_user)
6637 6937                              == NULL) {
6638 6938                                  zerr(gettext("%s %s is not a valid username"),
6639 6939                                      pt_to_str(PT_USER),
6640 6940                                      in_progress_admintab.zone_admin_user);
↓ open down ↓ 660 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX