
# HG changeset patch # User Jay Gagnon <grendel@linux.vnet.ibm.com> # Date 1194970453 18000 # Node ID 00626d8731495a89a93055be42ac52951f6fbcc7 # Parent 146a93bf2b929232c41bf7ed157c0343481d01a3 Turns out that the sdc_rasd_prop functions might need to report status or see the passed in reference. This updates the typedef and the memory functions, since those are already in the tree. Signed-off-by: Jay Gagnon <grendel@linux.vnet.ibm.com> diff -r 146a93bf2b92 -r 00626d873149 src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Mon Nov 12 17:53:00 2007 -0800 +++ b/src/Virt_ElementCapabilities.c Tue Nov 13 11:14:13 2007 -0500 @@ -94,14 +94,16 @@ static CMPIStatus cap_to_sys(const CMPIO inst_id = cu_get_str_path(ref, "InstanceID"); if (inst_id == NULL) { - CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED, - "Could not get InstanceID."); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Could not get InstanceID."); goto out; } if (!parse_fq_devid(inst_id, &host, &device)) { - CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED, - "Could not get system name."); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Could not get system name."); goto out; } @@ -152,14 +154,16 @@ static CMPIStatus cap_to_cs(const CMPIOb inst_id = cu_get_str_path(ref, "InstanceID"); if (inst_id == NULL) { - CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED, - "Could not get InstanceID."); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Could not get InstanceID."); goto error1; } if (!parse_fq_devid(inst_id, &host, &device)) { - CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED, - "Could not get system name."); + cu_status(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Could not get system name."); goto error1; } diff -r 146a93bf2b92 -r 00626d873149 src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Mon Nov 12 17:53:00 2007 -0800 +++ b/src/Virt_SettingsDefineCapabilities.c Tue Nov 13 11:14:13 2007 -0500 @@ -96,84 +96,100 @@ static bool free_rasd_prop_list(struct s return true; } -static struct sdc_rasd_prop *mem_max(void) -{ - bool ret; - struct sdc_rasd_prop *rasd; +static struct sdc_rasd_prop *mem_max(const CMPIObjectPath *ref, + CMPIStatus *s) +{ + bool ret; + struct sdc_rasd_prop *rasd = NULL; uint64_t max_vq = MAX_MEM; - struct sdc_rasd_prop max[] = { + struct sdc_rasd_prop tmp[] = { {"InstanceID", (CMPIValue *)"Maximum", CMPI_chars}, {"AllocationUnits", (CMPIValue *)"MegaBytes", CMPI_chars}, {"VirtualQuantity", (CMPIValue *)&max_vq, CMPI_uint64}, PROP_END }; - ret = dup_rasd_prop_list(max, &rasd); - if (ret) - return rasd; - else - return NULL; -} - -static struct sdc_rasd_prop *mem_min(void) -{ - bool ret; - struct sdc_rasd_prop *rasd; + ret = dup_rasd_prop_list(tmp, &rasd); + if (!ret) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not copy RASD."); + } + + return rasd; +} + +static struct sdc_rasd_prop *mem_min(const CMPIObjectPath *ref, + CMPIStatus *s) +{ + bool ret; + struct sdc_rasd_prop *rasd = NULL; uint64_t min_vq = 64; - struct sdc_rasd_prop min[] = { + struct sdc_rasd_prop tmp[] = { {"InstanceID", (CMPIValue *)"Minimum", CMPI_chars}, {"AllocationUnits", (CMPIValue *)"MegaBytes", CMPI_chars}, {"VirtualQuantity", (CMPIValue *)&min_vq, CMPI_uint64}, PROP_END }; - ret = dup_rasd_prop_list(min, &rasd); - if (ret) - return rasd; - else - return NULL; -} - -static struct sdc_rasd_prop *mem_def(void) -{ - bool ret; - struct sdc_rasd_prop *rasd; + ret = dup_rasd_prop_list(tmp, &rasd); + if (!ret) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not copy RASD."); + } + + return rasd; +} + +static struct sdc_rasd_prop *mem_def(const CMPIObjectPath *ref, + CMPIStatus *s) +{ + bool ret; + struct sdc_rasd_prop *rasd = NULL; uint64_t def_vq = 256; - struct sdc_rasd_prop def[] = { + struct sdc_rasd_prop tmp[] = { {"InstanceID", (CMPIValue *)"Default", CMPI_chars}, {"AllocationUnits", (CMPIValue *)"MegaBytes", CMPI_chars}, {"VirtualQuantity", (CMPIValue *)&def_vq, CMPI_uint64}, PROP_END }; - ret = dup_rasd_prop_list(def, &rasd); - if (ret) - return rasd; - else - return NULL; -} - -static struct sdc_rasd_prop *mem_inc(void) -{ - bool ret; - struct sdc_rasd_prop *rasd; + ret = dup_rasd_prop_list(tmp, &rasd); + if (!ret) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not copy RASD."); + } + + return rasd; +} + +static struct sdc_rasd_prop *mem_inc(const CMPIObjectPath *ref, + CMPIStatus *s) +{ + bool ret; + struct sdc_rasd_prop *rasd = NULL; uint64_t inc_vq = 1; - struct sdc_rasd_prop inc[] = { + struct sdc_rasd_prop tmp[] = { {"InstanceID", (CMPIValue *)"Increment", CMPI_chars}, {"AllocationUnits", (CMPIValue *)"MegaBytes", CMPI_chars}, {"VirtualQuantity", (CMPIValue *)&inc_vq, CMPI_uint64}, PROP_END }; - ret = dup_rasd_prop_list(inc, &rasd); - if (ret) - return rasd; - else - return NULL; + ret = dup_rasd_prop_list(tmp, &rasd); + if (!ret) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not copy RASD."); + } + + return rasd; } static struct sdc_rasd mem = { @@ -190,17 +206,17 @@ static struct sdc_rasd *sdc_rasd_list[] }; static CMPIInstance *sdc_rasd_inst(const CMPIBroker *broker, + CMPIStatus *s, const CMPIObjectPath *ref, struct sdc_rasd *rasd, sdc_rasd_type type) { - CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; struct sdc_rasd_prop *prop_list; int i; char *inst_id; uint16_t resource_type; - /* Defaults for the following three values are from + /* Defaults for the following are from CIM_SettingsDefineCapabilities.mof. */ uint16_t policy = SDC_POLICY_INDEPENDENT; uint16_t role = SDC_ROLE_SUPPORTED; @@ -209,43 +225,40 @@ static CMPIInstance *sdc_rasd_inst(const case SDC_RASD_MIN: if (rasd->min == NULL) goto out; - prop_list = rasd->min(); + prop_list = rasd->min(ref, s); inst_id = "Minimum"; range = SDC_RANGE_MIN; break; case SDC_RASD_MAX: if (rasd->max == NULL) goto out; - prop_list = rasd->max(); + prop_list = rasd->max(ref, s); inst_id = "Maximum"; range = SDC_RANGE_MAX; break; case SDC_RASD_INC: if (rasd->inc == NULL) goto out; - prop_list = rasd->inc(); + prop_list = rasd->inc(ref, s); inst_id = "Increment"; range = SDC_RANGE_INC; break; case SDC_RASD_DEF: if (rasd->def == NULL) goto out; - prop_list = rasd->def(); + prop_list = rasd->def(ref, s); inst_id = "Default"; role = SDC_ROLE_DEFAULT; range = SDC_RANGE_POINT; break; default: - CMSetStatusWithChars(broker, &s, CMPI_RC_ERR_FAILED, + CMSetStatusWithChars(broker, s, CMPI_RC_ERR_FAILED, "Unsupported sdc_rasd type."); goto out; } - if (prop_list == NULL) { - CMSetStatusWithChars(broker, &s, CMPI_RC_ERR_FAILED, - "Failed to get prop_list."); + if (s->rc != CMPI_RC_OK) goto out; - } inst = get_typed_instance(broker, "ResourceAllocationSettingData", @@ -291,7 +304,11 @@ static CMPIStatus sdc_rasds_for_type(con if (rasd) { for (i = SDC_RASD_MIN; i <= SDC_RASD_INC; i++) { - inst = sdc_rasd_inst(_BROKER, ref, rasd, i); + inst = sdc_rasd_inst(_BROKER, &s, ref, rasd, i); + if (s.rc != CMPI_RC_OK) { + CU_DEBUG("Problem getting inst."); + goto out; + } CU_DEBUG("Got inst.\n"); if (inst != NULL) { inst_list_add(list, inst); @@ -307,6 +324,7 @@ static CMPIStatus sdc_rasds_for_type(con "Unsupported device type."); } + out: return s; } diff -r 146a93bf2b92 -r 00626d873149 src/Virt_SettingsDefineCapabilities.h --- a/src/Virt_SettingsDefineCapabilities.h Mon Nov 12 17:53:00 2007 -0800 +++ b/src/Virt_SettingsDefineCapabilities.h Tue Nov 13 11:14:13 2007 -0500 @@ -50,7 +50,8 @@ struct sdc_rasd_prop { CMPIType type; }; -typedef struct sdc_rasd_prop *(*rasd_prop_func_t)(void); +typedef struct sdc_rasd_prop *(*rasd_prop_func_t)(const CMPIObjectPath *ref, + CMPIStatus *s); struct sdc_rasd { uint16_t resource_type;