os-cmpi-xen

changeset 109:64e363d418df

Minor changes to cmpilr interface:
- Propogated CMPIStatus structure through to resource files in cmpilr.[ch]
- Functions in cmpilr function table now return int and any data in
caller-provided pointer

This allows functions such as CMPILR_enumInstanceNames to return success when
no instances exist - instead of an exception which will terminate any
enumInstanceNames call chain from originated on superclass.

Updated providers to changes in cmpilr interface.

Signed-off-by: Jim Fehlig <jfehlig@novell.com>
author Jim Fehlig <jfehlig@novell.com>
date Fri May 11 17:17:46 2007 -0600 (2007-05-11)
parents 1ada37af7d08
children f99d9b081535
files ChangeLog src/Xen_Disk.c src/Xen_DiskSettingData.c src/Xen_VirtualSystemManagementCapabilities.c src/cmpilr.c src/cmpilr.h
line diff
     1.1 --- a/ChangeLog	Fri May 11 13:14:41 2007 -0600
     1.2 +++ b/ChangeLog	Fri May 11 17:17:46 2007 -0600
     1.3 @@ -1,3 +1,14 @@
     1.4 +-------------------------------------------------------------------
     1.5 +Fri May 11 17:08:37 MDT 2007 - jfehlig@novell.com
     1.6 +
     1.7 +        - Propogated CMPIStatus structure through to resource files
     1.8 +          in cmpilr.[ch].  Also changed all functions in cmpilr
     1.9 +          function table to return int and any data in caller-provided
    1.10 +          pointer.  This allows functions such as CMPILR_enumInstanceNames
    1.11 +          to return success when no instances exist instead of an
    1.12 +          exception - which will terminate any enumInstanceNames chain.
    1.13 +        - Updated providers to changes in cmpilr interface.
    1.14 +
    1.15  -------------------------------------------------------------------
    1.16  Fri May 11 13:11:08 MDT 2007 - jfehlig@novell.com
    1.17  
     2.1 --- a/src/Xen_Disk.c	Fri May 11 13:14:41 2007 -0600
     2.2 +++ b/src/Xen_Disk.c	Fri May 11 17:17:46 2007 -0600
     2.3 @@ -42,6 +42,7 @@ static const CMPIInstanceMI* mi;
     2.4  #include <xen_vbd.h>
     2.5  #include <xen_vdi.h>
     2.6  #include <xen_string_string_map.h>
     2.7 +#include <xen_vm_power_state.h>
     2.8  
     2.9  #include "cmpitrace.h"
    2.10  #include "xen_utils.h"
    2.11 @@ -83,21 +84,26 @@ static int unload(CMPIBoolean terminatin
    2.12  }
    2.13  
    2.14  
    2.15 -static void* beginEnum()
    2.16 +static int beginEnum(void **res_list, CMPIStatus *status)
    2.17  {
    2.18     _RESOURCES *resources;
    2.19     xen_domain_resources *res = NULL;
    2.20     xen_vbd_set *all_disks = NULL;
    2.21     xen_vm_record *vm_rec = NULL;
    2.22     
    2.23 +   if (res_list == NULL)
    2.24 +      return 0;
    2.25 +   
    2.26     resources = (_RESOURCES *)calloc(1, sizeof(_RESOURCES));
    2.27     if (resources == NULL)
    2.28 -      return NULL;
    2.29 +      return 0;
    2.30  
    2.31     if (!xen_utils_validate_session(&session)) {
    2.32        _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
    2.33                     ("--- Unable to establish connection with Xend"));
    2.34 -      return NULL;
    2.35 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
    2.36 +                           "Unable to establish connection with Xend");
    2.37 +      return 0;
    2.38     }
    2.39  
    2.40     /* Get a list of domain resources. */
    2.41 @@ -125,7 +131,8 @@ static void* beginEnum()
    2.42     resources->disks = all_disks;
    2.43     resources->currentdisknum = 0;
    2.44     
    2.45 -   return resources;
    2.46 +   *res_list = (void *)resources;
    2.47 +   return 1;
    2.48     
    2.49   Error:
    2.50     if (session && session->xen) {
    2.51 @@ -135,14 +142,17 @@ static void* beginEnum()
    2.52                              xen_utils_trace_error(session->xen));
    2.53     }
    2.54  
    2.55 +   CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
    2.56 +                        "Failed to retrieve vbd resources from Xend");
    2.57 +
    2.58     xen_vm_record_free(vm_rec);
    2.59     xen_utils_free_domain_resources(res);
    2.60     free(resources);
    2.61 -   return NULL;
    2.62 +   return 0;
    2.63  }
    2.64  
    2.65  
    2.66 -static void endEnum(void* res_list)
    2.67 +static void endEnum(void *res_list)
    2.68  {
    2.69     _RESOURCES *resources = (_RESOURCES *)res_list;
    2.70     
    2.71 @@ -154,22 +164,24 @@ static void endEnum(void* res_list)
    2.72  }
    2.73  
    2.74  
    2.75 -static void* getNext(void* res_list)
    2.76 +static int getNext(void *res_list, void **res, CMPIStatus *status)
    2.77  {
    2.78     _RESOURCES *resources = (_RESOURCES *)res_list;
    2.79     xen_vbd_record *vbd_rec;
    2.80  
    2.81 -   if (resources == NULL || resources->disks == NULL)
    2.82 -      return NULL;
    2.83 +   if (resources == NULL || resources->disks == NULL || res == NULL)
    2.84 +      return 0;
    2.85  
    2.86     /* Check if reached the end of the list of disks. */
    2.87     if (resources->currentdisknum == resources->disks->size)
    2.88 -      return NULL;
    2.89 +      return 0;
    2.90  
    2.91     if (!xen_utils_validate_session(&session)) {
    2.92        _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
    2.93                     ("--- Unable to establish connection with Xend"));
    2.94 -      return NULL;
    2.95 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
    2.96 +                           "Unable to establish connection with Xend");
    2.97 +      return 0;
    2.98     }
    2.99  
   2.100     /* Get the current disk record. */
   2.101 @@ -179,15 +191,18 @@ static void* getNext(void* res_list)
   2.102                     ("--- failed to retrieve vbd resources from Xend:"));
   2.103        _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
   2.104                              xen_utils_trace_error(session->xen));
   2.105 -      return NULL;
   2.106 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
   2.107 +                           "Failed to retrieve vbd resource from Xend");
   2.108 +      return 0;
   2.109     }
   2.110     
   2.111     resources->currentdisknum++;
   2.112 -   return (void *)vbd_rec;
   2.113 +   *res = (void *)vbd_rec;
   2.114 +   return 1;
   2.115  }
   2.116  
   2.117  
   2.118 -static int get(void* res_list, void** res)
   2.119 +static int get(void *res_list, void **res, CMPIStatus *status)
   2.120  {
   2.121     if (res == NULL || *res == NULL)
   2.122        return 0;
   2.123 @@ -201,13 +216,13 @@ static int get(void* res_list, void** re
   2.124  }
   2.125  
   2.126  
   2.127 -static void release(void* res)
   2.128 +static void release(void *res)
   2.129  {
   2.130     xen_vbd_record_free(res);
   2.131  }
   2.132  
   2.133  
   2.134 -static int add(void** res_list, void* res)
   2.135 +static int add(void **res_list, void *res, CMPIStatus *status)
   2.136  {
   2.137     xen_vbd_record *new_vbd_rec = (xen_vbd_record *)res;
   2.138     
   2.139 @@ -219,6 +234,8 @@ static int add(void** res_list, void* re
   2.140     if (!xen_utils_validate_session(&session)) {
   2.141        _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   2.142                     ("--- Unable to establish connection with Xend"));
   2.143 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
   2.144 +                           "Unable to establish connection with Xend");
   2.145        return 0;
   2.146     }
   2.147  
   2.148 @@ -228,6 +245,8 @@ static int add(void** res_list, void* re
   2.149                     ("--- xen_vbd_create failed:"));
   2.150        _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
   2.151                              xen_utils_trace_error(session->xen));
   2.152 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
   2.153 +                           "xen_vbd_create failed");
   2.154        return 0;
   2.155     }
   2.156  
   2.157 @@ -236,7 +255,7 @@ static int add(void** res_list, void* re
   2.158  }
   2.159  
   2.160  
   2.161 -static int delete(void** res_list, void* res)
   2.162 +static int delete(void **res_list, void *res, CMPIStatus *status)
   2.163  {
   2.164     xen_vbd_record *vbd_rec = (xen_vbd_record *)res;
   2.165     
   2.166 @@ -248,6 +267,8 @@ static int delete(void** res_list, void*
   2.167     if (!xen_utils_validate_session(&session)) {
   2.168        _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   2.169                     ("--- Unable to establish connection with Xend"));
   2.170 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
   2.171 +                           "Unable to establish connection with Xend");
   2.172        return 0;
   2.173     }
   2.174  
   2.175 @@ -256,6 +277,8 @@ static int delete(void** res_list, void*
   2.176                     ("--- xen_vbd_create failed:"));
   2.177        _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
   2.178                              xen_utils_trace_error(session->xen));
   2.179 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
   2.180 +                           "xen_vbd_destroy failed");
   2.181        return 0;
   2.182     }
   2.183  
   2.184 @@ -263,14 +286,14 @@ static int delete(void** res_list, void*
   2.185  }
   2.186  
   2.187  
   2.188 -static int modify(void** res_list, void* res)
   2.189 +static int modify(void **res_list, void *res, CMPIStatus *status)
   2.190  {
   2.191     return -1; /* unsupported */
   2.192  }
   2.193  
   2.194  
   2.195  /* Set CMPIInstance properties from the resource data. */
   2.196 -static int res2inst(void* res, CMPIInstance* inst)
   2.197 +static int res2inst(void *res, CMPIInstance *inst, CMPIStatus *status)
   2.198  {
   2.199     xen_vm_record *alloced_vm_rec = NULL;
   2.200     xen_vm_record *vm_rec;
   2.201 @@ -283,6 +306,8 @@ static int res2inst(void* res, CMPIInsta
   2.202     if (!xen_utils_validate_session(&session)) {
   2.203        _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   2.204                     ("--- Unable to establish connection with Xend"));
   2.205 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
   2.206 +                           "Unable to establish connection with Xend");
   2.207        return 0;
   2.208     }
   2.209  
   2.210 @@ -296,6 +321,8 @@ static int res2inst(void* res, CMPIInsta
   2.211                        ("--- xen_vm_get_record failed:"));
   2.212           _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
   2.213                                 xen_utils_trace_error(session->xen));
   2.214 +         CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
   2.215 +                              "xen_vm_get_record failed");
   2.216           return 0;
   2.217        }
   2.218        alloced_vm_rec = vm_rec;
   2.219 @@ -362,19 +389,18 @@ static int res2inst(void* res, CMPIInsta
   2.220  
   2.221  
   2.222  /* Set resource data from the CMPIInstance properties. */ 
   2.223 -static int inst2res(CMPIInstance* inst, void** res)
   2.224 +static int inst2res(CMPIInstance *inst, void **res, CMPIStatus *status)
   2.225  {
   2.226     CMPIData data;
   2.227     char *dev_uuid;
   2.228     char uuid[MAX_SYSTEM_NAME_LEN];
   2.229     int ccode;
   2.230 -   CMPIStatus status = {CMPI_RC_OK, NULL};
   2.231  
   2.232     if (CMIsNullObject(inst) || res == NULL)
   2.233        return 0;
   2.234  
   2.235 -   data = CMGetProperty(inst, "DeviceID", &status);
   2.236 -   if ((status.rc != CMPI_RC_OK) || CMIsNullValue(data))
   2.237 +   data = CMGetProperty(inst, "DeviceID", status);
   2.238 +   if ((status->rc != CMPI_RC_OK) || CMIsNullValue(data))
   2.239        return 0;
   2.240  
   2.241     dev_uuid = CMGetCharPtr(data.value.string);
   2.242 @@ -384,17 +410,48 @@ static int inst2res(CMPIInstance* inst, 
   2.243     if (!xen_utils_validate_session(&session)) {
   2.244        _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   2.245                     ("--- Unable to establish connection with Xend"));
   2.246 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
   2.247 +                           "Unable to establish connection with Xend");
   2.248 +      return 0;
   2.249 +   }
   2.250 +
   2.251 +   xen_vbd_record *vbd_rec;
   2.252 +   if (!xen_vbd_get_record(session->xen, &vbd_rec, (xen_vbd)dev_uuid)) {
   2.253 +      _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   2.254 +                   ("--- xen_vbd_get_record failed:"));
   2.255 +      _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
   2.256 +                            xen_utils_trace_error(session->xen));
   2.257 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
   2.258 +                           "xen_vbd_get_record failed");
   2.259        return 0;
   2.260     }
   2.261  
   2.262 -   if (!xen_vbd_get_record(session->xen, (xen_vbd_record **)res, (xen_vbd)dev_uuid)) {
   2.263 +   /* TODO:
   2.264 +    * For now Xen_Disk instances only exist when domain is not inactive,
   2.265 +    * so return NOT_FOUND.
   2.266 +    * Should disks be one of the few logical devices that do exist even
   2.267 +    * when domain is inactive?
   2.268 +    */
   2.269 +   enum xen_vm_power_state pstate;
   2.270 +   if (!xen_vm_get_power_state(session->xen, &pstate, vbd_rec->vm->u.handle)) {
   2.271        _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   2.272 -                   ("--- xen_vbd_destroy failed:"));
   2.273 +                   ("--- xen_vm_get_power_state failed:"));
   2.274        _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
   2.275                              xen_utils_trace_error(session->xen));
   2.276 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
   2.277 +                           "Unable to determine vm power state");
   2.278 +      xen_vbd_record_free(vbd_rec);
   2.279 +      
   2.280        return 0;
   2.281     }
   2.282  
   2.283 +   if (pstate == XEN_VM_POWER_STATE_HALTED) {
   2.284 +         CMSetStatus(status, CMPI_RC_ERR_NOT_FOUND);
   2.285 +         xen_vbd_record_free(vbd_rec);
   2.286 +         return 0;
   2.287 +   }
   2.288 +   
   2.289 +   *res = (void *)vbd_rec;
   2.290     return 1;
   2.291  }
   2.292  
     3.1 --- a/src/Xen_DiskSettingData.c	Fri May 11 13:14:41 2007 -0600
     3.2 +++ b/src/Xen_DiskSettingData.c	Fri May 11 17:17:46 2007 -0600
     3.3 @@ -83,7 +83,7 @@ static int unload(CMPIBoolean terminatin
     3.4  }
     3.5  
     3.6  
     3.7 -static void* beginEnum()
     3.8 +static int beginEnum(void **res_list, CMPIStatus *status)
     3.9  {
    3.10     _RESOURCES *resources;
    3.11     xen_domain_resources *res = NULL;
    3.12 @@ -92,12 +92,14 @@ static void* beginEnum()
    3.13     
    3.14     resources = (_RESOURCES *)calloc(1, sizeof(_RESOURCES));
    3.15     if (resources == NULL)
    3.16 -      return NULL;
    3.17 +      return 0;
    3.18  
    3.19     if (!xen_utils_validate_session(&session)) {
    3.20        _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
    3.21                     ("--- Unable to establish connection with Xend"));
    3.22 -      return NULL;
    3.23 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
    3.24 +                           "Unable to establish connection with Xend");
    3.25 +      return 0;
    3.26     }
    3.27  
    3.28     /* Get a list of domain resources. */
    3.29 @@ -119,7 +121,8 @@ static void* beginEnum()
    3.30     resources->disks = all_disks;
    3.31     resources->currentdisknum = 0;
    3.32     
    3.33 -   return resources;
    3.34 +   *res_list = (void *)resources;
    3.35 +   return 1;
    3.36     
    3.37   Error:
    3.38     if (session && session->xen) {
    3.39 @@ -129,14 +132,17 @@ static void* beginEnum()
    3.40                              xen_utils_trace_error(session->xen));
    3.41     }
    3.42  
    3.43 +   CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
    3.44 +                        "Failed to retrieve vbd resources from Xend");
    3.45 +
    3.46     xen_vm_record_free(vm_rec);
    3.47     xen_utils_free_domain_resources(res);
    3.48     free(resources);
    3.49 -   return NULL;
    3.50 +   return 0;
    3.51  }
    3.52  
    3.53  
    3.54 -static void endEnum(void* res_list)
    3.55 +static void endEnum(void *res_list)
    3.56  {
    3.57     _RESOURCES *resources = (_RESOURCES *)res_list;
    3.58     
    3.59 @@ -148,22 +154,24 @@ static void endEnum(void* res_list)
    3.60  }
    3.61  
    3.62  
    3.63 -static void* getNext(void* res_list)
    3.64 +static int getNext(void *res_list, void **res, CMPIStatus *status)
    3.65  {
    3.66     _RESOURCES *resources = (_RESOURCES *)res_list;
    3.67     xen_vbd_record *vbd_rec;
    3.68  
    3.69     if (resources == NULL || resources->disks == NULL)
    3.70 -      return NULL;
    3.71 +      return 0;
    3.72  
    3.73     /* Check if reached the end of the list of disks. */
    3.74     if (resources->currentdisknum == resources->disks->size)
    3.75 -      return NULL;
    3.76 +      return 0;
    3.77  
    3.78     if (!xen_utils_validate_session(&session)) {
    3.79        _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
    3.80                     ("--- Unable to establish connection with Xend"));
    3.81 -      return NULL;
    3.82 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
    3.83 +                           "Unable to establish connection with Xend");
    3.84 +      return 0;
    3.85     }
    3.86  
    3.87     /* Get the current disk record. */
    3.88 @@ -173,15 +181,18 @@ static void* getNext(void* res_list)
    3.89                     ("--- failed to retrieve vbd resource from Xend:"));
    3.90        _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
    3.91                              xen_utils_trace_error(session->xen));
    3.92 -      return NULL;
    3.93 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
    3.94 +                           "Failed to retrieve vbd resource from Xend");
    3.95 +      return 0;
    3.96     }
    3.97     
    3.98     resources->currentdisknum++;
    3.99 -   return (void *)vbd_rec;
   3.100 +   *res = (void *)vbd_rec;
   3.101 +   return 1;
   3.102  }
   3.103  
   3.104  
   3.105 -static int get(void* res_list, void** res)
   3.106 +static int get(void *res_list, void **res, CMPIStatus *status)
   3.107  {
   3.108     if (res == NULL || *res == NULL)
   3.109        return 0;
   3.110 @@ -195,13 +206,13 @@ static int get(void* res_list, void** re
   3.111  }
   3.112  
   3.113  
   3.114 -static void release(void* res)
   3.115 +static void release(void *res)
   3.116  {
   3.117     xen_vbd_record_free(res);
   3.118  }
   3.119  
   3.120  
   3.121 -static int add(void** res_list, void* res)
   3.122 +static int add(void **res_list, void *res, CMPIStatus *status)
   3.123  {
   3.124     xen_vbd_record *new_vbd_rec = (xen_vbd_record *)res;
   3.125     
   3.126 @@ -213,6 +224,8 @@ static int add(void** res_list, void* re
   3.127     if (!xen_utils_validate_session(&session)) {
   3.128        _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   3.129                     ("--- Unable to establish connection with Xend"));
   3.130 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
   3.131 +                           "Unable to establish connection with Xend");
   3.132        return 0;
   3.133     }
   3.134  
   3.135 @@ -222,6 +235,8 @@ static int add(void** res_list, void* re
   3.136                     ("--- xen_vbd_create failed:"));
   3.137        _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
   3.138                              xen_utils_trace_error(session->xen));
   3.139 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
   3.140 +                           "xen_vbd_create failed");
   3.141        return 0;
   3.142     }
   3.143  
   3.144 @@ -230,7 +245,7 @@ static int add(void** res_list, void* re
   3.145  }
   3.146  
   3.147  
   3.148 -static int delete(void** res_list, void* res)
   3.149 +static int delete(void **res_list, void *res, CMPIStatus *status)
   3.150  {
   3.151     xen_vbd_record *vbd_rec = (xen_vbd_record *)res;
   3.152     
   3.153 @@ -242,6 +257,8 @@ static int delete(void** res_list, void*
   3.154     if (!xen_utils_validate_session(&session)) {
   3.155        _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   3.156                     ("--- Unable to establish connection with Xend"));
   3.157 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
   3.158 +                           "Unable to establish connection with Xend");
   3.159        return 0;
   3.160     }
   3.161  
   3.162 @@ -250,6 +267,8 @@ static int delete(void** res_list, void*
   3.163                     ("--- xen_vbd_destroy failed:"));
   3.164        _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
   3.165                              xen_utils_trace_error(session->xen));
   3.166 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
   3.167 +                           "xen_vbd_destroy failed");
   3.168        return 0;
   3.169     }
   3.170  
   3.171 @@ -257,14 +276,14 @@ static int delete(void** res_list, void*
   3.172  }
   3.173  
   3.174  
   3.175 -static int modify(void** res_list, void* res)
   3.176 +static int modify(void **res_list, void *res, CMPIStatus *status)
   3.177  {
   3.178     return -1; /* unsupported */
   3.179  }
   3.180  
   3.181  
   3.182  /* Set CMPIInstance properties from the resource data. */
   3.183 -static int res2inst(void* res, CMPIInstance* inst)
   3.184 +static int res2inst(void *res, CMPIInstance *inst, CMPIStatus *status)
   3.185  {
   3.186     xen_vbd_record *vbd_rec = (xen_vbd_record *)res;
   3.187     char buf[MAX_INSTANCEID_LEN];
   3.188 @@ -275,6 +294,8 @@ static int res2inst(void* res, CMPIInsta
   3.189     if (!xen_utils_validate_session(&session)) {
   3.190        _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   3.191                     ("--- Unable to establish connection with Xend"));
   3.192 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
   3.193 +                           "Unable to establish connection with Xend");
   3.194        return 0;
   3.195     }
   3.196  
   3.197 @@ -349,19 +370,18 @@ static int res2inst(void* res, CMPIInsta
   3.198  
   3.199  
   3.200  /* Set resource data from the CMPIInstance properties. */ 
   3.201 -static int inst2res(CMPIInstance* inst, void** res)
   3.202 +static int inst2res(CMPIInstance *inst, void **res, CMPIStatus *status)
   3.203  {
   3.204     CMPIData data;
   3.205     char *inst_id;
   3.206     char uuid[MAX_SYSTEM_NAME_LEN];
   3.207     int ccode;
   3.208 -   CMPIStatus status = {CMPI_RC_OK, NULL};
   3.209  
   3.210     if (CMIsNullObject(inst) || res == NULL)
   3.211        return 0;
   3.212  
   3.213 -   data = CMGetProperty(inst, "InstanceID", &status);
   3.214 -   if ((status.rc != CMPI_RC_OK) || CMIsNullValue(data))
   3.215 +   data = CMGetProperty(inst, "InstanceID", status);
   3.216 +   if ((status->rc != CMPI_RC_OK) || CMIsNullValue(data))
   3.217        return 0;
   3.218     
   3.219     inst_id = CMGetCharPtr(data.value.string);
   3.220 @@ -375,14 +395,18 @@ static int inst2res(CMPIInstance* inst, 
   3.221     if (!xen_utils_validate_session(&session)) {
   3.222        _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   3.223                     ("--- Unable to establish connection with Xend"));
   3.224 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
   3.225 +                           "Unable to establish connection with Xend");
   3.226        return 0;
   3.227     }
   3.228  
   3.229     if (!xen_vbd_get_record(session->xen, (xen_vbd_record **)res, (xen_vbd)uuid)) {
   3.230        _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   3.231 -                   ("--- xen_vbd_destroy failed:"));
   3.232 +                   ("--- xen_vbd_get_record failed:"));
   3.233        _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
   3.234                              xen_utils_trace_error(session->xen));
   3.235 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
   3.236 +                           "xen_vbd_get_record failed");
   3.237        return 0;
   3.238     }
   3.239  
     4.1 --- a/src/Xen_VirtualSystemManagementCapabilities.c	Fri May 11 13:14:41 2007 -0600
     4.2 +++ b/src/Xen_VirtualSystemManagementCapabilities.c	Fri May 11 17:17:46 2007 -0600
     4.3 @@ -78,62 +78,37 @@ static int unload(CMPIBoolean terminatin
     4.4  }
     4.5  
     4.6  
     4.7 -static void* beginEnum()
     4.8 +static int beginEnum(void **res_list, CMPIStatus *status)
     4.9  {
    4.10 -   _RESOURCES *resources = (_RESOURCES *)calloc(1, sizeof(_RESOURCES));
    4.11 -   if (resources == NULL)
    4.12 -      return NULL;
    4.13 +   *res_list = (_RESOURCES *)calloc(1, sizeof(_RESOURCES));
    4.14 +   if (*res_list == NULL)
    4.15 +      return 0;
    4.16  
    4.17 -   return resources;
    4.18 +   return 1;
    4.19  }
    4.20  
    4.21  
    4.22 -static void endEnum(void* res_list)
    4.23 +static void endEnum(void *res_list)
    4.24  {
    4.25     free(res_list);
    4.26  }
    4.27  
    4.28  
    4.29 -static void* getNext(void* res_list)
    4.30 +static int getNext(void *res_list, void **res, CMPIStatus *status)
    4.31  {
    4.32 -   xen_host host;
    4.33 +   xen_host host = NULL;
    4.34     xen_host_record *host_rec;
    4.35  
    4.36     if (res_list == NULL || ((_RESOURCES *)res_list)->finished)
    4.37 -      return NULL;
    4.38 +      return 0;
    4.39     
    4.40     ((_RESOURCES *)res_list)->finished = 1;
    4.41  
    4.42     if (!xen_utils_validate_session(&session)) {
    4.43        _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
    4.44                     ("--- Unable to establish connection with Xend"));
    4.45 -      return NULL;
    4.46 -   }
    4.47 -
    4.48 -   xen_session_get_this_host(session->xen, &host, session->xen);
    4.49 -   xen_host_get_record(session->xen, &host_rec, host);
    4.50 -   if (!session->xen->ok) {
    4.51 -      /* Error description in session object. */
    4.52 -      _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
    4.53 -                   ("--- failed to retrieve host record from Xend:"));
    4.54 -      _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
    4.55 -                            xen_utils_trace_error(session->xen));
    4.56 -      return NULL;
    4.57 -   }
    4.58 -      
    4.59 -   return (void *)host_rec;
    4.60 -}
    4.61 -
    4.62 -
    4.63 -static int get(void* res_list, void** res)
    4.64 -{
    4.65 -   xen_host host;
    4.66 -   xen_host_record *host_rec;
    4.67 -
    4.68 -   (void) res_list;
    4.69 -   
    4.70 -   if (!xen_utils_validate_session(&session)) {
    4.71 -      _SBLIM_TRACE(1, ("--- Unable to establish connection with Xend"));
    4.72 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
    4.73 +                           "Unable to establish connection with Xend");
    4.74        return 0;
    4.75     }
    4.76  
    4.77 @@ -145,6 +120,42 @@ static int get(void* res_list, void** re
    4.78                     ("--- failed to retrieve host record from Xend:"));
    4.79        _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
    4.80                              xen_utils_trace_error(session->xen));
    4.81 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
    4.82 +                           "Failed to retrieve host record from Xend");
    4.83 +      xen_host_free(host);
    4.84 +      return 0;
    4.85 +   }
    4.86 +      
    4.87 +   *res = (void *)host_rec;
    4.88 +   return 1;
    4.89 +}
    4.90 +
    4.91 +
    4.92 +static int get(void *res_list, void **res, CMPIStatus *status)
    4.93 +{
    4.94 +   xen_host host = NULL;
    4.95 +   xen_host_record *host_rec;
    4.96 +
    4.97 +   (void) res_list;
    4.98 +   
    4.99 +   if (!xen_utils_validate_session(&session)) {
   4.100 +      _SBLIM_TRACE(1, ("--- Unable to establish connection with Xend"));
   4.101 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
   4.102 +                           "Unable to establish connection with Xend");
   4.103 +      return 0;
   4.104 +   }
   4.105 +
   4.106 +   xen_session_get_this_host(session->xen, &host, session->xen);
   4.107 +   xen_host_get_record(session->xen, &host_rec, host);
   4.108 +   if (!session->xen->ok) {
   4.109 +      /* Error description in session object. */
   4.110 +      _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   4.111 +                   ("--- failed to retrieve host record from Xend:"));
   4.112 +      _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
   4.113 +                            xen_utils_trace_error(session->xen));
   4.114 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
   4.115 +                           "Failed to retrieve host record from Xend");
   4.116 +      xen_host_free(host);
   4.117        return 0;
   4.118     }
   4.119  
   4.120 @@ -153,32 +164,32 @@ static int get(void* res_list, void** re
   4.121  }
   4.122  
   4.123  
   4.124 -static void release(void* res)
   4.125 +static void release(void *res)
   4.126  {
   4.127     xen_host_record_free(res);
   4.128  }
   4.129  
   4.130  
   4.131 -static int add(void** res_list, void* res)
   4.132 +static int add(void **res_list, void *res, CMPIStatus *status)
   4.133  {
   4.134     return -1; /* unsupported */
   4.135  }
   4.136  
   4.137  
   4.138 -static int delete(void** res_list, void* res)
   4.139 +static int delete(void **res_list, void *res, CMPIStatus *status)
   4.140  {
   4.141     return -1; /* unsupported */
   4.142  }
   4.143  
   4.144  
   4.145 -static int modify(void** res_list, void* res)
   4.146 +static int modify(void **res_list, void *res, CMPIStatus *status)
   4.147  {
   4.148     return -1; /* unsupported */
   4.149  }
   4.150  
   4.151  
   4.152  /* Set CMPIInstance properties from the resource data. */
   4.153 -static int res2inst(void* res, CMPIInstance* inst)
   4.154 +static int res2inst(void *res, CMPIInstance *inst, CMPIStatus *status)
   4.155  {
   4.156     xen_host_record *host_rec;
   4.157     int supported;
   4.158 @@ -268,9 +279,9 @@ static int res2inst(void* res, CMPIInsta
   4.159  
   4.160  
   4.161  /* Set resource data from the CMPIInstance properties. */ 
   4.162 -static int inst2res(CMPIInstance* inst, void** res)
   4.163 +static int inst2res(CMPIInstance *inst, void **res, CMPIStatus *status)
   4.164  {
   4.165 -   xen_host host;
   4.166 +   xen_host host = NULL;
   4.167     xen_host_record *host_rec;
   4.168  
   4.169     (void) inst;
   4.170 @@ -282,6 +293,8 @@ static int inst2res(CMPIInstance* inst, 
   4.171     if (!xen_utils_validate_session(&session)) {
   4.172        _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   4.173                     ("--- Unable to establish connection with Xend"));
   4.174 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
   4.175 +                           "Unable to establish connection with Xend");
   4.176        return 0;
   4.177     }
   4.178  
   4.179 @@ -293,6 +306,9 @@ static int inst2res(CMPIInstance* inst, 
   4.180                     ("--- failed to retrieve host record from Xend:"));
   4.181        _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
   4.182                              xen_utils_trace_error(session->xen));
   4.183 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_FAILED,
   4.184 +                           "Failed to retrieve host record from Xend");
   4.185 +      xen_host_free(host);
   4.186        return 0;
   4.187     }
   4.188  
     5.1 --- a/src/cmpilr.c	Fri May 11 13:14:41 2007 -0600
     5.2 +++ b/src/cmpilr.c	Fri May 11 17:17:46 2007 -0600
     5.3 @@ -58,7 +58,7 @@ static int op2res(CMPIObjectPath* op, vo
     5.4     }
     5.5  
     5.6     /* Create a partial resource from the CMPIInstance key properties. */
     5.7 -   return _FT->inst2res(inst, res);
     5.8 +   return _FT->inst2res(inst, res, &status);
     5.9  }
    5.10  
    5.11  /* ------------------------------------------------------------------------- */
    5.12 @@ -70,15 +70,14 @@ static int getres4op(void** res, CMPIObj
    5.13     int rc = op2res(op, res, mi);
    5.14     if (!rc || !*res) return 0;
    5.15  
    5.16 +   void *resList = NULL;
    5.17     /* Get handle to the list of resources. */
    5.18 -   void* resList = _FT->beginEnum();
    5.19 -   if (!resList) {
    5.20 -      _FT->release(*res);
    5.21 -      return 0;
    5.22 -   }
    5.23 +   if (!_FT->beginEnum(&resList, &status))
    5.24 +       return 0;
    5.25 +
    5.26  
    5.27     /* First try to get the target resource directly. */
    5.28 -   rc = _FT->get(resList, res);
    5.29 +   rc = _FT->get(resList, res, &status);
    5.30     if (rc == 0) { /* get() failed */
    5.31        _FT->release(*res);
    5.32        _FT->endEnum(resList);
    5.33 @@ -123,9 +122,11 @@ CMPIStatus CMPILR_enumInstanceNames
    5.34     CMPIStatus status = {CMPI_RC_OK, NULL};
    5.35  
    5.36     /* Get handle to the list of resources. */
    5.37 -   void* resList = _FT->beginEnum();
    5.38 -   if (!resList) {
    5.39 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "beginEnum() failed");
    5.40 +   void* resList = NULL;
    5.41 +   if (!_FT->beginEnum(&resList, &status)) {
    5.42 +      /* Set status to FAILED if beginEnum didn't update */
    5.43 +      if (status.rc == CMPI_RC_OK)
    5.44 +         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "beginEnum() failed");
    5.45        _SBLIM_RETURNSTATUS(status);
    5.46     }
    5.47  
    5.48 @@ -148,14 +149,17 @@ CMPIStatus CMPILR_enumInstanceNames
    5.49        }
    5.50  
    5.51        /* Get the next resource. */
    5.52 -      void* res = _FT->getNext(resList);
    5.53 -      if (!res) break; /* while() loop exit! */
    5.54 +      void* res = NULL;
    5.55 +      if (!_FT->getNext(resList, &res, &status))
    5.56 +         break; /* while() loop exit! */
    5.57  
    5.58        /* Set the CMPIInstance properties from the resource data. */
    5.59 -      int rc = _FT->res2inst(res, inst);
    5.60 +      int rc = _FT->res2inst(res, inst, &status);
    5.61        _FT->release(res);
    5.62        if (!rc) {
    5.63 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "res2inst() failed");
    5.64 +         /* Honor status set by resource. */
    5.65 +         if (status.rc == CMPI_RC_OK)
    5.66 +            CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "res2inst() failed");
    5.67           break;
    5.68        }
    5.69  
    5.70 @@ -181,8 +185,10 @@ CMPIStatus CMPILR_enumInstanceNames
    5.71     } /* while() */
    5.72     _FT->endEnum(resList);
    5.73  
    5.74 -   if (found) {if (status.rc == CMPI_RC_OK) CMReturnDone(rslt);}
    5.75 -   else CMSetStatus(&status, CMPI_RC_ERR_NOT_FOUND); 
    5.76 +   _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_INFO,("--- %d instance names found", found));
    5.77 +
    5.78 +   if (status.rc == CMPI_RC_OK)
    5.79 +      CMReturnDone(rslt);
    5.80  
    5.81      _SBLIM_RETURNSTATUS(status);
    5.82  }
    5.83 @@ -197,9 +203,11 @@ CMPIStatus CMPILR_enumInstances
    5.84     CMPIStatus status = {CMPI_RC_OK, NULL};
    5.85  
    5.86     /* Get handle to the list of resources. */
    5.87 -   void* resList = _FT->beginEnum();
    5.88 -   if (!resList) {
    5.89 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "beginEnum() failed");
    5.90 +   void* resList = NULL;
    5.91 +   if (!_FT->beginEnum(&resList, &status)) {
    5.92 +      /* Set status to FAILED if beginEnum didn't update */
    5.93 +      if (status.rc == CMPI_RC_OK)
    5.94 +         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "beginEnum() failed");
    5.95        _SBLIM_RETURNSTATUS(status);
    5.96     }
    5.97  
    5.98 @@ -222,8 +230,9 @@ CMPIStatus CMPILR_enumInstances
    5.99        }
   5.100  
   5.101        /* Get the next resource. */
   5.102 -      void* res = _FT->getNext(resList);
   5.103 -      if (!res) break; /* while() loop exit! */
   5.104 +      void* res = NULL;
   5.105 +      if (!_FT->getNext(resList, &res, &status))
   5.106 +         break; /* while() loop exit! */
   5.107  
   5.108        /* Set the property filter for this CMPIInstance, if specified. */
   5.109        if (properties != NULL) {
   5.110 @@ -235,10 +244,12 @@ CMPIStatus CMPILR_enumInstances
   5.111        }
   5.112  
   5.113        /* Set the CMPIInstance properties from the resource data. */
   5.114 -      int rc = _FT->res2inst(res, inst);
   5.115 +      int rc = _FT->res2inst(res, inst, &status);
   5.116        _FT->release(res);
   5.117        if (!rc) {
   5.118 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "res2inst() failed");
   5.119 +         /* Honor status set by resource. */
   5.120 +         if (status.rc == CMPI_RC_OK)
   5.121 +            CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "res2inst() failed");
   5.122           break;
   5.123        }
   5.124  
   5.125 @@ -252,8 +263,10 @@ CMPIStatus CMPILR_enumInstances
   5.126     } /* while() */
   5.127     _FT->endEnum(resList);
   5.128  
   5.129 -   if (found) {if (status.rc == CMPI_RC_OK) CMReturnDone(rslt);}
   5.130 -   else CMSetStatus(&status, CMPI_RC_ERR_NOT_FOUND);
   5.131 +   _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_INFO,("--- %d instances found", found));
   5.132 +
   5.133 +   if (status.rc == CMPI_RC_OK)
   5.134 +      CMReturnDone(rslt);
   5.135  
   5.136      _SBLIM_RETURNSTATUS(status);
   5.137  }
   5.138 @@ -292,10 +305,12 @@ CMPIStatus CMPILR_getInstance
   5.139     } 
   5.140  
   5.141     /* Set the CMPIInstance properties from the resource data. */
   5.142 -   rc = _FT->res2inst(res, inst);
   5.143 +   rc = _FT->res2inst(res, inst, &status);
   5.144     _FT->release(res);
   5.145     if (!rc) {
   5.146 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "res2inst() failed");
   5.147 +      /* Honor status set by resource. */
   5.148 +      if (status.rc == CMPI_RC_OK)
   5.149 +         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "res2inst() failed");
   5.150        _SBLIM_RETURNSTATUS(status);
   5.151     }
   5.152  
   5.153 @@ -318,7 +333,7 @@ CMPIStatus CMPILR_createInstance
   5.154     CMPIStatus status = {CMPI_RC_OK, NULL};
   5.155  
   5.156     /* Try to get the target resource. */
   5.157 -   void* res;
   5.158 +   void* res = NULL;
   5.159     int rc = getres4op(&res, (CMPIObjectPath*)ref, mi);
   5.160     if (rc) {
   5.161        _FT->release(res);
   5.162 @@ -326,25 +341,38 @@ CMPIStatus CMPILR_createInstance
   5.163        _SBLIM_RETURNSTATUS(status);
   5.164     }
   5.165  
   5.166 -   rc = _FT->inst2res((CMPIInstance*)inst, &res);
   5.167 +   rc = _FT->inst2res((CMPIInstance*)inst, &res, &status);
   5.168     if (!rc || !res) {
   5.169 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "inst2res() failed");
   5.170 +      /* Honor status set by resource. */
   5.171 +      if (status.rc == CMPI_RC_OK)
   5.172 +         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "inst2res() failed");
   5.173        _SBLIM_RETURNSTATUS(status);
   5.174     }
   5.175  
   5.176     /* Get handle to the list of resources. */
   5.177 -   void* resList = _FT->beginEnum();
   5.178 -   if (!resList) {
   5.179 +   void* resList = NULL;
   5.180 +   if (!_FT->beginEnum(&resList, &status)) {
   5.181        _FT->release(res);
   5.182 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "beginEnum() failed");
   5.183 +      /* Set status to FAILED if beginEnum didn't update */
   5.184 +      if (status.rc == CMPI_RC_OK)
   5.185 +         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "beginEnum() failed");
   5.186        _SBLIM_RETURNSTATUS(status);
   5.187     }
   5.188  
   5.189     /* Add the target resource. */
   5.190 -   rc = _FT->add(&resList, res);
   5.191 -   if (rc == -1) CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, "add() unsupported")
   5.192 -   else if (!rc) CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "add() failed");
   5.193 -
   5.194 +   rc = _FT->add(&resList, res, &status);
   5.195 +   if (rc != 1) {
   5.196 +      /* Honor status set by resource. */
   5.197 +      if (status.rc == CMPI_RC_OK) {
   5.198 +         if (rc == -1) {
   5.199 +            CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, "add() unsupported");
   5.200 +         }
   5.201 +         else {
   5.202 +            CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "add() failed");
   5.203 +         }
   5.204 +      }
   5.205 +   }
   5.206 +      
   5.207     _FT->release(res);
   5.208     _FT->endEnum(resList);
   5.209  
   5.210 @@ -368,25 +396,39 @@ CMPIStatus CMPILR_modifyInstance
   5.211        _SBLIM_RETURNSTATUS(status);
   5.212     }
   5.213  
   5.214 -   rc = _FT->inst2res((CMPIInstance*)inst, &res);
   5.215 +   rc = _FT->inst2res((CMPIInstance*)inst, &res, &status);
   5.216     if (!rc || !res) {
   5.217 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "inst2res() failed");
   5.218 +      /* Honor status set by resource. */
   5.219 +      if (status.rc == CMPI_RC_OK)
   5.220 +         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "inst2res() failed");
   5.221        _SBLIM_RETURNSTATUS(status);
   5.222     }
   5.223  
   5.224     /* Get handle to the list of resources. */
   5.225 -   void* resList = _FT->beginEnum();
   5.226 -   if (!resList) {
   5.227 +   void* resList = NULL;
   5.228 +   if (!_FT->beginEnum(&resList, &status)) {
   5.229        _FT->release(res);
   5.230 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "beginEnum() failed");
   5.231 +      /* Set status to FAILED if beginEnum didn't update */
   5.232 +      if (status.rc == CMPI_RC_OK)
   5.233 +         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "beginEnum() failed");
   5.234        _SBLIM_RETURNSTATUS(status);
   5.235     }
   5.236  
   5.237     /* Add the target resource. */
   5.238 -   rc = _FT->modify(&resList, res);
   5.239 -   if (rc == -1) CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, "modify() unsupported")
   5.240 -   else if (!rc) CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "modify() failed");
   5.241 -
   5.242 +   rc = _FT->modify(&resList, res, &status);
   5.243 +   if (rc != 1) {
   5.244 +      /* Honor status set by resource. */
   5.245 +      if (status.rc == CMPI_RC_OK) {
   5.246 +         if (rc == -1) {
   5.247 +            CMSetStatusWithChars(_BROKER, &status,
   5.248 +                                 CMPI_RC_ERR_NOT_SUPPORTED, "add() unsupported");
   5.249 +         }
   5.250 +         else {
   5.251 +            CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "add() failed");
   5.252 +         }
   5.253 +      }
   5.254 +   }
   5.255 +   
   5.256     _FT->release(res);
   5.257     _FT->endEnum(resList);
   5.258  
   5.259 @@ -411,16 +453,28 @@ CMPIStatus CMPILR_deleteInstance
   5.260     }
   5.261  
   5.262     /* Get handle to the list of resources. */
   5.263 -   void* resList = _FT->beginEnum();
   5.264 -   if (!resList) {
   5.265 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "beginEnum() failed");
   5.266 +   void* resList = NULL;
   5.267 +   if (!_FT->beginEnum(&resList, &status)) {
   5.268 +      /* Set status to FAILED if beginEnum didn't update */
   5.269 +      if (status.rc == CMPI_RC_OK)
   5.270 +         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "beginEnum() failed");
   5.271        _SBLIM_RETURNSTATUS(status);
   5.272     }
   5.273  
   5.274     /* Delete the target resource. */
   5.275 -   rc = _FT->delete(&resList, res);
   5.276 -   if (rc == -1) CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, "delete() unsupported")
   5.277 -   else if (!rc) CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "delete() failed");
   5.278 +   rc = _FT->delete(&resList, res, &status);
   5.279 +   if (rc != 1) {
   5.280 +      /* Honor status set by resource. */
   5.281 +      if (status.rc == CMPI_RC_OK) {
   5.282 +         if (rc == -1) {
   5.283 +            CMSetStatusWithChars(_BROKER, &status,
   5.284 +                                 CMPI_RC_ERR_NOT_SUPPORTED, "add() unsupported");
   5.285 +         }
   5.286 +         else {
   5.287 +            CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "add() failed");
   5.288 +         }
   5.289 +      }
   5.290 +   }
   5.291  
   5.292     _FT->release(res);
   5.293     _FT->endEnum(resList);
   5.294 @@ -445,9 +499,11 @@ CMPIStatus CMPILR_execQuery
   5.295     }
   5.296  
   5.297     /* Get handle to the list of resources. */
   5.298 -   void* resList = _FT->beginEnum();
   5.299 -   if (!resList) {
   5.300 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "beginEnum() failed");
   5.301 +   void* resList = NULL;
   5.302 +   if (!_FT->beginEnum(&resList, &status)) {
   5.303 +      /* Set status to FAILED if beginEnum didn't update */
   5.304 +      if (status.rc == CMPI_RC_OK)
   5.305 +         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "beginEnum() failed");
   5.306        _SBLIM_RETURNSTATUS(status);
   5.307     }
   5.308  
   5.309 @@ -470,14 +526,17 @@ CMPIStatus CMPILR_execQuery
   5.310        }
   5.311  
   5.312        /* Get the next resource. */
   5.313 -      void* res = _FT->getNext(resList);
   5.314 -      if (!res) break; /* while() loop exit! */
   5.315 +      void* res = NULL;
   5.316 +      if (!_FT->getNext(resList, &res, &status))
   5.317 +         break; /* while() loop exit! */
   5.318  
   5.319        /* Set the CMPIInstance properties from the resource data. */
   5.320 -      int rc = _FT->res2inst(res, inst);
   5.321 +      int rc = _FT->res2inst(res, inst, &status);
   5.322        _FT->release(res);
   5.323        if (!rc) {
   5.324 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "res2inst() failed");
   5.325 +         /* Honor status set by resource. */
   5.326 +         if (status.rc == CMPI_RC_OK)
   5.327 +            CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "res2inst() failed");
   5.328           break;
   5.329        }
   5.330  
   5.331 @@ -500,8 +559,10 @@ CMPIStatus CMPILR_execQuery
   5.332     } /* while() */
   5.333     _FT->endEnum(resList);
   5.334  
   5.335 -   if (found) {if (status.rc == CMPI_RC_OK) CMReturnDone(rslt);}
   5.336 -   else CMSetStatus(&status, CMPI_RC_ERR_NOT_FOUND);
   5.337 +   _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_INFO,("--- %d instances found", found));
   5.338 +
   5.339 +   if (status.rc == CMPI_RC_OK)
   5.340 +      CMReturnDone(rslt);
   5.341  
   5.342      _SBLIM_RETURNSTATUS(status);
   5.343  }
     6.1 --- a/src/cmpilr.h	Fri May 11 13:14:41 2007 -0600
     6.2 +++ b/src/cmpilr.h	Fri May 11 17:17:46 2007 -0600
     6.3 @@ -29,16 +29,16 @@
     6.4  typedef struct _CMPIResourceFT {
     6.5     int (*load)();
     6.6     int (*unload)(CMPIBoolean terminating);
     6.7 -   void* (*beginEnum)();
     6.8 +   int (*beginEnum)(void **resList, CMPIStatus *status);
     6.9     void (*endEnum)(void* resList);
    6.10 -   void* (*getNext)(void* resList);
    6.11 -   int (*get)(void* resList, void** res);
    6.12 +   int (*getNext)(void* resList, void **res, CMPIStatus *status);
    6.13 +   int (*get)(void* resList, void** res, CMPIStatus *status);
    6.14     void (*release)(void* res);
    6.15 -   int (*add)(void** resList, void* res);
    6.16 -   int (*delete)(void** resList, void* res);
    6.17 -   int (*modify)(void** resList, void* res);
    6.18 -   int (*res2inst)(void* res, CMPIInstance* inst);
    6.19 -   int (*inst2res)(CMPIInstance* inst, void** res);
    6.20 +   int (*add)(void** resList, void* res, CMPIStatus *status);
    6.21 +   int (*delete)(void** resList, void* res, CMPIStatus *status);
    6.22 +   int (*modify)(void** resList, void* res, CMPIStatus *status);
    6.23 +   int (*res2inst)(void* res, CMPIInstance* inst, CMPIStatus *status);
    6.24 +   int (*inst2res)(CMPIInstance* inst, void** res, CMPIStatus *status);
    6.25  } CMPIResourceFT;
    6.26  
    6.27  /* ------------------------------------------------------------------------- */