[PATCH] Fix stale issue with threads in Virt_HostedDependency association
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1201896389 28800
# Node ID 84ee0633c377768529c41463f0bf95b1c88c42e2
# Parent 5d554b65865ebaabf5261f7e8557dd7a40bf6175
Fix stale issue with threads in Virt_HostedDependency association
This crept in when we converted to lists of association classes with
std_assoc. It's a trivial fix, but it has to be done do all of our
associations, barring any that are correct already.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 5d554b65865e -r 84ee0633c377 src/Virt_HostedDependency.c
--- a/src/Virt_HostedDependency.c Fri Feb 01 11:30:37 2008 -0800
+++ b/src/Virt_HostedDependency.c Fri Feb 01 12:06:29 2008 -0800
@@ -84,19 +84,19 @@ static CMPIStatus host_to_vs(const CMPIO
LIBVIRT_CIM_DEFAULT_MAKEREF()
-char* antecedent[] = {
+static char* antecedent[] = {
"Xen_ComputerSystem",
"KVM_ComputerSystem",
NULL
};
-char* dependent[] = {
+static char* dependent[] = {
"Xen_HostSystem",
"KVM_HostSystem",
NULL
};
-char* assoc_classname[] = {
+static char* assoc_classname[] = {
"Xen_HostedDependency",
"KVM_HostedDependency",
NULL
16 years, 9 months
[PATCH 0 of 4] #2 - RPCS and RPCC ignores supported hypervisor type and wrong object path, adopt changes to HS
by Heidi Eckhart
This patch set is now the combination of the one patch against RPCS and the two patches against RPCC, I sent out on friday. The reason to combine these three patches in one patch set is, that both provider - RPCS and RPCC - look very similar now. This brought me to the idea, that it is possible to also define a common interface for instances providers - as this is already done for associations -, where the common functions could do a main part of the error handling (which is currently done again and again in each single provider itself).
In addition patch 4 updates HS (thanks to Kaitlin) with the new interface of RPCS.
16 years, 9 months
[PATCH] (#3) Remove the embedded object parsing pieces from VirtualSystemManagmentService
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1202147609 28800
# Node ID 245bbbe2d23427d18bbb476442ed5eef39ba12f2
# Parent 84ee0633c377768529c41463f0bf95b1c88c42e2
(#3) Remove the embedded object parsing pieces from VirtualSystemManagmentService.
Updates from set 2 to 3:
Added a tmp CMPIArray to rasd_refs_to_insts() to match usual out param style.
Updates from set 1 to set 2:
Removed unsused sys_op from define_system()
Removed unused list from update_resource_setting()
Changed CMPIArray **out_arr to **ret_arr in rasd_refs_to_insts()
Changed ReferencedConfiguration to ReferenceConfiguration in the definesystem handler.
Remove embedded object parsing since libcmpiutil now handles this. Also update the method handlers to expect instances instead of strings as arguments.
The following methods have been updated:
DefineSystem
AddResourceSettings
ModifyResourceSettings
ModifySystemSettings
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 84ee0633c377 -r 245bbbe2d234 src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Fri Feb 01 12:06:29 2008 -0800
+++ b/src/Virt_VirtualSystemManagementService.c Mon Feb 04 09:53:29 2008 -0800
@@ -57,69 +57,23 @@ enum ResourceAction {
RESOURCE_MOD,
};
-static int parse_str_inst_array(CMPIArray *array,
- const char *ns,
- struct inst_list *list)
-{
- int count;
- int i;
-
- count = CMGetArrayCount(array, NULL);
-
- for (i = 0; i < count; i++) {
- CMPIInstance *inst;
- CMPIData item;
- int ret;
-
- item = CMGetArrayElementAt(array, i, NULL);
- /* FIXME: Check for string here */
-
- ret = cu_parse_embedded_instance(CMGetCharPtr(item.value.string),
- _BROKER,
- ns,
- &inst);
-
- if (ret == 0)
- inst_list_add(list, inst);
- }
-
- return 1;
-}
-
static CMPIStatus define_system_parse_args(const CMPIArgs *argsin,
CMPIInstance **sys,
const char *ns,
- struct inst_list *res)
+ CMPIArray **res)
{
CMPIStatus s = {CMPI_RC_ERR_FAILED, NULL};
- const char *sys_str = NULL;
- CMPIArray *res_arr;
- int ret;
-
- if (cu_get_str_arg(argsin, "SystemSettings", &sys_str) != CMPI_RC_OK) {
+
+ if (cu_get_inst_arg(argsin, "SystemSettings", sys) != CMPI_RC_OK) {
CU_DEBUG("No SystemSettings string argument");
goto out;
}
- ret = cu_parse_embedded_instance(sys_str,
- _BROKER,
- ns,
- sys);
- if (ret) {
- CU_DEBUG("Unable to parse SystemSettings instance");
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "SystemSettings parse error");
- goto out;
- }
-
- if (cu_get_array_arg(argsin, "ResourceSettings", &res_arr) !=
+ if (cu_get_array_arg(argsin, "ResourceSettings", res) !=
CMPI_RC_OK) {
CU_DEBUG("Failed to get array arg");
goto out;
}
-
- ret = parse_str_inst_array(res_arr, ns, res);
CMSetStatus(&s, CMPI_RC_OK);
@@ -317,24 +271,34 @@ static int rasd_to_vdev(CMPIInstance *in
return 0;
}
-static int classify_resources(struct inst_list *all,
+static int classify_resources(CMPIArray *resources,
struct domain *domain)
{
int i;
uint16_t type;
+ int count;
domain->dev_disk_ct = domain->dev_net_ct = 0;
domain->dev_vcpu_ct = domain->dev_mem_ct = 0;
-
- domain->dev_disk = calloc(all->cur, sizeof(struct virt_device));
- domain->dev_vcpu = calloc(all->cur, sizeof(struct virt_device));
- domain->dev_mem = calloc(all->cur, sizeof(struct virt_device));
- domain->dev_net = calloc(all->cur, sizeof(struct virt_device));
-
- for (i = 0; i < all->cur; i++) {
+
+ count = CMGetArrayCount(resources, NULL);
+ if (count < 1)
+ return 0;
+
+ domain->dev_disk = calloc(count, sizeof(struct virt_device));
+ domain->dev_vcpu = calloc(count, sizeof(struct virt_device));
+ domain->dev_mem = calloc(count, sizeof(struct virt_device));
+ domain->dev_net = calloc(count, sizeof(struct virt_device));
+
+ for (i = 0; i < count; i++) {
CMPIObjectPath *op;
-
- op = CMGetObjectPath(all->list[i], NULL);
+ CMPIData item;
+
+ item = CMGetArrayElementAt(resources, i, NULL);
+ if (CMIsNullObject(item.value.inst))
+ return 0;
+
+ op = CMGetObjectPath(item.value.inst, NULL);
if (op == NULL)
return 0;
@@ -343,16 +307,16 @@ static int classify_resources(struct ins
return 0;
if (type == CIM_RASD_TYPE_PROC)
- rasd_to_vdev(all->list[i],
+ rasd_to_vdev(item.value.inst,
&domain->dev_vcpu[domain->dev_vcpu_ct++]);
else if (type == CIM_RASD_TYPE_MEM)
- rasd_to_vdev(all->list[i],
+ rasd_to_vdev(item.value.inst,
&domain->dev_mem[domain->dev_mem_ct++]);
else if (type == CIM_RASD_TYPE_DISK)
- rasd_to_vdev(all->list[i],
+ rasd_to_vdev(item.value.inst,
&domain->dev_disk[domain->dev_disk_ct++]);
else if (type == CIM_RASD_TYPE_NET)
- rasd_to_vdev(all->list[i],
+ rasd_to_vdev(item.value.inst,
&domain->dev_net[domain->dev_net_ct++]);
}
@@ -398,7 +362,7 @@ static CMPIInstance *connect_and_create(
}
static CMPIInstance *create_system(CMPIInstance *vssd,
- struct inst_list *resources,
+ CMPIArray *resources,
const CMPIObjectPath *ref,
CMPIStatus *s)
{
@@ -466,11 +430,8 @@ static CMPIStatus define_system(CMPIMeth
{
CMPIInstance *vssd;
CMPIInstance *sys;
- CMPIObjectPath *sys_op;
- struct inst_list res;
+ CMPIArray *res;
CMPIStatus s;
-
- inst_list_init(&res);
CU_DEBUG("DefineSystem");
@@ -478,15 +439,12 @@ static CMPIStatus define_system(CMPIMeth
if (s.rc != CMPI_RC_OK)
goto out;
- sys = create_system(vssd, &res, reference, &s);
+ sys = create_system(vssd, res, reference, &s);
if (sys == NULL)
goto out;
- inst_list_free(&res);
-
CMAddArg(argsout, "ResultingSystem", &sys, CMPI_instance);
- sys_op = CMGetObjectPath(sys, NULL);
trigger_indication(context,
"ComputerSystemCreatedIndication",
NAMESPACE(reference));
@@ -623,27 +581,14 @@ static CMPIStatus mod_system_settings(CM
const CMPIArgs *argsin,
CMPIArgs *argsout)
{
- const char *inst_str;
CMPIInstance *inst;
- if (cu_get_str_arg(argsin, "SystemSettings", &inst_str) != CMPI_RC_OK) {
+ if (cu_get_inst_arg(argsin, "SystemSettings", &inst) != CMPI_RC_OK) {
CMPIStatus s;
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
"Missing SystemSettings");
- return s;
- }
-
- if (cu_parse_embedded_instance(inst_str,
- _BROKER,
- NAMESPACE(reference),
- &inst)) {
- CMPIStatus s;
-
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Internal Parse Error on SystemSettings");
return s;
}
@@ -953,23 +898,30 @@ static CMPIStatus _update_resources_for(
}
static CMPIStatus _update_resource_settings(const CMPIObjectPath *ref,
- struct inst_list *list,
+ CMPIArray *resources,
resmod_fn func)
{
int i;
virConnectPtr conn = NULL;
CMPIStatus s;
+ int count;
conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
if (conn == NULL)
goto out;
- for (i = 0; i < list->cur; i++) {
- CMPIInstance *inst = list->list[i];
+ count = CMGetArrayCount(resources, NULL);
+
+ for (i = 0; i < count; i++) {
+ CMPIData item;
+ CMPIInstance *inst;
const char *id = NULL;
char *name = NULL;
char *devid = NULL;
virDomainPtr dom = NULL;
+
+ item = CMGetArrayElementAt(resources, i, NULL);
+ inst = item.value.inst;
if (cu_get_str_prop(inst, "InstanceID", &id) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
@@ -1016,9 +968,6 @@ static CMPIStatus update_resource_settin
{
CMPIArray *arr;
CMPIStatus s;
- struct inst_list list;
-
- inst_list_init(&list);
if (cu_get_array_arg(argsin, "ResourceSettings", &arr) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
@@ -1027,28 +976,30 @@ static CMPIStatus update_resource_settin
goto out;
}
- parse_str_inst_array(arr, NAMESPACE(ref), &list);
-
- s = _update_resource_settings(ref, &list, func);
-
- out:
- inst_list_free(&list);
-
+ s = _update_resource_settings(ref, arr, func);
+
+ out:
return s;
}
static CMPIStatus rasd_refs_to_insts(const CMPIContext *ctx,
const CMPIObjectPath *reference,
CMPIArray *arr,
- struct inst_list *list)
+ CMPIArray **ret_arr)
{
CMPIStatus s;
+ CMPIArray *tmp_arr;
int i;
int c;
c = CMGetArrayCount(arr, &s);
if (s.rc != CMPI_RC_OK)
return s;
+
+ tmp_arr = CMNewArray(_BROKER,
+ c,
+ CMPI_instance,
+ &s);
for (i = 0; i < c; i++) {
CMPIData d;
@@ -1079,13 +1030,16 @@ static CMPIStatus rasd_refs_to_insts(con
inst = get_rasd_instance(ctx, reference, _BROKER, id, type);
if (inst != NULL)
- inst_list_add(list, inst);
+ CMSetArrayElementAt(tmp_arr, i,
+ &inst,
+ CMPI_instance);
else
CU_DEBUG("Failed to get instance for `%s'",
REF2STR(ref));
}
CMSetStatus(&s, CMPI_RC_OK);
+ *ret_arr = tmp_arr;
return s;
}
@@ -1122,10 +1076,8 @@ static CMPIStatus rm_resource_settings(C
*/
CMPIArray *arr;
+ CMPIArray *resource_arr;
CMPIStatus s;
- struct inst_list list;
-
- inst_list_init(&list);
if (cu_get_array_arg(argsin, "ResourceSettings", &arr) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
@@ -1134,23 +1086,21 @@ static CMPIStatus rm_resource_settings(C
goto out;
}
- s = rasd_refs_to_insts(context, reference, arr, &list);
+ s = rasd_refs_to_insts(context, reference, arr, &resource_arr);
if (s.rc != CMPI_RC_OK)
goto out;
- s = _update_resource_settings(reference, &list, resource_del);
- out:
- inst_list_free(&list);
-
+ s = _update_resource_settings(reference, resource_arr, resource_del);
+ out:
return s;
}
static struct method_handler DefineSystem = {
.name = "DefineSystem",
.handler = define_system,
- .args = {{"SystemSettings", CMPI_string},
- {"ResourceSettings", CMPI_stringA},
- {"ReferencedConfiguration", CMPI_string},
+ .args = {{"SystemSettings", CMPI_instance},
+ {"ResourceSettings", CMPI_instanceA},
+ {"ReferenceConfiguration", CMPI_string},
ARG_END
}
};
@@ -1167,7 +1117,7 @@ static struct method_handler AddResource
.name = "AddResourceSettings",
.handler = add_resource_settings,
.args = {{"AffectedConfiguration", CMPI_ref},
- {"ResourceSettings", CMPI_stringA},
+ {"ResourceSettings", CMPI_instanceA},
ARG_END
}
};
@@ -1175,7 +1125,7 @@ static struct method_handler ModifyResou
static struct method_handler ModifyResourceSettings = {
.name = "ModifyResourceSettings",
.handler = mod_resource_settings,
- .args = {{"ResourceSettings", CMPI_stringA},
+ .args = {{"ResourceSettings", CMPI_instanceA},
ARG_END
}
};
@@ -1183,7 +1133,7 @@ static struct method_handler ModifySyste
static struct method_handler ModifySystemSettings = {
.name = "ModifySystemSettings",
.handler = mod_system_settings,
- .args = {{"SystemSettings", CMPI_string},
+ .args = {{"SystemSettings", CMPI_instance},
ARG_END
}
};
16 years, 9 months
[PATCH] (2) Remove the embedded object parsing pieces from VirtualSystemManagmentService
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1201801531 28800
# Node ID e27208a0ac3f69df3f704ecd32fdfdc78b79dc7c
# Parent b8d69e734306e618b4efb53e23c17ffdd8bab128
(2) Remove the embedded object parsing pieces from VirtualSystemManagmentService.
Updates from set 1 to set 2:
Removed unsused sys_op from define_system()
Removed unused list from update_resource_setting()
Changed CMPIArray **out_arr to **ret_arr in rasd_refs_to_insts()
Changed ReferencedConfiguration to ReferenceConfiguration in the definesystem handler.
Remove embedded object parsing since libcmpiutil now handles this. Also update the method handlers to expect instances instead of strings as arguments.
The following methods have been updated:
DefineSystem
AddResourceSettings
ModifyResourceSettings
ModifySystemSettings
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r b8d69e734306 -r e27208a0ac3f src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Wed Jan 30 09:27:27 2008 -0800
+++ b/src/Virt_VirtualSystemManagementService.c Thu Jan 31 09:45:31 2008 -0800
@@ -57,69 +57,23 @@ enum ResourceAction {
RESOURCE_MOD,
};
-static int parse_str_inst_array(CMPIArray *array,
- const char *ns,
- struct inst_list *list)
-{
- int count;
- int i;
-
- count = CMGetArrayCount(array, NULL);
-
- for (i = 0; i < count; i++) {
- CMPIInstance *inst;
- CMPIData item;
- int ret;
-
- item = CMGetArrayElementAt(array, i, NULL);
- /* FIXME: Check for string here */
-
- ret = cu_parse_embedded_instance(CMGetCharPtr(item.value.string),
- _BROKER,
- ns,
- &inst);
-
- if (ret == 0)
- inst_list_add(list, inst);
- }
-
- return 1;
-}
-
static CMPIStatus define_system_parse_args(const CMPIArgs *argsin,
CMPIInstance **sys,
const char *ns,
- struct inst_list *res)
+ CMPIArray **res)
{
CMPIStatus s = {CMPI_RC_ERR_FAILED, NULL};
- const char *sys_str = NULL;
- CMPIArray *res_arr;
- int ret;
-
- if (cu_get_str_arg(argsin, "SystemSettings", &sys_str) != CMPI_RC_OK) {
+
+ if (cu_get_inst_arg(argsin, "SystemSettings", sys) != CMPI_RC_OK) {
CU_DEBUG("No SystemSettings string argument");
goto out;
}
- ret = cu_parse_embedded_instance(sys_str,
- _BROKER,
- ns,
- sys);
- if (ret) {
- CU_DEBUG("Unable to parse SystemSettings instance");
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "SystemSettings parse error");
- goto out;
- }
-
- if (cu_get_array_arg(argsin, "ResourceSettings", &res_arr) !=
+ if (cu_get_array_arg(argsin, "ResourceSettings", res) !=
CMPI_RC_OK) {
CU_DEBUG("Failed to get array arg");
goto out;
}
-
- ret = parse_str_inst_array(res_arr, ns, res);
CMSetStatus(&s, CMPI_RC_OK);
@@ -317,24 +271,34 @@ static int rasd_to_vdev(CMPIInstance *in
return 0;
}
-static int classify_resources(struct inst_list *all,
+static int classify_resources(CMPIArray *resources,
struct domain *domain)
{
int i;
uint16_t type;
+ int count;
domain->dev_disk_ct = domain->dev_net_ct = 0;
domain->dev_vcpu_ct = domain->dev_mem_ct = 0;
-
- domain->dev_disk = calloc(all->cur, sizeof(struct virt_device));
- domain->dev_vcpu = calloc(all->cur, sizeof(struct virt_device));
- domain->dev_mem = calloc(all->cur, sizeof(struct virt_device));
- domain->dev_net = calloc(all->cur, sizeof(struct virt_device));
-
- for (i = 0; i < all->cur; i++) {
+
+ count = CMGetArrayCount(resources, NULL);
+ if (count < 1)
+ return 0;
+
+ domain->dev_disk = calloc(count, sizeof(struct virt_device));
+ domain->dev_vcpu = calloc(count, sizeof(struct virt_device));
+ domain->dev_mem = calloc(count, sizeof(struct virt_device));
+ domain->dev_net = calloc(count, sizeof(struct virt_device));
+
+ for (i = 0; i < count; i++) {
CMPIObjectPath *op;
-
- op = CMGetObjectPath(all->list[i], NULL);
+ CMPIData item;
+
+ item = CMGetArrayElementAt(resources, i, NULL);
+ if (CMIsNullObject(item.value.inst))
+ return 0;
+
+ op = CMGetObjectPath(item.value.inst, NULL);
if (op == NULL)
return 0;
@@ -343,16 +307,16 @@ static int classify_resources(struct ins
return 0;
if (type == CIM_RASD_TYPE_PROC)
- rasd_to_vdev(all->list[i],
+ rasd_to_vdev(item.value.inst,
&domain->dev_vcpu[domain->dev_vcpu_ct++]);
else if (type == CIM_RASD_TYPE_MEM)
- rasd_to_vdev(all->list[i],
+ rasd_to_vdev(item.value.inst,
&domain->dev_mem[domain->dev_mem_ct++]);
else if (type == CIM_RASD_TYPE_DISK)
- rasd_to_vdev(all->list[i],
+ rasd_to_vdev(item.value.inst,
&domain->dev_disk[domain->dev_disk_ct++]);
else if (type == CIM_RASD_TYPE_NET)
- rasd_to_vdev(all->list[i],
+ rasd_to_vdev(item.value.inst,
&domain->dev_net[domain->dev_net_ct++]);
}
@@ -398,7 +362,7 @@ static CMPIInstance *connect_and_create(
}
static CMPIInstance *create_system(CMPIInstance *vssd,
- struct inst_list *resources,
+ CMPIArray *resources,
const CMPIObjectPath *ref,
CMPIStatus *s)
{
@@ -466,11 +430,8 @@ static CMPIStatus define_system(CMPIMeth
{
CMPIInstance *vssd;
CMPIInstance *sys;
- CMPIObjectPath *sys_op;
- struct inst_list res;
+ CMPIArray *res;
CMPIStatus s;
-
- inst_list_init(&res);
CU_DEBUG("DefineSystem");
@@ -478,15 +439,12 @@ static CMPIStatus define_system(CMPIMeth
if (s.rc != CMPI_RC_OK)
goto out;
- sys = create_system(vssd, &res, reference, &s);
+ sys = create_system(vssd, res, reference, &s);
if (sys == NULL)
goto out;
- inst_list_free(&res);
-
CMAddArg(argsout, "ResultingSystem", &sys, CMPI_instance);
- sys_op = CMGetObjectPath(sys, NULL);
trigger_indication(context,
"ComputerSystemCreatedIndication",
NAMESPACE(reference));
@@ -623,27 +581,14 @@ static CMPIStatus mod_system_settings(CM
const CMPIArgs *argsin,
CMPIArgs *argsout)
{
- const char *inst_str;
CMPIInstance *inst;
- if (cu_get_str_arg(argsin, "SystemSettings", &inst_str) != CMPI_RC_OK) {
+ if (cu_get_inst_arg(argsin, "SystemSettings", &inst) != CMPI_RC_OK) {
CMPIStatus s;
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
"Missing SystemSettings");
- return s;
- }
-
- if (cu_parse_embedded_instance(inst_str,
- _BROKER,
- NAMESPACE(reference),
- &inst)) {
- CMPIStatus s;
-
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Internal Parse Error on SystemSettings");
return s;
}
@@ -953,23 +898,30 @@ static CMPIStatus _update_resources_for(
}
static CMPIStatus _update_resource_settings(const CMPIObjectPath *ref,
- struct inst_list *list,
+ CMPIArray *resources,
resmod_fn func)
{
int i;
virConnectPtr conn = NULL;
CMPIStatus s;
+ int count;
conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
if (conn == NULL)
goto out;
- for (i = 0; i < list->cur; i++) {
- CMPIInstance *inst = list->list[i];
+ count = CMGetArrayCount(resources, NULL);
+
+ for (i = 0; i < count; i++) {
+ CMPIData item;
+ CMPIInstance *inst;
const char *id = NULL;
char *name = NULL;
char *devid = NULL;
virDomainPtr dom = NULL;
+
+ item = CMGetArrayElementAt(resources, i, NULL);
+ inst = item.value.inst;
if (cu_get_str_prop(inst, "InstanceID", &id) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
@@ -1016,9 +968,6 @@ static CMPIStatus update_resource_settin
{
CMPIArray *arr;
CMPIStatus s;
- struct inst_list list;
-
- inst_list_init(&list);
if (cu_get_array_arg(argsin, "ResourceSettings", &arr) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
@@ -1027,20 +976,16 @@ static CMPIStatus update_resource_settin
goto out;
}
- parse_str_inst_array(arr, NAMESPACE(ref), &list);
-
- s = _update_resource_settings(ref, &list, func);
-
- out:
- inst_list_free(&list);
-
+ s = _update_resource_settings(ref, arr, func);
+
+ out:
return s;
}
static CMPIStatus rasd_refs_to_insts(const CMPIContext *ctx,
const CMPIObjectPath *reference,
CMPIArray *arr,
- struct inst_list *list)
+ CMPIArray **ret_arr)
{
CMPIStatus s;
int i;
@@ -1049,6 +994,11 @@ static CMPIStatus rasd_refs_to_insts(con
c = CMGetArrayCount(arr, &s);
if (s.rc != CMPI_RC_OK)
return s;
+
+ *ret_arr = CMNewArray(_BROKER,
+ c,
+ CMPI_instance,
+ &s);
for (i = 0; i < c; i++) {
CMPIData d;
@@ -1079,7 +1029,9 @@ static CMPIStatus rasd_refs_to_insts(con
inst = get_rasd_instance(ctx, reference, _BROKER, id, type);
if (inst != NULL)
- inst_list_add(list, inst);
+ CMSetArrayElementAt(*ret_arr, i,
+ &inst,
+ CMPI_instance);
else
CU_DEBUG("Failed to get instance for `%s'",
REF2STR(ref));
@@ -1122,10 +1074,8 @@ static CMPIStatus rm_resource_settings(C
*/
CMPIArray *arr;
+ CMPIArray *resource_arr;
CMPIStatus s;
- struct inst_list list;
-
- inst_list_init(&list);
if (cu_get_array_arg(argsin, "ResourceSettings", &arr) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
@@ -1134,23 +1084,21 @@ static CMPIStatus rm_resource_settings(C
goto out;
}
- s = rasd_refs_to_insts(context, reference, arr, &list);
+ s = rasd_refs_to_insts(context, reference, arr, &resource_arr);
if (s.rc != CMPI_RC_OK)
goto out;
- s = _update_resource_settings(reference, &list, resource_del);
- out:
- inst_list_free(&list);
-
+ s = _update_resource_settings(reference, resource_arr, resource_del);
+ out:
return s;
}
static struct method_handler DefineSystem = {
.name = "DefineSystem",
.handler = define_system,
- .args = {{"SystemSettings", CMPI_string},
- {"ResourceSettings", CMPI_stringA},
- {"ReferencedConfiguration", CMPI_string},
+ .args = {{"SystemSettings", CMPI_instance},
+ {"ResourceSettings", CMPI_instanceA},
+ {"ReferenceConfiguration", CMPI_string},
ARG_END
}
};
@@ -1167,7 +1115,7 @@ static struct method_handler AddResource
.name = "AddResourceSettings",
.handler = add_resource_settings,
.args = {{"AffectedConfiguration", CMPI_ref},
- {"ResourceSettings", CMPI_stringA},
+ {"ResourceSettings", CMPI_instanceA},
ARG_END
}
};
@@ -1175,7 +1123,7 @@ static struct method_handler ModifyResou
static struct method_handler ModifyResourceSettings = {
.name = "ModifyResourceSettings",
.handler = mod_resource_settings,
- .args = {{"ResourceSettings", CMPI_stringA},
+ .args = {{"ResourceSettings", CMPI_instanceA},
ARG_END
}
};
@@ -1183,7 +1131,7 @@ static struct method_handler ModifySyste
static struct method_handler ModifySystemSettings = {
.name = "ModifySystemSettings",
.handler = mod_system_settings,
- .args = {{"SystemSettings", CMPI_string},
+ .args = {{"SystemSettings", CMPI_instance},
ARG_END
}
};
16 years, 9 months
[PATCH] Set additional attribute values in Virt_ComputerSystem.c
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1201904890 28800
# Node ID 3b1671a993401889101969b3f5e3a25e45d13400
# Parent 19bd4c5ede1512bcd411a98b3c09acebc506b38e
Set additional attribute values in Virt_ComputerSystem.c
OtherIdentifyingInfo property and IdentifyingDescriptions. Modify instance_from_dom() to take a prefix parameter.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 19bd4c5ede15 -r 3b1671a99340 src/Virt_ComputerSystem.c
--- a/src/Virt_ComputerSystem.c Fri Feb 01 10:55:58 2008 -0800
+++ b/src/Virt_ComputerSystem.c Fri Feb 01 14:28:10 2008 -0800
@@ -71,7 +71,9 @@ static int set_name_from_dom(virDomainPt
}
/* Set the "UUID" property of an instance from a domain */
-static int set_uuid_from_dom(virDomainPtr dom, CMPIInstance *instance)
+static int set_uuid_from_dom(virDomainPtr dom,
+ CMPIInstance *instance,
+ char **out_uuid)
{
char uuid[VIR_UUID_STRING_BUFLEN];
int ret;
@@ -82,6 +84,8 @@ static int set_uuid_from_dom(virDomainPt
CMSetProperty(instance, "UUID",
(CMPIValue *)uuid, CMPI_chars);
+
+ *out_uuid = strdup(uuid);
return 1;
}
@@ -239,17 +243,91 @@ static int set_creation_class(CMPIInstan
return 1;
}
+static int set_other_id_info(const CMPIBroker *broker,
+ char *uuid,
+ const char *prefix,
+ CMPIInstance *instance)
+{
+ CMPIStatus s;
+ CMPIArray *id_info;
+ char *info[3];
+ int count = 3;
+ char *type = "Virtual System";
+ char *model;
+ int i;
+
+ id_info = CMNewArray(broker,
+ count,
+ CMPI_string,
+ &s);
+
+ if (s.rc != CMPI_RC_OK)
+ return 0;
+
+ if (asprintf(&model, "%s%s", prefix, type) == 1)
+ return 0;
+
+ info[0] = uuid;
+ info[1] = model;
+ info[2] = type;
+
+ for (i = 0; i < count; i++) {
+ CMPIString *tmp = CMNewString(broker, info[i], NULL);
+ CMSetArrayElementAt(id_info, i,
+ &tmp,
+ CMPI_string);
+ }
+
+ CMSetProperty(instance, "OtherIdentifyingInfo",
+ &id_info, CMPI_stringA);
+
+ return 1;
+}
+
+static int set_id_desc(const CMPIBroker *broker,
+ CMPIInstance *instance)
+{
+ CMPIStatus s;
+ CMPIArray *id_desc;
+ char *desc[3] = {"Type", "Model", "UUID"};
+ int count = 3;
+ int i;
+
+ id_desc = CMNewArray(broker,
+ count,
+ CMPI_string,
+ &s);
+
+ if (s.rc != CMPI_RC_OK)
+ return 0;
+
+ for (i = 0; i < count; i++) {
+ CMPIString *tmp = CMNewString(broker, desc[i], NULL);
+ CMSetArrayElementAt(id_desc, i,
+ &tmp,
+ CMPI_string);
+ }
+
+ CMSetProperty(instance, "IdentifyingDescriptions",
+ (CMPIValue *)&id_desc, CMPI_stringA);
+
+ return 1;
+}
+
/* Populate an instance with information from a domain */
static int instance_from_dom(const CMPIBroker *broker,
virDomainPtr dom,
+ const char *prefix,
CMPIInstance *instance)
{
+ char *uuid;
+
if (!set_name_from_dom(dom, instance)) {
/* Print trace error */
return 0;
}
- if (!set_uuid_from_dom(dom, instance)) {
+ if (!set_uuid_from_dom(dom, instance, &uuid)) {
/* Print trace error */
return 0;
}
@@ -269,7 +347,20 @@ static int instance_from_dom(const CMPIB
return 0;
}
+ if (!set_other_id_info(broker, uuid, prefix, instance)) {
+ /* Print trace error */
+ free(uuid);
+ return 0;
+ }
+
+ if (!set_id_desc(broker, instance)) {
+ /* Print trace error */
+ return 0;
+ }
+
/* More attributes here, of course */
+
+ free(uuid);
return 1;
}
@@ -294,7 +385,10 @@ CMPIInstance *instance_from_name(const C
if (instance == NULL)
goto out;
- if (!instance_from_dom(broker, dom, instance))
+ if (!instance_from_dom(broker,
+ dom,
+ pfx_from_conn(conn),
+ instance))
instance = NULL;
out:
@@ -327,7 +421,10 @@ int enum_domains(const CMPIBroker *broke
if (inst == NULL)
goto end;
- if (instance_from_dom(broker, list[i], inst))
+ if (instance_from_dom(broker,
+ list[i],
+ pfx_from_conn(conn),
+ inst))
inst_list_add(instlist, inst);
end:
16 years, 9 months
[PATCH] RPCS: enumerateInstance(Name)s and getInstance with wrong hypervisor segfaults
by Heidi Eckhart
# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1201864846 -3600
# Node ID 6b1bf8231d82f51f25ac3d954b63962bfc7484c9
# Parent cb0e8b858f4243a7086f627d65a07075b9f31ebc
RPCS: enumerateInstance(Name)s and getInstance with wrong hypervisor segfaults
wbemein http://localhost/root/virt:CIM_ResourcePoolConfigurationService
on a KVM system with no Xen segfaults.
The same happens to
wbemgi 'http://localhost:5988/root/virt:Xen_ResourcePoolConfigurationService.Syst..."Xen_HostSystem",SystemName="localhost.localdomain",CreationClassName="Xen_ResourcePoolConfigurationService",Name="RPCS"'
This patch also makes RPCS aware of the supported hypervisor type. Now only
instances of the machine's supported hypervisor are returned. This approach
is used all over the libvirt-cim providers, but was broken here.
Signed-off-by: Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
diff -r cb0e8b858f42 -r 6b1bf8231d82 src/Virt_ResourcePoolConfigurationService.c
--- a/src/Virt_ResourcePoolConfigurationService.c Fri Feb 01 11:17:15 2008 +0100
+++ b/src/Virt_ResourcePoolConfigurationService.c Fri Feb 01 12:20:46 2008 +0100
@@ -100,15 +100,20 @@ CMPIStatus rpcs_instance(const CMPIObjec
{
CMPIInstance *inst;
CMPIInstance *host;
- CMPIStatus s;
+ CMPIStatus s = {CMPI_RC_OK, NULL};
CMPIData prop;
+ virConnectPtr conn = NULL;
+
+ conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s);
+ if (conn == NULL)
+ goto out;
s = get_host_cs(broker, reference, &host);
if (s.rc != CMPI_RC_OK)
goto out;
inst = get_typed_instance(broker,
- CLASSNAME(reference),
+ pfx_from_conn(conn),
"ResourcePoolConfigurationService",
NAMESPACE(reference));
if (inst == NULL) {
@@ -145,7 +150,10 @@ CMPIStatus rpcs_instance(const CMPIObjec
(CMPIValue *)&prop.value.string, CMPI_string);
*_inst = inst;
+
out:
+ virConnectClose(conn);
+
return s;
}
@@ -155,13 +163,17 @@ static CMPIStatus GetInstance(CMPIInstan
const CMPIObjectPath *reference,
const char **properties)
{
- CMPIInstance *inst;
+ CMPIInstance *inst = NULL;
CMPIStatus s;
const char *prop = NULL;
s = rpcs_instance(reference, &inst, _BROKER);
- if (s.rc != CMPI_RC_OK)
+ if (s.rc != CMPI_RC_OK || inst == NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "No such instance");
return s;
+ }
prop = cu_compare_ref(reference, inst);
if (prop != NULL) {
@@ -180,11 +192,11 @@ static CMPIStatus EnumInstanceNames(CMPI
const CMPIResult *results,
const CMPIObjectPath *reference)
{
- CMPIInstance *inst;
- CMPIStatus s;
-
- s = rpcs_instance(reference, &inst, _BROKER);
- if (s.rc == CMPI_RC_OK)
+ CMPIInstance *inst = NULL;
+ CMPIStatus s;
+
+ s = rpcs_instance(reference, &inst, _BROKER);
+ if (s.rc == CMPI_RC_OK && inst != NULL)
cu_return_instance_name(results, inst);
return s;
@@ -197,11 +209,11 @@ static CMPIStatus EnumInstances(CMPIInst
const char **properties)
{
- CMPIInstance *inst;
- CMPIStatus s;
-
- s = rpcs_instance(reference, &inst, _BROKER);
- if (s.rc == CMPI_RC_OK)
+ CMPIInstance *inst = NULL;
+ CMPIStatus s;
+
+ s = rpcs_instance(reference, &inst, _BROKER);
+ if (s.rc == CMPI_RC_OK && inst != NULL)
CMReturnInstance(results, inst);
return s;
16 years, 9 months
Guo Lian Yun is out of the office.
by Guo Lian Yun
I will be out of the office starting 2008-02-03 and will not return until
2008-02-15.
I will respond to your message when I return.
16 years, 9 months
[PATCH] Fix Virt_Device crash due to improper virConnectClose()
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1201894237 28800
# Node ID 5d554b65865ebaabf5261f7e8557dd7a40bf6175
# Parent 6c3c30bf8e026c9b3609195c55766c6c3f757b99
Fix Virt_Device crash due to improper virConnectClose()
This was identified as being necessary in the first round, but it actually
breaks things. The conn here is not new, it's just the one from the current
dom pointer, which means that the first time we close it, all subsequent
devices break (or crash)
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 6c3c30bf8e02 -r 5d554b65865e src/Virt_Device.c
--- a/src/Virt_Device.c Fri Feb 01 11:17:15 2008 +0100
+++ b/src/Virt_Device.c Fri Feb 01 11:30:37 2008 -0800
@@ -224,7 +224,6 @@ static int device_set_systemname(CMPIIns
CMSetProperty(instance, "SystemCreationClassName",
(CMPIValue *)sccn, CMPI_chars);
free(sccn);
- virConnectClose(conn);
}
return 1;
16 years, 9 months