diff options
| author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2015-03-10 16:10:58 +0000 |
|---|---|---|
| committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2015-03-10 16:10:58 +0000 |
| commit | f0c8d695c23b09c138be7b6aef32258f3c29a933 (patch) | |
| tree | 2fdb7a38a99912ddddf16bd7ef453a54d1b6c9e8 /usr/src/cmd/zoneadm/zoneadm.c | |
| parent | d50bb8030991ebf3c68ad038e1fafc20a3617419 (diff) | |
| download | illumos-joyent-f0c8d695c23b09c138be7b6aef32258f3c29a933.tar.gz | |
OS-4019 zoneadm is slow with 1000s of zones
Diffstat (limited to 'usr/src/cmd/zoneadm/zoneadm.c')
| -rw-r--r-- | usr/src/cmd/zoneadm/zoneadm.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/usr/src/cmd/zoneadm/zoneadm.c b/usr/src/cmd/zoneadm/zoneadm.c index ab8016ede7..70962d1ea3 100644 --- a/usr/src/cmd/zoneadm/zoneadm.c +++ b/usr/src/cmd/zoneadm/zoneadm.c @@ -22,7 +22,7 @@ /* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2014 Nexenta Systems, Inc. All rights reserved. - * Copyright 2014, Joyent Inc. All rights reserved. + * Copyright 2015, Joyent Inc. All rights reserved. */ /* @@ -774,18 +774,22 @@ zone_print_list(zone_state_t min_state, boolean_t verbose, boolean_t parsable) * Retrieve a zone entry by name. Returns NULL if no such zone exists. */ static zone_entry_t * -lookup_running_zone(const char *str) +lookup_running_zone(const char *name) { - int i; + zoneid_t zid; + zone_entry_t *zent; - if (fetch_zents() != Z_OK) + if ((zid = getzoneidbyname(name)) == -1) return (NULL); - for (i = 0; i < nzents; i++) { - if (strcmp(str, zents[i].zname) == 0) - return (&zents[i]); + if ((zent = malloc(sizeof (zone_entry_t))) == NULL) + return (NULL); + + if (lookup_zone_info(name, zid, zent) != Z_OK) { + free(zent); + return (NULL); } - return (NULL); + return (zent); } /* |
