[PATCH] [CU][RFC] Correct a few API issues
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1196194806 28800
# Node ID 256b237ba19f9e178719ed657f2b9a8f0d44d433
# Parent 64e4f6355b52e4b7bcc984ec557610a1fa9a9786
[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.
Changes from last time:
- Fix cu_get_str_prop() to return a const broker string as well
Patch set to make associated changes to libvirt-cim to follow...
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 64e4f6355b52 -r 256b237ba19f args_util.c
--- a/args_util.c Tue Nov 27 06:33:45 2007 -0800
+++ b/args_util.c Tue Nov 27 12:20:06 2007 -0800
@@ -32,7 +32,9 @@
#define CU_WEAK_TYPES 1
-char *cu_get_str_path(const CMPIObjectPath *reference, const char *key)
+CMPIrc cu_get_str_path(const CMPIObjectPath *reference,
+ const char *key,
+ const char **val)
{
CMPIData data;
CMPIStatus s;
@@ -42,18 +44,20 @@ char *cu_get_str_path(const CMPIObjectPa
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) \
@@ -182,7 +195,7 @@ int cu_get_u16_arg(const CMPIArgs *args,
CMPIrc cu_get_str_prop(const CMPIInstance *inst,
const char *prop,
- char **target)
+ const char **target)
{
CMPIData value;
CMPIStatus s;
@@ -198,8 +211,7 @@ CMPIrc cu_get_str_prop(const CMPIInstanc
if ((prop_val = CMGetCharPtr(value.value.string)) == NULL)
return CMPI_RC_ERROR;
- if ((*target = strdup(prop_val)) == NULL)
- return CMPI_RC_ERROR;
+ *target = prop_val;
return CMPI_RC_OK;
}
diff -r 64e4f6355b52 -r 256b237ba19f libcmpiutil.h
--- a/libcmpiutil.h Tue Nov 27 06:33:45 2007 -0800
+++ b/libcmpiutil.h Tue Nov 27 12:20:06 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;
@@ -202,7 +214,7 @@ unsigned int cu_return_instance_names(co
*/
CMPIrc cu_get_str_prop(const CMPIInstance *inst,
const char *prop,
- char **target);
+ const char **target);
/**
* Get a boolean property of an instance
diff -r 64e4f6355b52 -r 256b237ba19f std_indication.c
--- a/std_indication.c Tue Nov 27 06:33:45 2007 -0800
+++ b/std_indication.c Tue Nov 27 12:20:06 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);
}
17 years
[PATCH] [RFC] Enhance handling of association's references
by Heidi Eckhart
# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1195819371 -3600
# Node ID db20c6206fb6decb484035bec81d7c7f2be75eae
# Parent bf54de6af2e210bef57d74cf12e4872f6ba2da4f
[RFC] Enhance handling of association's references
The source and target classnames of std_assoc are now lists,
containing all supported classnames. This approach frees
the provider from listing all possible combinations as
instances of std_assoc.
Signed-off-by: Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
diff -r bf54de6af2e2 -r db20c6206fb6 std_association.c
--- a/std_association.c Tue Nov 20 16:24:27 2007 -0800
+++ b/std_association.c Fri Nov 23 13:02:51 2007 +0100
@@ -61,18 +61,24 @@ static bool match_class(const CMPIBroker
static bool match_class(const CMPIBroker *broker,
const char *ns,
const char *test_class,
- const char *comp_class)
+ char **comp_class_list)
{
CMPIObjectPath *rop;
+ char *comp_class;
+ int i;
rop = CMNewObjectPath(broker, ns, test_class, NULL);
- if ((test_class == NULL) ||
- (comp_class == NULL) ||
- match_op(broker, rop, comp_class))
- return true;
- else
- return false;
+ 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))
+ return true;
+ }
+
+ return false;
}
static CMPIStatus filter_results(struct inst_list *list,
@@ -113,15 +119,30 @@ std_assoc_get_handler(const struct std_a
std_assoc_get_handler(const struct std_assoc_ctx *ctx,
const CMPIObjectPath *ref)
{
- struct std_assoc *ptr;
- int i;
+ struct std_assoc *hdl = NULL;
+ char *source_class;
+ int i, j;
for (i = 0; ctx->handlers[i]; i++) {
- ptr = ctx->handlers[i];
-
- if (CMClassPathIsA(ctx->brkr, ref, ptr->source_class, NULL))
- return ptr;
- }
+ hdl = ctx->handlers[i];
+
+ for (j = 0; hdl->source_class[j]; j++) {
+ source_class = hdl->source_class[j];
+
+ if (CMClassPathIsA(ctx->brkr,
+ ref,
+ source_class,
+ NULL))
+ break;
+
+ source_class = NULL;
+ }
+ if (source_class)
+ break;
+ }
+
+ if (hdl)
+ return hdl;
return NULL;
}
@@ -144,9 +165,6 @@ static CMPIStatus do_assoc(struct std_as
handler = std_assoc_get_handler(ctx, ref);
if (handler == NULL) {
CU_DEBUG("No handler found.");
- cu_statusf(ctx->brkr, &s,
- CMPI_RC_ERR_FAILED,
- "Unable to handle this association");
goto out;
}
@@ -243,9 +261,7 @@ static CMPIStatus do_ref(struct std_asso
handler = std_assoc_get_handler(ctx, ref);
if (handler == NULL) {
- cu_statusf(ctx->brkr, &s,
- CMPI_RC_ERR_FAILED,
- "Unable to handle this association");
+ CU_DEBUG("No handler found.");
goto out;
}
diff -r bf54de6af2e2 -r db20c6206fb6 std_association.h
--- a/std_association.h Tue Nov 20 16:24:27 2007 -0800
+++ b/std_association.h Fri Nov 23 13:02:51 2007 +0100
@@ -37,13 +37,13 @@ typedef CMPIInstance *(*make_ref_t)(cons
struct std_assoc *);
struct std_assoc {
- char *source_class;
+ char **source_class;
char *source_prop;
- char *target_class;
+ char **target_class;
char *target_prop;
- char *assoc_class;
+ char **assoc_class;
assoc_handler_t handler;
make_ref_t make_ref;
17 years
[PATCH] [RFC] Check for matching hypervisor prefixes
by Heidi Eckhart
# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1196167642 -3600
# Node ID 901bcb9e9fb3272956e55b01d2b1eb05f7e35a9c
# Parent 6200efdd04aafa69f2f76b1cbc0c3567406e829f
[RFC] Check for matching hypervisor prefixes
The class prefixes need to be checked for compliance, as a
request for KVM_RegisteredProfile with Xen_ECTP as assoc
does not return any instances.
Signed-off-by: Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
diff -r 6200efdd04aa -r 901bcb9e9fb3 libxkutil/misc_util.c
--- a/libxkutil/misc_util.c Tue Nov 27 11:12:59 2007 +0100
+++ b/libxkutil/misc_util.c Tue Nov 27 13:47:22 2007 +0100
@@ -33,6 +33,7 @@
#include "cmpimacs.h"
#include "libcmpiutil.h"
+#include "std_association.h"
#include "misc_util.h"
#include "cs_util.h"
@@ -304,6 +305,43 @@ bool provider_is_responsible(const CMPIB
free(pfx);
return rc;
}
+
+bool assoc_match_prefix(const CMPIObjectPath *reference,
+ struct std_assoc_info *info)
+{
+ char *ref_pfx = NULL;
+ char *pfx = NULL;
+ bool rc = true;
+
+ ref_pfx = class_prefix_name(CLASSNAME(reference));
+
+ if (info->assoc_class) {
+ pfx = class_prefix_name(info->assoc_class);
+
+ if (!STREQC(ref_pfx, pfx)) {
+ if (!STREQC("CIM", pfx))
+ rc = false;
+ }
+
+ free(pfx);
+ }
+
+ if (info->result_class) {
+ pfx = class_prefix_name(info->result_class);
+
+ if (!STREQC(ref_pfx, pfx)) {
+ if (!STREQC("CIM", pfx))
+ rc = false;
+ }
+
+ free(pfx);
+ }
+
+ free(ref_pfx);
+ return rc;
+}
+
+
bool domain_online(virDomainPtr dom)
{
diff -r 6200efdd04aa -r 901bcb9e9fb3 libxkutil/misc_util.h
--- a/libxkutil/misc_util.h Tue Nov 27 11:12:59 2007 +0100
+++ b/libxkutil/misc_util.h Tue Nov 27 13:47:22 2007 +0100
@@ -32,6 +32,7 @@
#include "cmpimacs.h"
#include <libcmpiutil.h>
+#include <std_association.h>
/* Check if the provider is reponsible for the given class:
* e.g. Xen is running on the system and KVM_... is asked for,
@@ -105,6 +106,9 @@ bool libvirt_cim_init(void);
#endif
+bool assoc_match_prefix(const CMPIObjectPath *reference,
+ struct std_assoc_info *info);
+
/*
* Local Variables:
* mode: C
diff -r 6200efdd04aa -r 901bcb9e9fb3 src/Virt_ElementConformsToProfile.c
--- a/src/Virt_ElementConformsToProfile.c Tue Nov 27 11:12:59 2007 +0100
+++ b/src/Virt_ElementConformsToProfile.c Tue Nov 27 13:47:22 2007 +0100
@@ -107,6 +107,9 @@ static CMPIStatus prof_to_elem(const CMP
char *id;
int i;
+ if (!assoc_match_prefix(ref, info))
+ goto out;
+
conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
if (conn == NULL)
return s;
@@ -147,6 +150,9 @@ static CMPIStatus elem_to_prof(const CMP
char *classname;
struct reg_prof *candidate;
int i;
+
+ if (!assoc_match_prefix(ref, info))
+ goto out;
conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
if (conn == NULL)
17 years
[PATCH] [RFC] Enhance handling of association's references
by Heidi Eckhart
# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1196160333 -3600
# Node ID 16ac621eb3b34d11caca00100901d27bede7a7c7
# Parent bf54de6af2e210bef57d74cf12e4872f6ba2da4f
[RFC] Enhance handling of association's references
The source and target classnames of std_assoc are now lists,
containing all supported classnames. This approach frees
the provider from listing all possible combinations as
instances of std_assoc.
Signed-off-by: Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
diff -r bf54de6af2e2 -r 16ac621eb3b3 std_association.c
--- a/std_association.c Tue Nov 20 16:24:27 2007 -0800
+++ b/std_association.c Tue Nov 27 11:45:33 2007 +0100
@@ -61,18 +61,44 @@ static bool match_class(const CMPIBroker
static bool match_class(const CMPIBroker *broker,
const char *ns,
const char *test_class,
- const char *comp_class)
+ char **comp_class_list)
{
CMPIObjectPath *rop;
+ char *comp_class;
+ int i;
rop = CMNewObjectPath(broker, ns, test_class, NULL);
- if ((test_class == NULL) ||
- (comp_class == NULL) ||
- match_op(broker, rop, comp_class))
- return true;
- else
- return false;
+ 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))
+ return true;
+ }
+
+ return false;
+}
+
+static bool match_source_class(const CMPIBroker *broker,
+ const CMPIObjectPath *ref,
+ struct std_assoc *ptr)
+{
+ int i;
+ char *source_class;
+
+ for (i = 0; ptr->source_class[i]; i++) {
+ source_class = ptr->source_class[i];
+
+ if (CMClassPathIsA(broker,
+ ref,
+ source_class,
+ NULL))
+ return true;
+ }
+
+ return false;
}
static CMPIStatus filter_results(struct inst_list *list,
@@ -113,13 +139,13 @@ std_assoc_get_handler(const struct std_a
std_assoc_get_handler(const struct std_assoc_ctx *ctx,
const CMPIObjectPath *ref)
{
- struct std_assoc *ptr;
+ struct std_assoc *ptr = NULL;
int i;
for (i = 0; ctx->handlers[i]; i++) {
ptr = ctx->handlers[i];
- if (CMClassPathIsA(ctx->brkr, ref, ptr->source_class, NULL))
+ if (match_source_class(ctx->brkr, ref, ptr))
return ptr;
}
@@ -144,9 +170,6 @@ static CMPIStatus do_assoc(struct std_as
handler = std_assoc_get_handler(ctx, ref);
if (handler == NULL) {
CU_DEBUG("No handler found.");
- cu_statusf(ctx->brkr, &s,
- CMPI_RC_ERR_FAILED,
- "Unable to handle this association");
goto out;
}
@@ -243,9 +266,7 @@ static CMPIStatus do_ref(struct std_asso
handler = std_assoc_get_handler(ctx, ref);
if (handler == NULL) {
- cu_statusf(ctx->brkr, &s,
- CMPI_RC_ERR_FAILED,
- "Unable to handle this association");
+ CU_DEBUG("No handler found.");
goto out;
}
diff -r bf54de6af2e2 -r 16ac621eb3b3 std_association.h
--- a/std_association.h Tue Nov 20 16:24:27 2007 -0800
+++ b/std_association.h Tue Nov 27 11:45:33 2007 +0100
@@ -37,13 +37,13 @@ typedef CMPIInstance *(*make_ref_t)(cons
struct std_assoc *);
struct std_assoc {
- char *source_class;
+ char **source_class;
char *source_prop;
- char *target_class;
+ char **target_class;
char *target_prop;
- char *assoc_class;
+ char **assoc_class;
assoc_handler_t handler;
make_ref_t make_ref;
17 years
[PATCH] Enumeration on VirtualSystemManagementService class is returning dups
by Heidi Eckhart
# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1196156053 -3600
# Node ID ce846c470102c9c126b027c68d58f5205cadfb10
# Parent a73fce7861b2fef889762fc2c4d8f70e7ea499a1
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 a73fce7861b2 -r ce846c470102 src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Tue Nov 27 10:32:04 2007 +0100
+++ b/src/Virt_VirtualSystemManagementService.c Tue Nov 27 10:34:13 2007 +0100
@@ -1048,20 +1048,27 @@ 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;
+
+ *_inst = NULL;
+ conn = connect_by_classname(broker, CLASSNAME(reference), &s);
+ if (conn == NULL)
+ return s;
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),
"VirtualSystemManagementService",
NAMESPACE(reference));
+
if (inst == NULL) {
CU_DEBUG("Failed to get typed instance");
cu_statusf(broker, &s,
@@ -1076,7 +1083,7 @@ 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");
+ "Unable to get name of HostSystem");
goto out;
}
@@ -1087,7 +1094,7 @@ 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");
+ "Unable to get creation class of HostSystem");
goto out;
}
@@ -1097,8 +1104,10 @@ CMPIStatus get_vsms(const CMPIObjectPath
CMSetStatus(&s, CMPI_RC_OK);
+ out:
+ virConnectClose(conn);
*_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;
}
17 years
[PATCH] Enumeration on HostSystem class is returning dups
by Heidi Eckhart
# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1196155366 -3600
# Node ID 533f6c0e7e4dd1b3264e136211d6f84062d9f79d
# 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 533f6c0e7e4d src/Virt_HostSystem.c
--- a/src/Virt_HostSystem.c Tue Nov 20 16:26:00 2007 -0500
+++ b/src/Virt_HostSystem.c Tue Nov 27 10:22:46 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);
+ *instance = NULL;
+ conn = connect_by_classname(broker, CLASSNAME(reference), &s);
+ if (conn == NULL)
+ return s;
- 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");
+ "Can't create HostSystem instance.");
goto out;
}
- 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;
- }
-
- 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);
+ set_host_system_properties(inst);
out:
+ virConnectClose(conn);
*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)
17 years
[PATCH] Add installation instructions for root/interop namespace
by Heidi Eckhart
# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1196154214 -3600
# Node ID ea06dd0a020c087d1373551722b89a1da372453d
# Parent 31093e14df128c2b0c01480fd5c001ee127d1e0b
Add installation instructions for root/interop namespace
Signed-off-by: Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
diff -r 31093e14df12 -r ea06dd0a020c doc/libvirt-cim.html
--- a/doc/libvirt-cim.html Fri Nov 23 10:57:12 2007 +0100
+++ b/doc/libvirt-cim.html Tue Nov 27 10:03:34 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 following 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>
17 years
[PATCH] More rpm spec changes
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1196174025 28800
# Node ID 64e4f6355b52e4b7bcc984ec557610a1fa9a9786
# Parent 183df45f2bb6debe6dd9fc4aec82ad8673741107
More rpm spec changes
- Make 'rpm' target change permissions on the spec file before building
- Disable static library builds
- Make install use "install -p" to preserve file timestamps
- Include COPYING file in the base package
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 183df45f2bb6 -r 64e4f6355b52 Makefile.am
--- a/Makefile.am Wed Nov 21 07:01:01 2007 -0800
+++ b/Makefile.am Tue Nov 27 06:33:45 2007 -0800
@@ -48,5 +48,5 @@ clean-local:
rm -f $(BUILT_SOURCES) *~
rpm: clean
- @(unset CDPATH ; $(MAKE) dist && rpmbuild -ta $(distdir).tar.gz)
+ @(unset CDPATH ; chmod 0644 libcmpiutil.spec ; $(MAKE) dist && rpmbuild -ta $(distdir).tar.gz)
diff -r 183df45f2bb6 -r 64e4f6355b52 libcmpiutil.spec.in
--- a/libcmpiutil.spec.in Wed Nov 21 07:01:01 2007 -0800
+++ b/libcmpiutil.spec.in Tue Nov 27 06:33:45 2007 -0800
@@ -5,7 +5,7 @@ Version: @PACKAGE_VERSION@
Version: @PACKAGE_VERSION@
Release: 1%{?dist}%{?extra_release}
License: LGPLv2+
-Group: Development/Libraries
+Group: System Environment/Libraries
Source: libcmpiutil-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
URL: http://libvirt.org/CIM/
@@ -40,13 +40,13 @@ chmod -x *.c *.y *.h *.l
chmod -x *.c *.y *.h *.l
%build
-%configure
+%configure --enable-static=no
make %{?_smp_mflags}
%install
rm -fr $RPM_BUILD_ROOT
-make DESTDIR=$RPM_BUILD_ROOT install
+make DESTDIR=$RPM_BUILD_ROOT INSTALL="install -p" install
rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
rm -f $RPM_BUILD_ROOT%{_libdir}/*.a
@@ -58,13 +58,13 @@ rm -fr $RPM_BUILD_ROOT
%postun -p /sbin/ldconfig
%files
-%defattr(-, root, root)
+%defattr(-, root, root, -)
-%doc doc/doxygen.conf doc/mainpage README
+%doc doc/doxygen.conf doc/mainpage README COPYING
%{_libdir}/lib*.so.*
%files devel
-%defattr(-, root, root)
+%defattr(-, root, root, -)
%{_libdir}/lib*.so
%dir %{_includedir}/libcmpiutil
17 years
[PATCH] More rpm spec changes
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1196124672 28800
# Node ID 05f120725e3dc562dc8fa251da698faa474f0b55
# Parent 183df45f2bb6debe6dd9fc4aec82ad8673741107
More rpm spec changes
- Make dist a dependency of rpm and change the permissions on the spec file
before building the rpm
- Disable static library builds
- Make install use "install -p" to preserve file timestamps
- Include COPYING file in the base package
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 183df45f2bb6 -r 05f120725e3d Makefile.am
--- a/Makefile.am Wed Nov 21 07:01:01 2007 -0800
+++ b/Makefile.am Mon Nov 26 16:51:12 2007 -0800
@@ -47,6 +47,7 @@ clean-local:
clean-local:
rm -f $(BUILT_SOURCES) *~
-rpm: clean
- @(unset CDPATH ; $(MAKE) dist && rpmbuild -ta $(distdir).tar.gz)
+rpm: clean dist
+ @chmod 0644 libcmpiutil.spec $(distdir).tar.gz
+ @(unset CDPATH ; rpmbuild -ta $(distdir).tar.gz)
diff -r 183df45f2bb6 -r 05f120725e3d libcmpiutil.spec.in
--- a/libcmpiutil.spec.in Wed Nov 21 07:01:01 2007 -0800
+++ b/libcmpiutil.spec.in Mon Nov 26 16:51:12 2007 -0800
@@ -5,7 +5,7 @@ Version: @PACKAGE_VERSION@
Version: @PACKAGE_VERSION@
Release: 1%{?dist}%{?extra_release}
License: LGPLv2+
-Group: Development/Libraries
+Group: System Environment/Libraries
Source: libcmpiutil-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
URL: http://libvirt.org/CIM/
@@ -40,13 +40,13 @@ chmod -x *.c *.y *.h *.l
chmod -x *.c *.y *.h *.l
%build
-%configure
+%configure --enable-static=no
make %{?_smp_mflags}
%install
rm -fr $RPM_BUILD_ROOT
-make DESTDIR=$RPM_BUILD_ROOT install
+make DESTDIR=$RPM_BUILD_ROOT INSTALL="install -p" install
rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
rm -f $RPM_BUILD_ROOT%{_libdir}/*.a
@@ -58,13 +58,13 @@ rm -fr $RPM_BUILD_ROOT
%postun -p /sbin/ldconfig
%files
-%defattr(-, root, root)
+%defattr(-, root, root, -)
-%doc doc/doxygen.conf doc/mainpage README
+%doc doc/doxygen.conf doc/mainpage README COPYING
%{_libdir}/lib*.so.*
%files devel
-%defattr(-, root, root)
+%defattr(-, root, root, -)
%{_libdir}/lib*.so
%dir %{_includedir}/libcmpiutil
17 years