Print this page
7711 SMF: Finish implementing support for degraded state


   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.

  23  */
  24 
  25 #ifndef _LIBRESTART_H
  26 #define _LIBRESTART_H
  27 
  28 #include <libsysevent.h>
  29 #include <libcontract.h>
  30 #include <libscf.h>
  31 #include <limits.h>
  32 #include <priv.h>
  33 #include <pwd.h>
  34 #include <sys/types.h>
  35 #include <sys/secflags.h>
  36 
  37 #ifdef  __cplusplus
  38 extern "C" {
  39 #endif
  40 
  41 /*
  42  * There are 3 parts to librestart.


  74  * protocol. In practice, increment RESTARTER_EVENT_VERSION whenever the
  75  * protocol might have changed.
  76  */
  77 #define RESTARTER_EVENT_VERSION         5
  78 
  79 #define RESTARTER_FLAG_DEBUG            1
  80 
  81 #define RESTARTER_ERRMSGSZ              1024
  82 
  83 /*
  84  * Event types
  85  *      RESTARTER_EVENT_TYPE_ADD_INSTANCE
  86  *              responsible for a new (stopped) instance
  87  *      RESTARTER_EVENT_TYPE_REMOVE_INSTANCE
  88  *              no longer responsible for this instance; stop it and return
  89  *      RESTARTER_EVENT_TYPE_ENABLE
  90  *              no guarantee that dependencies are met; see
  91  *              RESTARTER_EVENT_TYPE_START
  92  *      RESTARTER_EVENT_TYPE_DISABLE
  93  *              no guarantee that instance was running

  94  *      RESTARTER_EVENT_TYPE_ADMIN_DEGRADED

  95  *      RESTARTER_EVENT_TYPE_ADMIN_REFRESH
  96  *      RESTARTER_EVENT_TYPE_ADMIN_RESTART
  97  *      RESTARTER_EVENT_TYPE_ADMIN_MAINT_OFF
  98  *      RESTARTER_EVENT_TYPE_ADMIN_MAINT_ON
  99  *      RESTARTER_EVENT_TYPE_ADMIN_MAINT_ON_IMMEDIATE
 100  *      RESTARTER_EVENT_TYPE_ADMIN_MAINT_OFF
 101  *      RESTARTER_EVENT_TYPE_STOP
 102  *              dependencies are, or are becoming, unsatisfied
 103  *      RESTARTER_EVENT_TYPE_START
 104  *              dependencies have become satisfied
 105  *      RESTARTER_EVENT_TYPE_DEPENDENCY_CYCLE
 106  *              instance caused a dependency cycle
 107  *      RESTARTER_EVENT_TYPE_INVALID_DEPENDENCY
 108  *              instance has an invalid dependency
 109  */
 110 
 111 #define RESTARTER_EVENT_TYPE_INVALID                    0
 112 #define RESTARTER_EVENT_TYPE_ADD_INSTANCE               1
 113 #define RESTARTER_EVENT_TYPE_REMOVE_INSTANCE            2
 114 #define RESTARTER_EVENT_TYPE_ENABLE                     3
 115 #define RESTARTER_EVENT_TYPE_DISABLE                    4
 116 #define RESTARTER_EVENT_TYPE_ADMIN_DEGRADED             5
 117 #define RESTARTER_EVENT_TYPE_ADMIN_REFRESH              6
 118 #define RESTARTER_EVENT_TYPE_ADMIN_RESTART              7
 119 #define RESTARTER_EVENT_TYPE_ADMIN_MAINT_OFF            8
 120 #define RESTARTER_EVENT_TYPE_ADMIN_MAINT_ON             9
 121 #define RESTARTER_EVENT_TYPE_ADMIN_MAINT_ON_IMMEDIATE   10
 122 #define RESTARTER_EVENT_TYPE_STOP                       11
 123 #define RESTARTER_EVENT_TYPE_START                      12
 124 #define RESTARTER_EVENT_TYPE_DEPENDENCY_CYCLE           13
 125 #define RESTARTER_EVENT_TYPE_INVALID_DEPENDENCY         14
 126 #define RESTARTER_EVENT_TYPE_ADMIN_DISABLE              15
 127 #define RESTARTER_EVENT_TYPE_STOP_RESET                 16


 128 
 129 #define RESTARTER_EVENT_ERROR                   -1
 130 
 131 #define RESTARTER_EVENT_INSTANCE_DISABLED       0
 132 #define RESTARTER_EVENT_INSTANCE_ENABLED        1
 133 
 134 typedef enum {
 135         RESTARTER_STATE_NONE,
 136         RESTARTER_STATE_UNINIT,
 137         RESTARTER_STATE_MAINT,
 138         RESTARTER_STATE_OFFLINE,
 139         RESTARTER_STATE_DISABLED,
 140         RESTARTER_STATE_ONLINE,
 141         RESTARTER_STATE_DEGRADED
 142 } restarter_instance_state_t;
 143 
 144 /*
 145  * These values are ordered by severity of required restart, as we use
 146  * integer comparisons to determine error flow.
 147  */




   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2017 RackTop Systems.
  24  */
  25 
  26 #ifndef _LIBRESTART_H
  27 #define _LIBRESTART_H
  28 
  29 #include <libsysevent.h>
  30 #include <libcontract.h>
  31 #include <libscf.h>
  32 #include <limits.h>
  33 #include <priv.h>
  34 #include <pwd.h>
  35 #include <sys/types.h>
  36 #include <sys/secflags.h>
  37 
  38 #ifdef  __cplusplus
  39 extern "C" {
  40 #endif
  41 
  42 /*
  43  * There are 3 parts to librestart.


  75  * protocol. In practice, increment RESTARTER_EVENT_VERSION whenever the
  76  * protocol might have changed.
  77  */
  78 #define RESTARTER_EVENT_VERSION         5
  79 
  80 #define RESTARTER_FLAG_DEBUG            1
  81 
  82 #define RESTARTER_ERRMSGSZ              1024
  83 
  84 /*
  85  * Event types
  86  *      RESTARTER_EVENT_TYPE_ADD_INSTANCE
  87  *              responsible for a new (stopped) instance
  88  *      RESTARTER_EVENT_TYPE_REMOVE_INSTANCE
  89  *              no longer responsible for this instance; stop it and return
  90  *      RESTARTER_EVENT_TYPE_ENABLE
  91  *              no guarantee that dependencies are met; see
  92  *              RESTARTER_EVENT_TYPE_START
  93  *      RESTARTER_EVENT_TYPE_DISABLE
  94  *              no guarantee that instance was running
  95  *      RESTARTER_EVENT_TYPE_ADMIN_RESTORE
  96  *      RESTARTER_EVENT_TYPE_ADMIN_DEGRADED
  97  *      RESTARTER_EVENT_TYPE_ADMIN_DEGRADE_IMMEDIATE
  98  *      RESTARTER_EVENT_TYPE_ADMIN_REFRESH
  99  *      RESTARTER_EVENT_TYPE_ADMIN_RESTART
 100  *      RESTARTER_EVENT_TYPE_ADMIN_MAINT_OFF
 101  *      RESTARTER_EVENT_TYPE_ADMIN_MAINT_ON
 102  *      RESTARTER_EVENT_TYPE_ADMIN_MAINT_ON_IMMEDIATE
 103  *      RESTARTER_EVENT_TYPE_ADMIN_MAINT_OFF
 104  *      RESTARTER_EVENT_TYPE_STOP
 105  *              dependencies are, or are becoming, unsatisfied
 106  *      RESTARTER_EVENT_TYPE_START
 107  *              dependencies have become satisfied
 108  *      RESTARTER_EVENT_TYPE_DEPENDENCY_CYCLE
 109  *              instance caused a dependency cycle
 110  *      RESTARTER_EVENT_TYPE_INVALID_DEPENDENCY
 111  *              instance has an invalid dependency
 112  */
 113 
 114 #define RESTARTER_EVENT_TYPE_INVALID                    0
 115 #define RESTARTER_EVENT_TYPE_ADD_INSTANCE               1
 116 #define RESTARTER_EVENT_TYPE_REMOVE_INSTANCE            2
 117 #define RESTARTER_EVENT_TYPE_ENABLE                     3
 118 #define RESTARTER_EVENT_TYPE_DISABLE                    4
 119 #define RESTARTER_EVENT_TYPE_ADMIN_DEGRADED             5
 120 #define RESTARTER_EVENT_TYPE_ADMIN_REFRESH              6
 121 #define RESTARTER_EVENT_TYPE_ADMIN_RESTART              7
 122 #define RESTARTER_EVENT_TYPE_ADMIN_MAINT_OFF            8
 123 #define RESTARTER_EVENT_TYPE_ADMIN_MAINT_ON             9
 124 #define RESTARTER_EVENT_TYPE_ADMIN_MAINT_ON_IMMEDIATE   10
 125 #define RESTARTER_EVENT_TYPE_STOP                       11
 126 #define RESTARTER_EVENT_TYPE_START                      12
 127 #define RESTARTER_EVENT_TYPE_DEPENDENCY_CYCLE           13
 128 #define RESTARTER_EVENT_TYPE_INVALID_DEPENDENCY         14
 129 #define RESTARTER_EVENT_TYPE_ADMIN_DISABLE              15
 130 #define RESTARTER_EVENT_TYPE_STOP_RESET                 16
 131 #define RESTARTER_EVENT_TYPE_ADMIN_RESTORE              17
 132 #define RESTARTER_EVENT_TYPE_ADMIN_DEGRADE_IMMEDIATE    18
 133 
 134 #define RESTARTER_EVENT_ERROR                   -1
 135 
 136 #define RESTARTER_EVENT_INSTANCE_DISABLED       0
 137 #define RESTARTER_EVENT_INSTANCE_ENABLED        1
 138 
 139 typedef enum {
 140         RESTARTER_STATE_NONE,
 141         RESTARTER_STATE_UNINIT,
 142         RESTARTER_STATE_MAINT,
 143         RESTARTER_STATE_OFFLINE,
 144         RESTARTER_STATE_DISABLED,
 145         RESTARTER_STATE_ONLINE,
 146         RESTARTER_STATE_DEGRADED
 147 } restarter_instance_state_t;
 148 
 149 /*
 150  * These values are ordered by severity of required restart, as we use
 151  * integer comparisons to determine error flow.
 152  */