--- a/usr/src/lib/liborchestrator/upgrade_targets.c Wed Mar 05 13:46:46 2008 +0800
+++ b/usr/src/lib/liborchestrator/upgrade_targets.c Fri Mar 07 10:25:22 2008 +0100
@@ -32,8 +32,6 @@
#include <pthread.h>
#include <sys/types.h>
-#include "spmizones_api.h"
-#include "spmiapp_api.h"
#include "orchestrator_private.h"
/*
@@ -42,10 +40,6 @@
boolean_t instances_discovery_done = B_FALSE;
/*
- * local functions
- */
-void print_space_results(FSspace **sp, char *outfile);
-/*
* om_get_upgrade_targets
* This function will return the upgrade targets (Solaris Instances)
* found on the system. All the solaris instances whether upgradable
@@ -180,65 +174,7 @@
om_is_upgrade_target_valid(om_handle_t handle,
upgrade_info_t *uinfo, om_callback_t ut_cb)
{
- pthread_t validate_upgrade_thread;
- callback_args_t *cb_args;
- int ret;
- char root_slice[MAXNAMELEN];
-
- if (uinfo == NULL) {
- om_set_error(OM_NO_UPGRADE_TARGET);
- return (B_FALSE);
- }
-
- /*
- * We support only solaris instance which is on UFS.
- * The other types of targets like zfs will be added when they
- * become available
- */
- if (uinfo->instance_type != OM_INSTANCE_UFS) {
- om_set_error(OM_NOT_UFS_UPGRADE_TARGET);
- return (B_FALSE);
- }
-
- if (uinfo->instance.uinfo.disk_name == NULL) {
- om_set_error(OM_NO_UPGRADE_TARGET);
- return (B_FALSE);
- }
-
- if (!uinfo->upgradable) {
- om_set_error(OM_UPGRADE_NOT_ALLOWED);
- return (B_FALSE);
- }
-
- (void) snprintf(root_slice, sizeof (root_slice), "%ss%d",
- uinfo->instance.uinfo.disk_name, uinfo->instance.uinfo.slice);
- /*
- * Create a thread for running discovery and report progress
- * using the callback function.
- * if callback function is not provided, do not create the thread
- */
- cb_args = (callback_args_t *)calloc(1, sizeof (callback_args_t));
- if (cb_args == NULL) {
- om_set_error(OM_NO_SPACE);
- return (B_FALSE);
- }
- cb_args->cb = ut_cb;
- cb_args->cb_type.valid.target = strdup(root_slice);
- if (cb_args->cb_type.valid.target == NULL) {
- om_set_error(OM_NO_SPACE);
- free(cb_args);
- return (B_FALSE);
- }
- ret = pthread_create(&validate_upgrade_thread, NULL,
- handle_upgrade_validation, (void *)cb_args);
-
- if (ret != 0) {
- om_set_error(OM_ERROR_THREAD_CREATE);
- free(cb_args->cb_type.valid.target);
- free(cb_args);
- return (B_FALSE);
- }
- return (B_TRUE);
+ return (B_FALSE);
}
/*
@@ -393,190 +329,3 @@
free(si->instance.uinfo.svm_info);
return (NULL);
}
-
-/*
- * om_is_upgrade_target_valid
- * This function perform upgrade target validation using the
- * upgrade mechanism implemented in pfinatll
- * Input: void *args - The arguments to initialize the callback.
- * currently the structure containing upgrade target slice
- * and the callback function are passed.
- * Output: None
- * Return: The status is returned as part of pthread_exit function
- */
-
-void *
-handle_upgrade_validation(void *args)
-{
- callback_args_t *cp;
- om_callback_t cb;
- char *root_slice;
- char *media_dir = "/cdrom";
- Module *media, *mod;
- char *meta_cluster;
- FSspace **space;
- int status;
- int16_t percent = 0;
- boolean_t zones_loaded = B_FALSE;
-
- cp = (callback_args_t *)args;
-
- root_slice = cp->cb_type.valid.target;
- cb = cp->cb;
-
- init_spmi_for_upgrade_check();
- /*
- * Mount the file system to examine the instance
- */
- if ((status = mount_and_add_swap(root_slice, NULL)) != 0) {
- om_set_error(OM_BAD_UPGRADE_TARGET);
- om_debug_print(OM_DBGLVL_ERR, "mount_and_add_swap failed\n");
- goto huv_return;
- }
- percent += 10;
- send_upgrade_validation_callback(percent, cb);
-
- if ((mod = load_installed("/", FALSE)) == NULL) {
- om_set_error(OM_BAD_UPGRADE_TARGET);
- status = OM_BAD_UPGRADE_TARGET;
- om_debug_print(OM_DBGLVL_ERR, "load_installed failed\n");
- goto huv_return;
- }
- percent += 10;
- send_upgrade_validation_callback(percent, cb);
-
- meta_cluster = mod->sub->sub->info.mod->m_pkgid;
-
- if (load_zones() != 0) {
- om_set_error(OM_BAD_UPGRADE_TARGET);
- om_debug_print(OM_DBGLVL_ERR, "load_zones failed\n");
- status = OM_BAD_UPGRADE_TARGET;
- goto huv_return;
- }
- zones_loaded = B_TRUE;
- percent += 10;
- send_upgrade_validation_callback(percent, cb);
-
- /*
- * Load the media
- */
- if ((media = add_media(media_dir)) != NULL) {
- if (load_media(media, TRUE) != 0) {
- om_set_error(OM_CANNOT_LOAD_MEDIA);
- status = OM_CANNOT_LOAD_MEDIA;
- om_debug_print(OM_DBGLVL_ERR, "load_media failed\n");
- goto huv_return;
- }
- }
- percent += 10;
- send_upgrade_validation_callback(percent, cb);
-
- status = upgrade_all_envs();
- if (status != 0) {
- om_set_error(OM_BAD_UPGRADE_TARGET);
- om_debug_print(OM_DBGLVL_ERR, "upgrade_all_envs failed\n");
- goto huv_return;
- }
-
- (void) load_view((get_default_media())->sub, get_localmedia());
-
- status = configure_software(meta_cluster);
-
- percent += 10;
- send_upgrade_validation_callback(percent, cb);
-
- if (status != 0) {
- om_set_error(OM_BAD_UPGRADE_TARGET);
- om_debug_print(OM_DBGLVL_ERR, "configure_software failed\n");
- goto huv_return;
- }
-
- /*
- * Get the current file system layout
- */
- space = get_current_fs_layout(TRUE);
- if (space == NULL) {
- om_set_error(OM_BAD_UPGRADE_TARGET);
- status = OM_BAD_UPGRADE_TARGET;
- om_debug_print(OM_DBGLVL_ERR, "get_current_fs_layout failed\n");
- goto huv_return;
- }
-
- percent += 20;
- send_upgrade_validation_callback(percent, cb);
-
- status = verify_fs_layout(space, NULL, NULL);
-
- if (status == SP_ERR_NOT_ENOUGH_SPACE) {
- om_set_error(OM_NOT_ENOUGH_SPACE);
- om_debug_print(OM_DBGLVL_ERR, "verify_fs_layout failed\n");
-
- /*
- * Report the space required information back to the user
- */
- print_space_results(space, "/tmp/space.out");
- goto huv_return;
- } else if (status != 0) {
- om_set_error(OM_SPACE_CHECK_FAILURE);
- om_debug_print(OM_DBGLVL_ERR, "verify_fs_layout failed\n");
- goto huv_return;
- }
- percent += 20;
- send_upgrade_validation_callback(percent, cb);
- status = 0;
-
-huv_return:
- if (zones_loaded) {
- UmountAllZones(get_rootdir());
- }
- om_debug_print(OM_DBGLVL_ERR, "validation exited with status = %d\n",
- status);
-
- if (umount_and_delete_swap() != 0) {
- /*
- * Log the failure
- */
- status = OM_CANNOT_UMOUNT_ROOT_SWAP;
- om_set_error(OM_CANNOT_UMOUNT_ROOT_SWAP);
- om_debug_print(OM_DBGLVL_ERR,
- "umount_and_delete_swap failed\n");
- }
- if (status == 0) {
- percent = 100;
- } else {
- percent = -1;
- }
- send_upgrade_validation_callback(percent, cb);
- /*
- * Free the arguments allocated for this thread by the caller
- */
- free(cp->cb_type.valid.target);
- free(args);
- pthread_exit((void *)&status);
- /* LINTED [no return statement] */
-}
-
-/*
- * send_upgrade_validation_callback
- * This function will send a callback with the percent information
- * passed as a parameter
- * Input: percent - The percentage of validation completed
- * cb - Callback function to be invoked
- * output: None
- * Return: None
- */
-void
-send_upgrade_validation_callback(int16_t percent, om_callback_t cb)
-{
- om_callback_info_t cb_data;
- uintptr_t app_data = 0;
-
- if (cb == NULL) {
- return;
- }
- cb_data.callback_type = OM_SYSTEM_VALIDATION;
- cb_data.num_milestones = 1;
- cb_data.curr_milestone = OM_UPGRADE_CHECK;
- cb_data.percentage_done = percent;
- cb(&cb_data, app_data);
-}