Print this page
patch zone-auto-create-be
*** 23,32 ****
--- 23,33 ----
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2015 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
*/
#include <assert.h>
#include <libintl.h>
#include <libnvpair.h>
*** 1388,1431 ****
char origin[MAXPATHLEN];
char zoneroot_ds[MAXPATHLEN];
zfs_handle_t *zhp = NULL;
zfs_handle_t *z_zhp = NULL;
zoneList_t zone_list = NULL;
- zoneBrandList_t *brands = NULL;
boolean_t be_mounted = B_FALSE;
int zone_index = 0;
int err = BE_SUCCESS;
- /*
- * Get the supported zone brands so we can pass that
- * to z_get_nonglobal_zone_list_by_brand. Currently
- * only the ipkg and labeled brand zones are supported
- *
- */
- if ((brands = be_get_supported_brandlist()) == NULL) {
- be_print_err(gettext("be_promote_zone_ds: no supported "
- "brands\n"));
- return (BE_SUCCESS);
- }
-
if ((zhp = zfs_open(g_zfs, be_root_ds,
ZFS_TYPE_FILESYSTEM)) == NULL) {
be_print_err(gettext("be_promote_zone_ds: Failed to open "
"dataset (%s): %s\n"), be_root_ds,
libzfs_error_description(g_zfs));
err = zfs_err_to_be_err(g_zfs);
- z_free_brand_list(brands);
return (err);
}
if (!zfs_is_mounted(zhp, &temp_mntpt)) {
if ((err = _be_mount(be_name, &temp_mntpt,
BE_MOUNT_FLAG_NO_ZONES)) != BE_SUCCESS) {
be_print_err(gettext("be_promote_zone_ds: failed to "
"mount the BE for zones procesing.\n"));
ZFS_CLOSE(zhp);
- z_free_brand_list(brands);
return (err);
}
be_mounted = B_TRUE;
}
--- 1389,1417 ----
*** 1433,1456 ****
* Set the zone root to the temp mount point for the BE we just mounted.
*/
z_set_zone_root(temp_mntpt);
/*
! * Get all the zones based on the brands we're looking for. If no zones
! * are found that we're interested in unmount the BE and move on.
*/
! if ((zone_list = z_get_nonglobal_zone_list_by_brand(brands)) == NULL) {
if (be_mounted)
(void) _be_unmount(be_name, 0);
ZFS_CLOSE(zhp);
- z_free_brand_list(brands);
free(temp_mntpt);
return (BE_SUCCESS);
}
for (zone_index = 0; z_zlist_get_zonename(zone_list, zone_index)
!= NULL; zone_index++) {
char *zone_path = NULL;
/* Skip zones that aren't at least installed */
if (z_zlist_get_current_state(zone_list, zone_index) <
ZONE_STATE_INSTALLED)
continue;
--- 1419,1452 ----
* Set the zone root to the temp mount point for the BE we just mounted.
*/
z_set_zone_root(temp_mntpt);
/*
! * If no zones are found, unmount the BE and move on.
*/
! if ((zone_list = z_get_nonglobal_branded_zone_list()) == NULL) {
if (be_mounted)
(void) _be_unmount(be_name, 0);
ZFS_CLOSE(zhp);
free(temp_mntpt);
return (BE_SUCCESS);
}
for (zone_index = 0; z_zlist_get_zonename(zone_list, zone_index)
!= NULL; zone_index++) {
char *zone_path = NULL;
+ boolean_t auto_create;
+
+ if (z_zlist_is_zone_auto_create_be(zone_list, zone_index,
+ &auto_create) != 0) {
+ be_print_err(gettext("be_promote_zone_ds: "
+ "Failed to get auto-create-be brand property\n"));
+ err = -1; // XXX
+ goto done;
+ }
+
+ if (!auto_create)
+ continue;
/* Skip zones that aren't at least installed */
if (z_zlist_get_current_state(zone_list, zone_index) <
ZONE_STATE_INSTALLED)
continue;
*** 1503,1513 ****
done:
if (be_mounted)
(void) _be_unmount(be_name, 0);
ZFS_CLOSE(zhp);
free(temp_mntpt);
- z_free_brand_list(brands);
z_free_zone_list(zone_list);
return (err);
}
/*
--- 1499,1508 ----