[PATCH] [CU][RFC] Correct a few API issues
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1196124861 28800
# Node ID 96b651213e50f02586988064a014bbe746dc9c59
# Parent 05f120725e3dc562dc8fa251da698faa474f0b55
[CU][RFC] Correct a few API issues
that I think need to be resolved before we snap a release.
Some of the cu_get_* functions returned values instead of a CMPIrc's
like everything else, so this changes that. Also, return const char *'s
from the broker memory so that the callers don't need to free the result.
This will require some work in libvirt-cim to make sure the new API is
adhered to properly. If this is okay with people, I'll follow up with a
patch to libvirt-cim to make those changes. Any other discussion about
things that should change in the libcmpiutil API is welcomed.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 05f120725e3d -r 96b651213e50 args_util.c
--- a/args_util.c Mon Nov 26 16:51:12 2007 -0800
+++ b/args_util.c Mon Nov 26 16:54:21 2007 -0800
@@ -32,28 +32,32 @@
#define CU_WEAK_TYPES 1
-char *cu_get_str_path(const CMPIObjectPath *reference, const char *key)
+CMPIrc cu_get_str_path(const CMPIObjectPath *ref,
+ const char *key,
+ const char **val)
{
CMPIData data;
CMPIStatus s;
const char *value;
- data = CMGetKey(reference, key, &s);
+ data = CMGetKey(ref, key, &s);
if ((s.rc != CMPI_RC_OK) ||
CMIsNullValue(data) ||
CMIsNullObject(data.value.string))
- return NULL;
+ return CMPI_RC_ERR_FAILED;
value = CMGetCharPtr(data.value.string);
if ((value == NULL) || (*value == '\0'))
- return NULL;
-
- return strdup(value);
-}
-
-int cu_get_u16_path(const CMPIObjectPath *reference,
- const char *key,
- uint16_t *target)
+ return CMPI_RC_ERR_TYPE_MISMATCH;
+
+ *val = value;
+
+ return CMPI_RC_OK;
+}
+
+CMPIrc cu_get_u16_path(const CMPIObjectPath *reference,
+ const char *key,
+ uint16_t *target)
{
CMPIData data;
CMPIStatus s;
@@ -61,11 +65,11 @@ int cu_get_u16_path(const CMPIObjectPath
data = CMGetKey(reference, key, &s);
if ((s.rc != CMPI_RC_OK) ||
CMIsNullValue(data))
- return 0;
+ return CMPI_RC_ERR_FAILED;
*target = data.value.uint16;
- return 1;
+ return CMPI_RC_OK;
}
const char *cu_check_args(const CMPIArgs *args, const char **names)
@@ -85,92 +89,101 @@ const char *cu_check_args(const CMPIArgs
return NULL;
}
-char *cu_get_str_arg(const CMPIArgs *args, const char *name)
-{
- CMPIData argdata;
- char *argval;
+CMPIrc cu_get_str_arg(const CMPIArgs *args, const char *name, const char **val)
+{
+ CMPIData argdata;
CMPIStatus s;
argdata = CMGetArg(args, name, &s);
if ((s.rc != CMPI_RC_OK) || (CMIsNullValue(argdata)))
- return NULL;
+ return CMPI_RC_ERR_INVALID_PARAMETER;
if ((argdata.type != CMPI_string) ||
CMIsNullObject(argdata.value.string))
- return NULL;
-
- argval = strdup(CMGetCharPtr(argdata.value.string));
-
- return argval;
-}
-
-CMPIObjectPath *cu_get_ref_arg(const CMPIArgs *args, const char *name)
+ return CMPI_RC_ERR_TYPE_MISMATCH;
+
+ *val = CMGetCharPtr(argdata.value.string);
+
+ return CMPI_RC_OK;
+}
+
+CMPIrc cu_get_ref_arg(const CMPIArgs *args,
+ const char *name,
+ CMPIObjectPath **op)
{
CMPIData argdata;
CMPIStatus s;
argdata = CMGetArg(args, name, &s);
if ((s.rc != CMPI_RC_OK) || (CMIsNullValue(argdata)))
- return NULL;
+ return CMPI_RC_ERR_INVALID_PARAMETER;
if ((argdata.type != CMPI_ref) || CMIsNullObject(argdata.value.ref))
- return NULL;
-
- return argdata.value.ref;
-}
-
-CMPIInstance *cu_get_inst_arg(const CMPIArgs *args, const char *name)
-{
- CMPIData argdata;
- CMPIStatus s;
-
- argdata = CMGetArg(args, name, &s);
- if ((s.rc != CMPI_RC_OK) || (CMIsNullValue(argdata))) {
- return NULL;
- }
+ return CMPI_RC_ERR_TYPE_MISMATCH;
+
+ *op = argdata.value.ref;
+
+ return CMPI_RC_OK;
+}
+
+CMPIrc cu_get_inst_arg(const CMPIArgs *args,
+ const char *name,
+ CMPIInstance **inst)
+{
+ CMPIData argdata;
+ CMPIStatus s;
+
+ argdata = CMGetArg(args, name, &s);
+ if ((s.rc != CMPI_RC_OK) || (CMIsNullValue(argdata)))
+ return CMPI_RC_ERR_INVALID_PARAMETER;
if ((argdata.type != CMPI_instance) ||
- CMIsNullObject(argdata.value.inst)) {
- return NULL;
- }
-
- return argdata.value.inst;
-}
-
-CMPIArray *cu_get_array_arg(const CMPIArgs *args, const char *name)
+ CMIsNullObject(argdata.value.inst))
+ CMPI_RC_ERR_TYPE_MISMATCH;
+
+ *inst = argdata.value.inst;
+
+ return CMPI_RC_OK;
+}
+
+CMPIrc cu_get_array_arg(const CMPIArgs *args,
+ const char *name,
+ CMPIArray **array)
{
CMPIData argdata;
CMPIStatus s;
argdata = CMGetArg(args, name, &s);
if ((s.rc != CMPI_RC_OK) || CMIsNullValue(argdata))
- return NULL;
+ return CMPI_RC_ERR_INVALID_PARAMETER;
if (!CMIsArray(argdata) || CMIsNullObject(argdata.value.array))
- return NULL;
-
- return argdata.value.array;
-}
-
-int cu_get_u16_arg(const CMPIArgs *args, const char *name, uint16_t *target)
+ return CMPI_RC_ERR_TYPE_MISMATCH;
+
+ *array = argdata.value.array;
+
+ return CMPI_RC_OK;
+}
+
+CMPIrc cu_get_u16_arg(const CMPIArgs *args, const char *name, uint16_t *target)
{
CMPIData argdata;
CMPIStatus s;
argdata = CMGetArg(args, name, &s);
if ((s.rc != CMPI_RC_OK) || CMIsNullValue(argdata))
- return 0;
+ return CMPI_RC_ERR_INVALID_PARAMETER;
#ifdef CU_WEAK_TYPES
if (!(argdata.type & CMPI_INTEGER))
#else
if (argdata.type != CMPI_uint16)
#endif
- return 0;
+ return CMPI_RC_ERR_TYPE_MISMATCH;
*target = argdata.value.uint16;
- return 1;
+ return CMPI_RC_OK;
}
#define REQUIRE_PROPERTY_DEFINED(i, p, pv, s) \
diff -r 05f120725e3d -r 96b651213e50 libcmpiutil.h
--- a/libcmpiutil.h Mon Nov 26 16:51:12 2007 -0800
+++ b/libcmpiutil.h Mon Nov 26 16:54:21 2007 -0800
@@ -91,18 +91,22 @@ const char *cu_check_args(const CMPIArgs
*
* @param args The argument list to search
* @param name The name of the argument
- * @returns The string argument's value, or NULL if error (must be free()'d)
- */
-char *cu_get_str_arg(const CMPIArgs *args, const char *name);
+ * @param val The value of the argument (must be free()'d)
+ * @returns CMPI_RC_OK if successful
+ */
+CMPIrc cu_get_str_arg(const CMPIArgs *args, const char *name, const char **val);
/**
* Get a reference argument
*
* @param args The argument list to search
* @param name The name of the argument
- * @returns The reference argument's value, or NULL if error
- */
-CMPIObjectPath *cu_get_ref_arg(const CMPIArgs *args, const char *name);
+ * @param op The reference argument's value
+ * @returns CMPI_RC_OK if successful
+ */
+CMPIrc cu_get_ref_arg(const CMPIArgs *args,
+ const char *name,
+ CMPIObjectPath **op);
/**
* Get an instance argument
@@ -111,7 +115,9 @@ CMPIObjectPath *cu_get_ref_arg(const CMP
* @param name The name of the argument
* @returns The instance argument's value, or NULL if error
*/
-CMPIInstance *cu_get_inst_arg(const CMPIArgs *args, const char *name);
+CMPIrc cu_get_inst_arg(const CMPIArgs *args,
+ const char *name,
+ CMPIInstance **inst);
/**
* Get an array argument
@@ -120,7 +126,9 @@ CMPIInstance *cu_get_inst_arg(const CMPI
* @param name The name of the argument
* @returns The array argument's value, or NULL if error
*/
-CMPIArray *cu_get_array_arg(const CMPIArgs *args, const char *name);
+CMPIrc cu_get_array_arg(const CMPIArgs *args,
+ const char *name,
+ CMPIArray **array);
/**
* Get a uint16 argument
@@ -128,18 +136,22 @@ CMPIArray *cu_get_array_arg(const CMPIAr
* @param args The argument list to search
* @param name The name of the argument
* @param target The uint16_t to reflect the argument value
- * @returns nonzero on success, zero otherwise
- */
-int cu_get_u16_arg(const CMPIArgs *args, const char *name, uint16_t *target);
+ * @returns CMPI_RC_OK if successful
+ */
+CMPIrc cu_get_u16_arg(const CMPIArgs *args, const char *name, uint16_t *target);
/**
* Get a string component of an object path
*
- * @param reference The object path
+ * @param ref The object path
* @param key The name of the component to return
- * @returns The value of the component, or NULL if error (must be free()'d)
- */
-char *cu_get_str_path(const CMPIObjectPath *reference, const char *key);
+ * @param val The value of the component, or NULL if error (must be
+ * free()'d)
+ * @returns CMPI_RC_OK on success
+ */
+CMPIrc cu_get_str_path(const CMPIObjectPath *ref,
+ const char *key,
+ const char **val);
/**
* Get a uint16 component of an object path
@@ -147,11 +159,11 @@ char *cu_get_str_path(const CMPIObjectPa
* @param reference The object path
* @param key The name of the component to return
* @param target A pointer to the uint16 to set
- * @returns nonzero on success, zero otherwise
- */
-int cu_get_u16_path(const CMPIObjectPath *reference,
- const char *key,
- uint16_t *target);
+ * @returns CMPI_RC_OK if successful
+ */
+CMPIrc cu_get_u16_path(const CMPIObjectPath *reference,
+ const char *key,
+ uint16_t *target);
/* Forward declaration */
struct inst_list;
diff -r 05f120725e3d -r 96b651213e50 std_indication.c
--- a/std_indication.c Mon Nov 26 16:51:12 2007 -0800
+++ b/std_indication.c Mon Nov 26 16:54:21 2007 -0800
@@ -49,7 +49,8 @@ static CMPIStatus raise(struct std_indic
if (ctx->handler->raise_fn == NULL)
return (CMPIStatus){CMPI_RC_OK, NULL};
- inst = cu_get_inst_arg(argsin, "Indication");
+ if (cu_get_inst_arg(argsin, "Indication", &inst) != CMPI_RC_OK)
+ return (CMPIStatus){CMPI_RC_ERR_FAILED, NULL};
return ctx->handler->raise_fn(context, inst);
}
16 years, 11 months
[PATCH] Enhance handling of input parameter of std_association logic
by Heidi Eckhart
# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1195821409 -3600
# Node ID 07ab148e7311656c997bcc8f5ad6249fdc7b42bc
# Parent db20c6206fb6decb484035bec81d7c7f2be75eae
Enhance handling of input parameter of std_association logic
Signed-off-by: Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
diff -r db20c6206fb6 -r 07ab148e7311 std_association.c
--- a/std_association.c Fri Nov 23 13:02:51 2007 +0100
+++ b/std_association.c Fri Nov 23 13:36:49 2007 +0100
@@ -67,14 +67,17 @@ static bool match_class(const CMPIBroker
char *comp_class;
int i;
- rop = CMNewObjectPath(broker, ns, test_class, NULL);
+ if (test_class == NULL)
+ return true;
+
+ if (comp_class_list == NULL)
+ return true;
for (i = 0; comp_class_list[i]; i++) {
comp_class = comp_class_list[i];
-
- if ((test_class == NULL) ||
- (comp_class == NULL) ||
- match_op(broker, rop, comp_class))
+ rop = CMNewObjectPath(broker, ns,comp_class , NULL);
+
+ if (match_op(broker, rop, test_class))
return true;
}
@@ -117,11 +120,16 @@ out:
static struct std_assoc *
std_assoc_get_handler(const struct std_assoc_ctx *ctx,
+ struct std_assoc_info *info,
const CMPIObjectPath *ref)
{
struct std_assoc *hdl = NULL;
char *source_class;
int i, j;
+ bool rc;
+
+ CU_DEBUG("Calling Provider: '%s'",
+ info->provider_name);
for (i = 0; ctx->handlers[i]; i++) {
hdl = ctx->handlers[i];
@@ -141,9 +149,66 @@ std_assoc_get_handler(const struct std_a
break;
}
- if (hdl)
+ if (hdl) {
+ if (info->assoc_class) {
+ CU_DEBUG("Check client's assocClass: '%s'",
+ info->assoc_class);
+
+ rc = match_class(ctx->brkr,
+ NAMESPACE(ref),
+ info->assoc_class,
+ hdl->assoc_class);
+
+ if (!rc) {
+ CU_DEBUG("AssocClass not valid.");
+ goto out;
+ }
+ CU_DEBUG("AssocClass valid.");
+ }
+
+ if (info->result_class) {
+ CU_DEBUG("Check client's resultClass: '%s'",
+ info->result_class);
+
+ rc = match_class(ctx->brkr,
+ NAMESPACE(ref),
+ info->result_class,
+ hdl->target_class);
+
+ if (!rc) {
+ CU_DEBUG("ResultClass not valid.");
+ goto out;
+ }
+ CU_DEBUG("ResultClass valid.");
+ }
+
+ if (info->role) {
+ CU_DEBUG("Check client's role: '%s'",
+ info->role);
+
+ if (!STREQC(info->role, hdl->source_prop)) {
+ CU_DEBUG("Role not valid.");
+ goto out;
+ }
+ CU_DEBUG("Role valid.");
+ }
+
+
+ if (info->result_role) {
+ CU_DEBUG("Check client's resultRole: '%s'",
+ info->result_role);
+
+ if (!STREQC(info->result_role, hdl->target_prop)) {
+ CU_DEBUG("ResultRole not valid.");
+ goto out;
+ }
+ CU_DEBUG("ResultRole valid.");
+ }
+
return hdl;
-
+ }
+
+ out:
return NULL;
}
@@ -153,57 +218,21 @@ static CMPIStatus do_assoc(struct std_as
const CMPIObjectPath *ref,
bool names_only)
{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
struct inst_list list;
- CMPIStatus s;
struct std_assoc *handler;
- bool rc;
inst_list_init(&list);
CU_DEBUG("Getting handler...");
-
- handler = std_assoc_get_handler(ctx, ref);
+ handler = std_assoc_get_handler(ctx, info, ref);
if (handler == NULL) {
CU_DEBUG("No handler found.");
goto out;
}
-
- CU_DEBUG("OK.\n\tsource: '%s'\n\ttarget: '%s'\n\tassoc_class: '%s'",
- handler->source_class,
- handler->target_class,
- handler->assoc_class);
- CU_DEBUG("Calling match_class: \n\tinfo->result_class: '%s'",
- info->result_class);
-
- rc = match_class(ctx->brkr,
- NAMESPACE(ref),
- info->result_class,
- handler->target_class);
- if (!rc) {
- CU_DEBUG("Match_class failed.");
- cu_statusf(ctx->brkr, &s,
- CMPI_RC_ERR_FAILED,
- "Result class is not valid for this association");
- goto out;
- }
- CU_DEBUG("Match_class succeeded.");
-
- CU_DEBUG("Calling match_class: \n\tinfo->assoc_class: '%s'",
- info->assoc_class);
- rc = match_class(ctx->brkr,
- NAMESPACE(ref),
- info->assoc_class,
- handler->assoc_class);
- if (!rc) {
- CU_DEBUG("Match_class failed.");
- cu_statusf(ctx->brkr, &s,
- CMPI_RC_ERR_FAILED,
- "Association class given is not valid for"
- "this association");
- goto out;
- }
- CU_DEBUG("Match_class succeeded, calling handler->handler...");
-
+ CU_DEBUG("Getting handler succeeded.");
+
+ CU_DEBUG("Calling handler->handler...");
s = handler->handler(ref, info, &list);
if (s.rc != CMPI_RC_OK) {
@@ -251,32 +280,22 @@ static CMPIStatus do_ref(struct std_asso
const CMPIObjectPath *ref,
bool names_only)
{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
struct inst_list list;
- CMPIStatus s;
+ struct std_assoc *handler;
int i;
- struct std_assoc *handler;
- bool rc;
inst_list_init(&list);
- handler = std_assoc_get_handler(ctx, ref);
+ CU_DEBUG("Getting handler...");
+ handler = std_assoc_get_handler(ctx, info, ref);
if (handler == NULL) {
CU_DEBUG("No handler found.");
goto out;
}
-
- rc = match_class(ctx->brkr,
- NAMESPACE(ref),
- info->result_class,
- handler->assoc_class);
- if (!rc) {
- cu_statusf(ctx->brkr, &s,
- CMPI_RC_ERR_FAILED,
- "Result class is not valid for this association");
- goto out;
- }
-
-
+ CU_DEBUG("Getting handler succeeded.");
+
+ CU_DEBUG("Calling handler->handler...");
s = handler->handler(ref, info, &list);
if ((s.rc != CMPI_RC_OK) || (list.list == NULL))
goto out;
16 years, 11 months
[PATCH] Enumeration on HostSystem class is returning dups
by Heidi Eckhart
# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1195733309 -3600
# Node ID 8c0410bfe3d3da3ef61aa40bfe75f1f23426b77d
# Parent 278c59f67cb1fe0520e8dfa7b118cd907e8f10a1
Enumeration on HostSystem class is returning dups
On systems where only one hypervisor is existing, the provider
returned instance for all known subclasses (Xen, KVM).
Signed-off-by: Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
diff -r 278c59f67cb1 -r 8c0410bfe3d3 src/Virt_HostSystem.c
--- a/src/Virt_HostSystem.c Tue Nov 20 16:26:00 2007 -0500
+++ b/src/Virt_HostSystem.c Thu Nov 22 13:08:29 2007 +0100
@@ -36,20 +36,24 @@
const static CMPIBroker *_BROKER;
-static int set_host_system_properties(CMPIInstance *instance,
- const char *classname)
+static int set_host_system_properties(CMPIInstance *instance)
{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ CMPIObjectPath *op;
char hostname[256] = {0};
- CMSetProperty(instance, "CreationClassName",
- (CMPIValue *)classname, CMPI_chars);
+ op = CMGetObjectPath(instance, &s);
+ if ((s.rc == CMPI_RC_OK) || !CMIsNullObject(op)) {
+ CMSetProperty(instance, "CreationClassName",
+ (CMPIValue *)CLASSNAME(op), CMPI_chars);
+ }
if (gethostname(hostname, sizeof(hostname) - 1) != 0)
strcpy(hostname, "unknown");
CMSetProperty(instance, "Name",
(CMPIValue *)hostname, CMPI_chars);
-
+
return 1;
}
@@ -57,44 +61,32 @@ CMPIStatus get_host_cs(const CMPIBroker
const CMPIObjectPath *reference,
CMPIInstance **instance)
{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
CMPIInstance *inst = NULL;
- CMPIObjectPath *op;
- CMPIStatus s;
- char *ns;
- char *classname;
+ virConnectPtr conn = NULL;
- ns = NAMESPACE(reference);
+ conn = connect_by_classname(broker, CLASSNAME(reference), &s);
+ if (conn == NULL)
+ goto out;
- classname = get_typed_class(CLASSNAME(reference), "HostSystem");
- if (classname == NULL) {
- CMSetStatusWithChars(broker, &s,
+ inst = get_typed_instance(broker,
+ pfx_from_conn(conn),
+ "HostSystem",
+ NAMESPACE(reference));
+
+ if (inst == NULL) {
+ CMSetStatusWithChars(broker, &s,
CMPI_RC_ERR_FAILED,
- "Invalid class");
- goto out;
+ "Can't create HostSystem instance.");
+ goto err;
}
- op = CMNewObjectPath(broker, ns, classname, &s);
- if ((s.rc != CMPI_RC_OK) || CMIsNullObject(op)) {
- CMSetStatusWithChars(broker, &s,
- CMPI_RC_ERR_FAILED,
- "Cannot get object path for HostSystem");
- goto out;
- }
+ set_host_system_properties(inst);
- inst = CMNewInstance(broker, op, &s);
- if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(op))) {
- CMSetStatusWithChars(broker, &s,
- CMPI_RC_ERR_FAILED,
- "Failed to instantiate HostSystem");
- goto out;
- }
-
- set_host_system_properties(inst, classname);
-
+ err:
+ virConnectClose(conn);
out:
*instance = inst;
-
- free(classname);
return s;
}
@@ -103,17 +95,11 @@ static CMPIStatus return_host_cs(const C
const CMPIResult *results,
int name_only)
{
- CMPIStatus s;
+ CMPIStatus s = {CMPI_RC_OK, NULL};
CMPIInstance *instance;
- char *ns;
-
- if (!provider_is_responsible(_BROKER, reference, &s))
- return s;
-
- ns = NAMESPACE(reference);
s = get_host_cs(_BROKER, reference, &instance);
- if (s.rc != CMPI_RC_OK)
+ if (s.rc != CMPI_RC_OK || instance == NULL)
goto out;
if (name_only)
16 years, 11 months
[PATCH] [RFC] ECTP: Adoption of changes to std_association logic
by Heidi Eckhart
# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1196158379 -3600
# Node ID 6200efdd04aafa69f2f76b1cbc0c3567406e829f
# Parent 0e9ce5fd90ec7ab755c017cd5002e8115d7225b7
[RFC] ECTP: Adoption of changes to std_association logic
Signed-off-by: Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
diff -r 0e9ce5fd90ec -r 6200efdd04aa src/Virt_ElementConformsToProfile.c
--- a/src/Virt_ElementConformsToProfile.c Tue Nov 27 11:12:50 2007 +0100
+++ b/src/Virt_ElementConformsToProfile.c Tue Nov 27 11:12:59 2007 +0100
@@ -220,27 +220,47 @@ static CMPIInstance *make_ref(const CMPI
return assoc_inst;
}
+char* conformant_standard[] = {
+ "Xen_RegisteredProfile",
+ "KVM_RegisteredProfile",
+ NULL
+};
+
+char* managed_element[] = {
+ "Xen_HostSystem",
+ "Xen_ComputerSystem",
+ "KVM_HostSystem",
+ "KVM_ComputerSystem",
+ NULL
+};
+
+char* assoc_classname[] = {
+ "Xen_ElementConformsToProfile",
+ "KVM_ElementConformsToProfile",
+ NULL
+};
+
struct std_assoc forward = {
- .source_class = "CIM_RegisteredProfile",
+ .source_class = (char**)&conformant_standard,
.source_prop = "ConformantStandard",
- .target_class = "CIM_ManagedElement",
+ .target_class = (char**)&managed_element,
.target_prop = "ManagedElement",
- .assoc_class = NULL,
+ .assoc_class = (char**)&assoc_classname,
.handler = prof_to_elem,
.make_ref = make_ref
};
struct std_assoc backward = {
- .source_class = "CIM_ManagedElement",
+ .source_class = (char**)&managed_element,
.source_prop = "ManagedElement",
- .target_class = "CIM_RegisteredProfile",
+ .target_class = (char**)&conformant_standard,
.target_prop = "ConformantStandard",
- .assoc_class = NULL,
+ .assoc_class = (char**)&assoc_classname,
.handler = elem_to_prof,
.make_ref = make_ref
@@ -251,7 +271,6 @@ struct std_assoc *assoc_handlers[] = {
&backward,
NULL
};
-
STDA_AssocMIStub(, Virt_ElementConformsToProfileProvider, _BROKER, libvirt_cim_init(), assoc_handlers);
/*
16 years, 11 months
[PATCH] Fix class prefix to depend on established hypervisor connection
by Heidi Eckhart
# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1196158370 -3600
# Node ID 0e9ce5fd90ec7ab755c017cd5002e8115d7225b7
# Parent 690413b4aef454d03ce31003feea55a65fa5347b
Fix class prefix to depend on established hypervisor connection
Signed-off-by: Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
diff -r 690413b4aef4 -r 0e9ce5fd90ec src/Virt_ElementConformsToProfile.c
--- a/src/Virt_ElementConformsToProfile.c Tue Nov 27 10:59:47 2007 +0100
+++ b/src/Virt_ElementConformsToProfile.c Tue Nov 27 11:12:50 2007 +0100
@@ -50,7 +50,8 @@ static CMPIStatus elem_instances(const C
static CMPIStatus elem_instances(const CMPIObjectPath *ref,
struct std_assoc_info *info,
struct inst_list *list,
- struct reg_prof *profile)
+ struct reg_prof *profile,
+ virConnectPtr conn)
{
CMPIStatus s = {CMPI_RC_OK, NULL};
CMPIObjectPath *op;
@@ -58,7 +59,8 @@ static CMPIStatus elem_instances(const C
CMPIData data ;
char *classname;
- classname = get_typed_class("Xen", profile->provider_name);
+ classname = get_typed_class(pfx_from_conn(conn),
+ profile->provider_name);
if (classname == NULL) {
CMSetStatusWithChars(_BROKER, &s,
CMPI_RC_ERR_FAILED,
@@ -101,9 +103,14 @@ static CMPIStatus prof_to_elem(const CMP
struct inst_list *list)
{
CMPIStatus s = {CMPI_RC_OK, NULL};
+ virConnectPtr conn = NULL;
char *id;
int i;
+ conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
+ if (conn == NULL)
+ return s;
+
id = cu_get_str_path(ref, "InstanceID");
if (id == NULL) {
CMSetStatusWithChars(_BROKER, &s,
@@ -114,7 +121,8 @@ static CMPIStatus prof_to_elem(const CMP
for (i = 0; profiles[i] != NULL; i++) {
if (STREQ(id, profiles[i]->reg_id)) {
- s = elem_instances(ref, info, list, profiles[i]);
+ s = elem_instances(ref, info, list,
+ profiles[i], conn);
if ((s.rc != CMPI_RC_OK))
goto error;
break;
@@ -124,6 +132,8 @@ static CMPIStatus prof_to_elem(const CMP
error:
free(id);
out:
+ virConnectClose(conn);
+
return s;
}
@@ -182,10 +192,16 @@ static CMPIInstance *make_ref(const CMPI
struct std_assoc_info *info,
struct std_assoc *assoc)
{
- CMPIInstance *assoc_inst;
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ CMPIInstance *assoc_inst = NULL;
+ virConnectPtr conn = NULL;
+
+ conn = connect_by_classname(_BROKER, CLASSNAME(source_op), &s);
+ if (conn == NULL)
+ return NULL;
assoc_inst = get_typed_instance(_BROKER,
- "Xen",
+ pfx_from_conn(conn),
"ElementConformsToProfile",
NAMESPACE(source_op));
@@ -198,6 +214,8 @@ static CMPIInstance *make_ref(const CMPI
CMSetProperty(assoc_inst, assoc->target_prop,
(CMPIValue *)&(target_op), CMPI_ref);
}
+
+ virConnectClose(conn);
return assoc_inst;
}
16 years, 11 months
[PATCH 0 of 2] Updated ElementSettingData to support RASD instances.
by Kaitlin Rupert
Revised so that get_rasd_instance() is no longer static. This function should be used by other providers - there isn't a need for a new function. Also, cleaned up some of the confusion structure / function names in Virt_ElementSettingData.
Fixed whitespace issues in Virt_RASD.h
16 years, 11 months
[PATCH] Enumeration on VirtualSystemManagementService class is returning dups
by Heidi Eckhart
# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1195735052 -3600
# Node ID fb84303afda80d4d180e9951b114f2769a5d6baa
# Parent 710a381591c1a67e5a79ad3b04aaa8bc7adbb108
Enumeration on VirtualSystemManagementService class is returning dups
On systems where only one hypervisor is existing, the provider
returned instance for all known subclasses (Xen, KVM).
Signed-off-by: Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
diff -r 710a381591c1 -r fb84303afda8 src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Thu Nov 22 13:13:00 2007 +0100
+++ b/src/Virt_VirtualSystemManagementService.c Thu Nov 22 13:37:32 2007 +0100
@@ -1048,26 +1048,32 @@ CMPIStatus get_vsms(const CMPIObjectPath
CMPIStatus get_vsms(const CMPIObjectPath *reference,
CMPIInstance **_inst,
const CMPIBroker *broker)
-{
- CMPIStatus s;
- CMPIInstance *inst;
- CMPIInstance *host;
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ CMPIInstance *inst = NULL;
+ CMPIInstance *host = NULL;
char *val = NULL;
+ 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;
+ goto err;
inst = get_typed_instance(broker,
- CLASSNAME(reference),
+ pfx_from_conn(conn),
"VirtualSystemManagementService",
NAMESPACE(reference));
+
if (inst == NULL) {
CU_DEBUG("Failed to get typed instance");
cu_statusf(broker, &s,
CMPI_RC_ERR_FAILED,
"Failed to create instance");
- goto out;
+ goto err;
}
CMSetProperty(inst, "Name",
@@ -1076,8 +1082,8 @@ CMPIStatus get_vsms(const CMPIObjectPath
if (cu_get_str_prop(host, "Name", &val) != CMPI_RC_OK) {
cu_statusf(broker, &s,
CMPI_RC_ERR_FAILED,
- "Unable to get name of System");
- goto out;
+ "Unable to get name of HostSystem");
+ goto err;
}
CMSetProperty(inst, "SystemName",
@@ -1087,8 +1093,8 @@ CMPIStatus get_vsms(const CMPIObjectPath
if (cu_get_str_prop(host, "CreationClassName", &val) != CMPI_RC_OK) {
cu_statusf(broker, &s,
CMPI_RC_ERR_FAILED,
- "Unable to get creation class of system");
- goto out;
+ "Unable to get creation class of HostSystem");
+ goto err;
}
CMSetProperty(inst, "SystemCreationClassName",
@@ -1097,8 +1103,11 @@ CMPIStatus get_vsms(const CMPIObjectPath
CMSetStatus(&s, CMPI_RC_OK);
+ err:
+ virConnectClose(conn);
+
+ out:
*_inst = inst;
- out:
return s;
}
@@ -1106,19 +1115,17 @@ static CMPIStatus return_vsms(const CMPI
const CMPIResult *results,
int name_only)
{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
CMPIInstance *inst;
- CMPIStatus s;
s = get_vsms(reference, &inst, _BROKER);
- if (s.rc != CMPI_RC_OK)
+ if (s.rc != CMPI_RC_OK || inst == NULL)
goto out;
if (name_only)
cu_return_instance_name(results, inst);
else
CMReturnInstance(results, inst);
-
- CMSetStatus(&s, CMPI_RC_OK);
out:
return s;
}
16 years, 11 months
[PATCH] Add installation instructions for root/interop namespace
by Heidi Eckhart
# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1195733580 -3600
# Node ID 710a381591c1a67e5a79ad3b04aaa8bc7adbb108
# Parent 8c0410bfe3d3da3ef61aa40bfe75f1f23426b77d
Add installation instructions for root/interop namespace
Signed-off-by: Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
diff -r 8c0410bfe3d3 -r 710a381591c1 doc/libvirt-cim.html
--- a/doc/libvirt-cim.html Thu Nov 22 13:08:29 2007 +0100
+++ b/doc/libvirt-cim.html Thu Nov 22 13:13:00 2007 +0100
@@ -76,6 +76,7 @@
$ sudo cimmofl -uc -aEV -R$PEGASUS_REPO -n /root/virt cimv216.mof<br/>
$ sudo cimmofl -uc -aEV -R$PEGASUS_REPO -n /root/virt qualifiers.mof<br/>
$ sudo cimmofl -uc -aEV -R$PEGASUS_REPO -n /root/virt qualifiers_optional.mof<br/>
+ $ sudo cimmofl -uc -aEV -R$PEGASUS_REPO -n /root/interop cimv216-interop.mof<br/>
</code></p>
<h4>To install the schema in SFCB:</h4>
@@ -111,6 +112,23 @@
+//#pragma include ("Security/CIM_IPNetworkSecurityIndication.mof")<br/>
+//#pragma include ("Security/CIM_IPPacketFilterIndication.mof")<br/>
#pragma include ("Support/PRS_ActivityContact.mof")<br/>
+</code></p>
+
+<p><strong>cimv216-interop.mof</strong> is not part of the official DMTF
+ CIM v2.16 schema package. Please create with the folloing content:
+</p>
+
+<p><code>
+#pragma locale ("en_US")<br/>
+#pragma include ("qualifiers.mof")<br/>
+#pragma include ("qualifiers_optional.mof")<br/>
+#pragma include ("Core/CIM_ManagedElement.mof")<br/>
+#pragma include ("Interop/CIM_RegisteredProfile.mof")<br/>
+#pragma include ("Interop/CIM_RegisteredSubProfile.mof")<br/>
+#pragma include ("Core/CIM_Dependency.mof")<br/>
+#pragma include ("Interop/CIM_ElementConformsToProfile.mof")<br/>
+#pragma include ("Interop/CIM_ReferencedProfile.mof")<br/>
+#pragma include ("Interop/CIM_SubProfileRequiresProfile.mof")<br/>
</code></p>
<h2><a name="Platforms">Platform Support</a></h2>
16 years, 11 months
[PATCH] [RFC] ECTP: Adoption of changes to std_association logic
by Heidi Eckhart
# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1195818927 -3600
# Node ID 1078f8d5a4fb8b33f3714dbf72437a7d7f1eaa8f
# Parent 883d767c64256f4d582f06125e05f392454f8a15
[RFC] ECTP: Adoption of changes to std_association logic
Signed-off-by: Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
diff -r 883d767c6425 -r 1078f8d5a4fb src/Virt_ElementConformsToProfile.c
--- a/src/Virt_ElementConformsToProfile.c Fri Nov 23 11:11:22 2007 +0100
+++ b/src/Virt_ElementConformsToProfile.c Fri Nov 23 12:55:27 2007 +0100
@@ -218,27 +218,44 @@ static CMPIInstance *make_ref(const CMPI
return assoc_inst;
}
+char* conformant_standard[] = {
+ "Xen_RegisteredProfile",
+ "KVM_RegisteredProfile",
+ NULL
+};
+
+char* managed_element[] = {
+ "CIM_ManagedElement",
+ NULL
+};
+
+char* assoc_classname[] = {
+ "Xen_ElementConformsToProfile",
+ "KVM_ElementConformsToProfile",
+ NULL
+};
+
struct std_assoc forward = {
- .source_class = "CIM_RegisteredProfile",
+ .source_class = (char**)&conformant_standard,
.source_prop = "ConformantStandard",
- .target_class = "CIM_ManagedElement",
+ .target_class = (char**)&managed_element,
.target_prop = "ManagedElement",
- .assoc_class = NULL,
+ .assoc_class = (char**)&assoc_classname,
.handler = prof_to_elem,
.make_ref = make_ref
};
struct std_assoc backward = {
- .source_class = "CIM_ManagedElement",
+ .source_class = (char**)&managed_element,
.source_prop = "ManagedElement",
- .target_class = "CIM_RegisteredProfile",
+ .target_class = (char**)&conformant_standard,
.target_prop = "ConformantStandard",
- .assoc_class = NULL,
+ .assoc_class = (char**)&assoc_classname,
.handler = elem_to_prof,
.make_ref = make_ref
@@ -249,7 +266,6 @@ struct std_assoc *assoc_handlers[] = {
&backward,
NULL
};
-
STDA_AssocMIStub(, Virt_ElementConformsToProfileProvider, _BROKER, libvirt_cim_init(), assoc_handlers);
/*
16 years, 11 months