diff options
| author | Bryan Cantrill <bryan@joyent.com> | 2011-03-02 22:42:28 -0800 |
|---|---|---|
| committer | Bryan Cantrill <bryan@joyent.com> | 2011-03-02 22:42:28 -0800 |
| commit | 26204c7d5048483a0c81c654800b77079cedeb8c (patch) | |
| tree | 92c2b787b32d62776f4b392d6081e4e3a67af40e /usr/src | |
| parent | 36089eb1d8a2aae733a3d36216923d599ac800ff (diff) | |
| download | illumos-joyent-26204c7d5048483a0c81c654800b77079cedeb8c.tar.gz | |
OS-279 #pragma D option zone= does not work on installed, halted zones
Diffstat (limited to 'usr/src')
| -rw-r--r-- | usr/src/lib/libdtrace/Makefile.com | 2 | ||||
| -rw-r--r-- | usr/src/lib/libdtrace/common/dt_options.c | 30 |
2 files changed, 19 insertions, 13 deletions
diff --git a/usr/src/lib/libdtrace/Makefile.com b/usr/src/lib/libdtrace/Makefile.com index c4f967fc71..0de9a76625 100644 --- a/usr/src/lib/libdtrace/Makefile.com +++ b/usr/src/lib/libdtrace/Makefile.com @@ -114,7 +114,7 @@ CPPFLAGS += -I../common -I. CFLAGS += $(CCVERBOSE) $(C_BIGPICFLAGS) CFLAGS64 += $(CCVERBOSE) $(C_BIGPICFLAGS) YYCFLAGS = -LDLIBS += -lgen -lproc -lrtld_db -lnsl -lsocket -lctf -lelf -lc +LDLIBS += -lgen -lproc -lrtld_db -lnsl -lsocket -lctf -lelf -lc -lzonecfg DRTILDLIBS = $(LDLIBS.lib) -lc yydebug := YYCFLAGS += -DYYDEBUG diff --git a/usr/src/lib/libdtrace/common/dt_options.c b/usr/src/lib/libdtrace/common/dt_options.c index cc5d1c8eed..c8b7829b32 100644 --- a/usr/src/lib/libdtrace/common/dt_options.c +++ b/usr/src/lib/libdtrace/common/dt_options.c @@ -41,6 +41,7 @@ #include <errno.h> #include <fcntl.h> #include <zone.h> +#include <libzonecfg.h> #include <dt_impl.h> #include <dt_string.h> @@ -787,29 +788,34 @@ dt_opt_bufresize(dtrace_hdl_t *dtp, const char *arg, uintptr_t option) static int dt_opt_zone(dtrace_hdl_t *dtp, const char *arg, uintptr_t option) { - dtrace_optval_t val = 0; zoneid_t z, did; if (arg == NULL) return (dt_set_errno(dtp, EDT_BADOPTVAL)); /* - * First attempt to treat the argument as a zone name; if that fails, - * treat it as an identifier (and validate that it corresponds to a - * zone). + * If the specified zone is currently running, we'll query the kernel + * for its debugger ID. If it doesn't appear to be running, we'll look + * for it for among all installed zones (thereby allowing a zdefs + * enabling against a halted zone). */ - if ((z = getzoneidbyname(arg)) == -1) { - char n[ZONENAME_MAX]; - - if (dt_optval_parse(arg, &val) != 0) + if ((z = getzoneidbyname(arg)) != -1) { + if (zone_getattr(z, ZONE_ATTR_DID, &did, sizeof (did)) < 0) return (dt_set_errno(dtp, EDT_BADOPTVAL)); + } else { + zone_dochandle_t handle; + + if ((handle = zonecfg_init_handle()) == NULL) + return (dt_set_errno(dtp, errno)); - if (getzonenamebyid(z = (zoneid_t)val, n, sizeof (n)) < 0) + if (zonecfg_get_handle(arg, handle) != Z_OK) { + zonecfg_fini_handle(handle); return (dt_set_errno(dtp, EDT_BADOPTVAL)); - } + } - if (zone_getattr(z, ZONE_ATTR_DID, &did, sizeof (did)) < 0) - return (dt_set_errno(dtp, EDT_BADOPTVAL)); + did = zonecfg_get_did(handle); + zonecfg_fini_handle(handle); + } dtp->dt_options[DTRACEOPT_ZONE] = did; |
