Print this page
*** NO COMMENTS ***

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libbe/common/be_list.c
          +++ new/usr/src/lib/libbe/common/be_list.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  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) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   */
  25   25  
  26   26  /*
  27      - * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
       27 + * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
  28   28   */
  29   29  
  30   30  #include <assert.h>
  31   31  #include <libintl.h>
  32   32  #include <libnvpair.h>
  33   33  #include <libzfs.h>
  34   34  #include <stdio.h>
  35   35  #include <stdlib.h>
  36   36  #include <string.h>
  37   37  #include <strings.h>
↓ open down ↓ 143 lines elided ↑ open up ↑
 181  181  
 182  182          /*
 183  183           * If be_name is NULL we'll look for all BE's on the system.
 184  184           * If not then we will only return data for the specified BE.
 185  185           */
 186  186          if (be_name != NULL)
 187  187                  cb.be_name = strdup(be_name);
 188  188  
 189  189          if (be_defaults.be_deflt_rpool_container && rpool != NULL) {
 190  190                  if ((zphp = zpool_open(g_zfs, rpool)) == NULL) {
 191      -                        be_print_err(gettext("be_get_node_data: failed to "
      191 +                        be_print_err(gettext("be_list: failed to "
 192  192                              "open rpool (%s): %s\n"), rpool,
 193  193                              libzfs_error_description(g_zfs));
 194  194                          free(cb.be_name);
 195  195                          return (zfs_err_to_be_err(g_zfs));
 196  196                  }
 197  197  
 198  198                  ret = be_get_list_callback(zphp, &cb);
 199  199          } else {
 200  200                  if ((zpool_iter(g_zfs, be_get_list_callback, &cb)) != 0) {
 201  201                          if (cb.be_nodes_head != NULL) {
↓ open down ↓ 615 lines elided ↑ open up ↑
 817  817          zfs_handle_t *zhp,
 818  818          be_node_list_t *be_node,
 819  819          char *be_name,
 820  820          const char *rpool,
 821  821          char *current_be,
 822  822          char *be_ds)
 823  823  {
 824  824          char prop_buf[MAXPATHLEN];
 825  825          nvlist_t *userprops = NULL;
 826  826          nvlist_t *propval = NULL;
      827 +        nvlist_t *zone_propval = NULL;
 827  828          char *prop_str = NULL;
      829 +        char *zone_prop_str = NULL;
 828  830          char *grub_default_bootfs = NULL;
 829  831          zpool_handle_t *zphp = NULL;
 830  832          int err = 0;
 831  833  
 832  834          if (be_node == NULL || be_name == NULL || current_be == NULL ||
 833  835              be_ds == NULL) {
 834  836                  be_print_err(gettext("be_get_node_data: invalid arguments, "
 835  837                      "can not be NULL\n"));
 836  838                  return (BE_ERR_INVAL);
 837  839          }
↓ open down ↓ 20 lines elided ↑ open up ↑
 858  860  
 859  861          be_node->be_rpool = strdup(rpool);
 860  862          if (be_node->be_rpool == NULL || (err = errno) != 0) {
 861  863                  be_print_err(gettext("be_get_node_data: failed to "
 862  864                      "copy root pool name\n"));
 863  865                  return (errno_to_be_err(err));
 864  866          }
 865  867  
 866  868          be_node->be_space_used = zfs_prop_get_int(zhp, ZFS_PROP_USED);
 867  869  
 868      -        if ((zphp = zpool_open(g_zfs, rpool)) == NULL) {
 869      -                be_print_err(gettext("be_get_node_data: failed to open pool "
 870      -                    "(%s): %s\n"), rpool, libzfs_error_description(g_zfs));
 871      -                return (zfs_err_to_be_err(g_zfs));
 872      -        }
      870 +        if (getzoneid() == GLOBAL_ZONEID) {
      871 +                if ((zphp = zpool_open(g_zfs, rpool)) == NULL) {
      872 +                        be_print_err(gettext("be_get_node_data: failed to open "
      873 +                            "pool (%s): %s\n"), rpool,
      874 +                            libzfs_error_description(g_zfs));
      875 +                        return (zfs_err_to_be_err(g_zfs));
      876 +                }
 873  877  
 874      -        (void) zpool_get_prop(zphp, ZPOOL_PROP_BOOTFS, prop_buf, ZFS_MAXPROPLEN,
 875      -            NULL);
 876      -        if (be_has_grub() &&
 877      -            (be_default_grub_bootfs(rpool, &grub_default_bootfs)
 878      -            == BE_SUCCESS) && grub_default_bootfs != NULL)
 879      -                if (strcmp(grub_default_bootfs, be_ds) == 0)
      878 +                (void) zpool_get_prop(zphp, ZPOOL_PROP_BOOTFS, prop_buf,
      879 +                    ZFS_MAXPROPLEN, NULL);
      880 +                if (be_has_grub() && (be_default_grub_bootfs(rpool,
      881 +                    &grub_default_bootfs) == BE_SUCCESS) &&
      882 +                    grub_default_bootfs != NULL)
      883 +                        if (strcmp(grub_default_bootfs, be_ds) == 0)
      884 +                                be_node->be_active_on_boot = B_TRUE;
      885 +                        else
      886 +                                be_node->be_active_on_boot = B_FALSE;
      887 +                else if (prop_buf != NULL && strcmp(prop_buf, be_ds) == 0)
 880  888                          be_node->be_active_on_boot = B_TRUE;
 881  889                  else
 882  890                          be_node->be_active_on_boot = B_FALSE;
 883      -        else if (prop_buf != NULL && strcmp(prop_buf, be_ds) == 0)
 884      -                be_node->be_active_on_boot = B_TRUE;
 885      -        else
 886      -                be_node->be_active_on_boot = B_FALSE;
 887      -        free(grub_default_bootfs);
 888      -        zpool_close(zphp);
 889  891  
      892 +                be_node->be_global_active = B_TRUE;
      893 +
      894 +                free(grub_default_bootfs);
      895 +                zpool_close(zphp);
      896 +        } else {
      897 +                if (be_zone_compare_uuids(be_node->be_root_ds))
      898 +                        be_node->be_global_active = B_TRUE;
      899 +                else
      900 +                        be_node->be_global_active = B_FALSE;
      901 +        }
      902 +
 890  903          /*
 891  904           * If the dataset is mounted use the mount point
 892  905           * returned from the zfs_is_mounted call. If the
 893  906           * dataset is not mounted then pull the mount
 894  907           * point information out of the zfs properties.
 895  908           */
 896  909          be_node->be_mounted = zfs_is_mounted(zhp,
 897  910              &(be_node->be_mntpt));
 898  911          if (!be_node->be_mounted) {
 899  912                  if (zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, prop_buf,
↓ open down ↓ 3 lines elided ↑ open up ↑
 903  916                          return (zfs_err_to_be_err(g_zfs));
 904  917          }
 905  918  
 906  919          be_node->be_node_creation = (time_t)zfs_prop_get_int(zhp,
 907  920              ZFS_PROP_CREATION);
 908  921  
 909  922          /* Get all user properties used for libbe */
 910  923          if ((userprops = zfs_get_user_props(zhp)) == NULL) {
 911  924                  be_node->be_policy_type = strdup(be_default_policy());
 912  925          } else {
      926 +                if (getzoneid() != GLOBAL_ZONEID) {
      927 +                        if (nvlist_lookup_nvlist(userprops,
      928 +                            BE_ZONE_ACTIVE_PROPERTY, &zone_propval) != 0 ||
      929 +                            zone_propval == NULL) {
      930 +                                be_node->be_active_on_boot = B_FALSE;
      931 +                        } else {
      932 +                                verify(nvlist_lookup_string(zone_propval,
      933 +                                    ZPROP_VALUE, &zone_prop_str) == 0);
      934 +                                if (strcmp(zone_prop_str, "on") == 0) {
      935 +                                        be_node->be_active_on_boot = B_TRUE;
      936 +                                } else {
      937 +                                        be_node->be_active_on_boot = B_FALSE;
      938 +                                }
      939 +                        }
      940 +                }
      941 +
 913  942                  if (nvlist_lookup_nvlist(userprops, BE_POLICY_PROPERTY,
 914  943                      &propval) != 0 || propval == NULL) {
 915  944                          be_node->be_policy_type =
 916  945                              strdup(be_default_policy());
 917  946                  } else {
 918  947                          verify(nvlist_lookup_string(propval, ZPROP_VALUE,
 919  948                              &prop_str) == 0);
 920  949                          if (prop_str == NULL || strcmp(prop_str, "-") == 0 ||
 921  950                              strcmp(prop_str, "") == 0)
 922  951                                  be_node->be_policy_type =
 923  952                                      strdup(be_default_policy());
 924  953                          else
 925  954                                  be_node->be_policy_type = strdup(prop_str);
 926  955                  }
 927      -
 928      -                if (nvlist_lookup_nvlist(userprops, BE_UUID_PROPERTY, &propval)
 929      -                    == 0 && nvlist_lookup_string(propval, ZPROP_VALUE,
 930      -                    &prop_str) == 0) {
 931      -                        be_node->be_uuid_str = strdup(prop_str);
      956 +                if (getzoneid() != GLOBAL_ZONEID) {
      957 +                        if (nvlist_lookup_nvlist(userprops,
      958 +                            BE_ZONE_PARENTBE_PROPERTY, &propval) != 0 &&
      959 +                            nvlist_lookup_string(propval, ZPROP_VALUE,
      960 +                            &prop_str) == 0) {
      961 +                                be_node->be_uuid_str = strdup(prop_str);
      962 +                        }
      963 +                } else {
      964 +                        if (nvlist_lookup_nvlist(userprops, BE_UUID_PROPERTY,
      965 +                            &propval) == 0 && nvlist_lookup_string(propval,
      966 +                            ZPROP_VALUE, &prop_str) == 0) {
      967 +                                be_node->be_uuid_str = strdup(prop_str);
      968 +                        }
 932  969                  }
 933  970          }
 934  971  
 935  972          /*
 936  973           * Increment the dataset counter to include the root dataset
 937  974           * of the BE.
 938  975           */
 939  976          be_node->be_node_num_datasets++;
 940  977  
 941  978          return (BE_SUCCESS);
↓ open down ↓ 223 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX