Print this page
OS-279 #pragma D option zone= does not work on installed, halted zones
OS-208 DTrace needs to use zone_did to match zone-limited enablings
INTRO-118 enabling USDT probes in zones should be more scalable

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libdtrace/common/dt_options.c
          +++ new/usr/src/lib/libdtrace/common/dt_options.c
↓ open down ↓ 33 lines elided ↑ open up ↑
  34   34  #include <sys/types.h>
  35   35  
  36   36  #include <strings.h>
  37   37  #include <signal.h>
  38   38  #include <stdlib.h>
  39   39  #include <unistd.h>
  40   40  #include <limits.h>
  41   41  #include <alloca.h>
  42   42  #include <errno.h>
  43   43  #include <fcntl.h>
       44 +#include <zone.h>
       45 +#include <libzonecfg.h>
  44   46  
  45   47  #include <dt_impl.h>
  46   48  #include <dt_string.h>
  47   49  
  48   50  static int
  49   51  dt_opt_agg(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
  50   52  {
  51   53          dt_aggregate_t *agp = &dtp->dt_aggregate;
  52   54  
  53   55          if (arg != NULL)
↓ open down ↓ 793 lines elided ↑ open up ↑
 847  849          }
 848  850  
 849  851          if (policy == DTRACEOPT_UNSET)
 850  852                  return (dt_set_errno(dtp, EDT_BADOPTVAL));
 851  853  
 852  854          dtp->dt_options[DTRACEOPT_BUFRESIZE] = policy;
 853  855  
 854  856          return (0);
 855  857  }
 856  858  
      859 +/*ARGSUSED*/
      860 +static int
      861 +dt_opt_zone(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
      862 +{
      863 +        zoneid_t z, did;
      864 +
      865 +        if (arg == NULL)
      866 +                return (dt_set_errno(dtp, EDT_BADOPTVAL));
      867 +
      868 +        /*
      869 +         * If the specified zone is currently running, we'll query the kernel
      870 +         * for its debugger ID.  If it doesn't appear to be running, we'll look
      871 +         * for it for among all installed zones (thereby allowing a zdefs
      872 +         * enabling against a halted zone).
      873 +         */
      874 +        if ((z = getzoneidbyname(arg)) != -1) {
      875 +                if (zone_getattr(z, ZONE_ATTR_DID, &did, sizeof (did)) < 0)
      876 +                        return (dt_set_errno(dtp, EDT_BADOPTVAL));
      877 +        } else {
      878 +                zone_dochandle_t handle;
      879 +
      880 +                if ((handle = zonecfg_init_handle()) == NULL)
      881 +                        return (dt_set_errno(dtp, errno));
      882 +
      883 +                if (zonecfg_get_handle(arg, handle) != Z_OK) {
      884 +                        zonecfg_fini_handle(handle);
      885 +                        return (dt_set_errno(dtp, EDT_BADOPTVAL));
      886 +                }
      887 +
      888 +                did = zonecfg_get_did(handle);
      889 +                zonecfg_fini_handle(handle);
      890 +        }
      891 +
      892 +        dtp->dt_options[DTRACEOPT_ZONE] = did;
      893 +
      894 +        return (0);
      895 +}
      896 +
 857  897  int
 858  898  dt_options_load(dtrace_hdl_t *dtp)
 859  899  {
 860  900          dof_hdr_t hdr, *dof;
 861  901          dof_sec_t *sec;
 862  902          size_t offs;
 863  903          int i;
 864  904  
 865  905          /*
 866  906           * To load the option values, we need to ask the kernel to provide its
↓ open down ↓ 120 lines elided ↑ open up ↑
 987 1027          { "grabanon", dt_opt_runtime, DTRACEOPT_GRABANON },
 988 1028          { "jstackframes", dt_opt_runtime, DTRACEOPT_JSTACKFRAMES },
 989 1029          { "jstackstrsize", dt_opt_size, DTRACEOPT_JSTACKSTRSIZE },
 990 1030          { "nspec", dt_opt_runtime, DTRACEOPT_NSPEC },
 991 1031          { "specsize", dt_opt_size, DTRACEOPT_SPECSIZE },
 992 1032          { "stackframes", dt_opt_runtime, DTRACEOPT_STACKFRAMES },
 993 1033          { "statusrate", dt_opt_rate, DTRACEOPT_STATUSRATE },
 994 1034          { "strsize", dt_opt_strsize, DTRACEOPT_STRSIZE },
 995 1035          { "ustackframes", dt_opt_runtime, DTRACEOPT_USTACKFRAMES },
 996 1036          { "temporal", dt_opt_runtime, DTRACEOPT_TEMPORAL },
     1037 +        { "zone", dt_opt_zone, DTRACEOPT_ZONE },
 997 1038          { NULL }
 998 1039  };
 999 1040  
1000 1041  /*
1001 1042   * Dynamic run-time options.
1002 1043   */
1003 1044  static const dt_option_t _dtrace_drtoptions[] = {
1004 1045          { "agghist", dt_opt_runtime, DTRACEOPT_AGGHIST },
1005 1046          { "aggpack", dt_opt_runtime, DTRACEOPT_AGGPACK },
1006 1047          { "aggrate", dt_opt_rate, DTRACEOPT_AGGRATE },
↓ open down ↓ 75 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX