[PATCH 0 of 2] Updated ElementSettingData to support RASD instances.

Revised so that get_rasd_instance_from_ref() takes an InstanceID argument. Also, cleaned up some of the confusion structure / function names in Virt_ElementSettingData.

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1195605864 28800 # Node ID 00a0b30a8d7b7d11ba03b0857962ac15b40868ed # Parent 83aeadb6ebd9089e633013a0c65246a6d4881fcb Add get_rasd_instance_from_ref() to RASD. This allows other providers to get a specific RASD instance without having to do a CBGetInstance(). Updated get_rasd_instance_from_ref() to take an InstanceID parameter. The original version used the InstanceID from the ref. This was incorrect becasue the ref might not always have an InstanceID or the InstanceID might not correspond to the InstanceID of the RASD instance we want to return. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 83aeadb6ebd9 -r 00a0b30a8d7b src/Virt_RASD.c --- a/src/Virt_RASD.c Tue Nov 20 16:39:17 2007 -0800 +++ b/src/Virt_RASD.c Tue Nov 20 16:44:24 2007 -0800 @@ -179,6 +179,7 @@ static CMPIInstance *rasd_from_vdev(cons static CMPIInstance *get_rasd_instance(const CMPIContext *context, const CMPIObjectPath *ref, + const CMPIBroker *broker, const char *id, const uint16_t type) { @@ -194,13 +195,13 @@ static CMPIInstance *get_rasd_instance(c if (!ret) return NULL; - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); + conn = connect_by_classname(broker, CLASSNAME(ref), &s); if (conn == NULL) goto out; dev = find_dev(conn, type, host, devid); if (dev) - inst = rasd_from_vdev(_BROKER, dev, host, ref); + inst = rasd_from_vdev(broker, dev, host, ref); out: virConnectClose(conn); @@ -238,6 +239,28 @@ CMPIrc rasd_type_from_classname(const ch return rc; } +CMPIInstance *get_rasd_instance_from_ref(const CMPIContext *context, + const CMPIObjectPath *ref, + const char *id, + const CMPIBroker *broker) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + uint16_t type; + + if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to determine RASD type"); + goto out; + } + + inst = get_rasd_instance(context, ref, broker, id, type); + + out: + return inst; +} + static CMPIStatus GetInstance(CMPIInstanceMI *self, const CMPIContext *context, const CMPIResult *results, @@ -247,7 +270,6 @@ static CMPIStatus GetInstance(CMPIInstan CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst; char *id = NULL; - uint16_t type; id = cu_get_str_path(ref, "InstanceID"); if (id == NULL) { @@ -257,14 +279,7 @@ static CMPIStatus GetInstance(CMPIInstan goto out; } - if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Unable to determine RASD type"); - goto out; - } - - inst = get_rasd_instance(context, ref, id, type); + inst = get_rasd_instance_from_ref(context, ref, id, _BROKER); if (inst != NULL) CMReturnInstance(results, inst); @@ -273,6 +288,8 @@ static CMPIStatus GetInstance(CMPIInstan CMPI_RC_ERR_FAILED, "Unknown instance"); out: + free(id); + return s; } diff -r 83aeadb6ebd9 -r 00a0b30a8d7b src/Virt_RASD.h --- a/src/Virt_RASD.h Tue Nov 20 16:39:17 2007 -0800 +++ b/src/Virt_RASD.h Tue Nov 20 16:44:24 2007 -0800 @@ -41,6 +41,11 @@ int rasds_for_domain(const CMPIBroker *b CMPIrc rasd_type_from_classname(const char *cn, uint16_t *type); +CMPIInstance *get_rasd_instance_from_ref(const CMPIContext *context, + const CMPIObjectPath *ref, + const char *id, + const CMPIBroker *broker); + #endif /*

KR> # HG changeset patch KR> # User Kaitlin Rupert <karupert@us.ibm.com> KR> # Date 1195605864 28800 KR> # Node ID 00a0b30a8d7b7d11ba03b0857962ac15b40868ed KR> # Parent 83aeadb6ebd9089e633013a0c65246a6d4881fcb KR> Add get_rasd_instance_from_ref() to RASD. KR> Updated get_rasd_instance_from_ref() to take an InstanceID KR> parameter. The original version used the InstanceID from the ref. KR> This was incorrect becasue the ref might not always have an KR> InstanceID or the InstanceID might not correspond to the KR> InstanceID of the RASD instance we want to return. Right, so... KR> +CMPIInstance *get_rasd_instance_from_ref(const CMPIContext *context, KR> + const CMPIObjectPath *ref, KR> + const char *id, KR> + const CMPIBroker *broker) KR> +{ KR> + CMPIStatus s = {CMPI_RC_OK, NULL}; KR> + CMPIInstance *inst = NULL; KR> + uint16_t type; KR> + KR> + if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) { KR> + cu_statusf(broker, &s, KR> + CMPI_RC_ERR_FAILED, KR> + "Unable to determine RASD type"); KR> + goto out; KR> + } Doesn't the same go for the type? If you are in VSSDC, say, then you have probably have a ref of root/virt:Xen_VSSDC.InstanceID="Xen:foo", which will not resolve to a valid type if you call rasd_type_from_classname() on it, as above. In most of our other external interfaces like this, we pass around a char *id and a uint16_t type, which is one of CIM_RASD_TYPE_*, per svpd_types.h. See Virt_DevicePool.h:get_pool_by_type() for example. KR> + inst = get_rasd_instance(context, ref, broker, id, type); Also, since we're not really getting the RASD information from the ref, I'm not sure the function is properly named, nor needed at this point. I think simply making the get_rasd_instance() non-static and exposed will do what we want, right? -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

Dan Smith wrote:
Doesn't the same go for the type? If you are in VSSDC, say, then you have probably have a ref of root/virt:Xen_VSSDC.InstanceID="Xen:foo", which will not resolve to a valid type if you call rasd_type_from_classname() on it, as above.
In most of our other external interfaces like this, we pass around a char *id and a uint16_t type, which is one of CIM_RASD_TYPE_*, per svpd_types.h. See Virt_DevicePool.h:get_pool_by_type() for example.
KR> + inst = get_rasd_instance(context, ref, broker, id, type);
Also, since we're not really getting the RASD information from the ref, I'm not sure the function is properly named, nor needed at this point. I think simply making the get_rasd_instance() non-static and exposed will do what we want, right?
Yes, I think you're right. Trying to encapsulate this behavior only works for some cases. It isn't generic enough to warrant a new function. Will generate a new patch. =) -- Kaitlin Rupert IBM Linux Technology Center karupert@us.ibm.com

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1195605557 28800 # Node ID 83aeadb6ebd9089e633013a0c65246a6d4881fcb # Parent 278c59f67cb1fe0520e8dfa7b118cd907e8f10a1 Adding the RASD related part. This is based on the Resource Allocation Profile. My understanding is that we are implementing a setup similar to Figure 3 on page 31. In this case, we'll use the same RASD instance for State as well as Defined. Updated to due to change in get_rasd_instance_from_ref(). Also updated structure and handler function names to avoid confusion. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 278c59f67cb1 -r 83aeadb6ebd9 src/Makefile.am --- a/src/Makefile.am Tue Nov 20 16:26:00 2007 -0500 +++ b/src/Makefile.am Tue Nov 20 16:39:17 2007 -0800 @@ -135,4 +135,4 @@ libVirt_HostedService_la_LIBADD = -lVirt libVirt_ElementSettingData_la_DEPENDENCIES = libVirt_VSSD.la libVirt_ElementSettingData_la_SOURCES = Virt_ElementSettingData.c -libVirt_ElementSettingData_la_LIBADD = -lVirt_VSSD +libVirt_ElementSettingData_la_LIBADD = -lVirt_VSSD -lVirt_RASD diff -r 278c59f67cb1 -r 83aeadb6ebd9 src/Virt_ElementSettingData.c --- a/src/Virt_ElementSettingData.c Tue Nov 20 16:26:00 2007 -0500 +++ b/src/Virt_ElementSettingData.c Tue Nov 20 16:39:17 2007 -0800 @@ -31,12 +31,13 @@ #include "misc_util.h" #include "Virt_VSSD.h" +#include "Virt_RASD.h" const static CMPIBroker *_BROKER; -static CMPIStatus vssd_to_sd(const CMPIObjectPath *ref, - struct std_assoc_info *info, - struct inst_list *list) +static CMPIStatus vssd_to_vssd(const CMPIObjectPath *ref, + struct std_assoc_info *info, + struct inst_list *list) { CMPIStatus s; CMPIInstance *inst; @@ -83,6 +84,41 @@ static CMPIStatus vssd_to_sd(const CMPIO return s; } +static CMPIStatus rasd_to_rasd(const CMPIObjectPath *ref, + struct std_assoc_info *info, + struct inst_list *list) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst; + char *id; + + ASSOC_MATCH(info->provider_name, CLASSNAME(ref)); + + id = cu_get_str_path(ref, "InstanceID"); + if (id == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Missing InstanceID"); + goto out; + } + + inst = get_rasd_instance_from_ref(info->context, ref, id, _BROKER); + if (inst == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Error getting associated RASD"); + + goto out; + } + + inst_list_add(list, inst); + + out: + free(id); + + return s; +} + static CMPIInstance *make_ref(const CMPIObjectPath *ref, const CMPIInstance *inst, struct std_assoc_info *info, @@ -130,7 +166,7 @@ out: return refinst; } -static struct std_assoc vssd_to_sd_fd_bkwd = { +static struct std_assoc _vssd_to_vssd = { .source_class = "CIM_VirtualSystemSettingData", .source_prop = "ManagedElement", @@ -139,12 +175,26 @@ static struct std_assoc vssd_to_sd_fd_bk .assoc_class = "CIM_ElementSettingData", - .handler = vssd_to_sd, + .handler = vssd_to_vssd, .make_ref = make_ref }; +static struct std_assoc _rasd_to_rasd = { + .source_class = "CIM_ResourceAllocationSettingData", + .source_prop = "ManagedElement", + + .target_class = "CIM_ManagedElement", + .target_prop = "SettingData", + + .assoc_class = "CIM_ElementSettingData", + + .handler = rasd_to_rasd, + .make_ref = make_ref +}; + static struct std_assoc *handlers[] = { - &vssd_to_sd_fd_bkwd, + &_vssd_to_vssd, + &_rasd_to_rasd, NULL };
participants (2)
-
Dan Smith
-
Kaitlin Rupert