[PATCH] VSMC: use get_typed_instance function (tiny optimization)
by Heidi Eckhart
# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1203420624 -3600
# Node ID d96a062a7996bee0109172f8779ae3482cfab6d5
# Parent 8b7a10c27b1cad1b140083dc5fd8b9abab2597ef
VSMC: use get_typed_instance function (tiny optimization)
Signed-off-by: Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
diff -r 8b7a10c27b1c -r d96a062a7996 src/Virt_VirtualSystemManagementCapabilities.c
--- a/src/Virt_VirtualSystemManagementCapabilities.c Tue Feb 19 12:17:08 2008 +0100
+++ b/src/Virt_VirtualSystemManagementCapabilities.c Tue Feb 19 12:30:24 2008 +0100
@@ -46,15 +46,11 @@ enum {ADD_RESOURCES = 1,
static CMPIStatus set_inst_properties(const CMPIBroker *broker,
- CMPIInstance *inst,
- const char *classname)
+ CMPIInstance *inst)
{
CMPIStatus s = {CMPI_RC_OK, NULL};
CMPIArray *array;
uint16_t element;
-
- CMSetProperty(inst, "CreationClassName",
- (CMPIValue *)classname, CMPI_chars);
CMSetProperty(inst, "InstanceID",
(CMPIValue *)"ManagementCapabilities", CMPI_chars);
@@ -83,13 +79,12 @@ static CMPIStatus set_inst_properties(co
CMPIStatus get_vsm_cap(const CMPIBroker *broker,
const CMPIObjectPath *ref,
- CMPIInstance **inst,
+ CMPIInstance **_inst,
bool is_get_inst)
{
- CMPIStatus s;
- CMPIObjectPath *op;
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ CMPIInstance *inst = NULL;
virConnectPtr conn = NULL;
- char *classname = NULL;
conn = connect_by_classname(broker, CLASSNAME(ref), &s);
if (conn == NULL) {
@@ -100,41 +95,26 @@ CMPIStatus get_vsm_cap(const CMPIBroker
goto out;
}
- classname = get_typed_class(CLASSNAME(ref),
- "VirtualSystemManagementCapabilities");
- if (classname == NULL) {
- cu_statusf(broker, &s,
+ inst = get_typed_instance(_BROKER,
+ pfx_from_conn(conn),
+ "VirtualSystemManagementCapabilities",
+ NAMESPACE(ref));
+ if (inst == NULL)
+ cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
- "Invalid class");
- goto out;
- }
+ "Can't create VirtualSystemManagementCapabilities instance");
- op = CMNewObjectPath(broker, NAMESPACE(ref), classname, &s);
- if ((s.rc != CMPI_RC_OK) || CMIsNullObject(op)) {
- cu_statusf(broker, &s,
- CMPI_RC_ERR_FAILED,
- "Cannot get object path for VSMCapabilities");
- goto out;
- }
-
- *inst = CMNewInstance(broker, op, &s);
- if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(*inst))) {
- cu_statusf(broker, &s,
- CMPI_RC_ERR_FAILED,
- "Failed to instantiate HostSystem");
- goto out;
- }
-
- s = set_inst_properties(broker, *inst, classname);
+ s = set_inst_properties(broker, inst);
if (is_get_inst) {
- s = cu_validate_ref(broker, ref, *inst);
+ s = cu_validate_ref(broker, ref, inst);
if (s.rc != CMPI_RC_OK)
goto out;
}
+ *_inst = inst;
+
out:
- free(classname);
virConnectClose(conn);
return s;
16 years, 10 months
[PATCH] (#3) Add Enumeration support to RASD
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1203439144 28800
# Node ID 95c56a7a865df18bbdf1066d8b04d5d4b75e7d44
# Parent 030c012f1698cbccc0cdd0b34f51e377ced6eb16
(#3) Add Enumeration support to RASD
Supports enumerating a specific RASD type, as well as the parent classes
KVM_RASD, Xen_RASD, as well as CIM_RASD.
Changes:
- Remove printf() in place of a CU_DEBUG() (before Kaitlin got a chance to
complain, I'll have you know)
- Fix silly compile error
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 030c012f1698 -r 95c56a7a865d src/Virt_RASD.c
--- a/src/Virt_RASD.c Tue Feb 19 17:04:52 2008 +0800
+++ b/src/Virt_RASD.c Tue Feb 19 08:39:04 2008 -0800
@@ -34,6 +34,7 @@
#include "device_parsing.h"
#include "misc_util.h"
+#include "cs_util.h"
#include "Virt_RASD.h"
#include "svpc_types.h"
@@ -442,6 +443,100 @@ CMPIrc rasd_classname_from_type(uint16_t
return rc;
}
+static CMPIStatus _enum_rasds(const CMPIObjectPath *ref,
+ struct inst_list *list)
+{
+ virConnectPtr conn = NULL;
+ virDomainPtr *domains = NULL;
+ int count;
+ int i, j;
+ uint16_t type;
+ CMPIStatus s;
+ uint16_t types[] = {CIM_RASD_TYPE_PROC,
+ CIM_RASD_TYPE_DISK,
+ CIM_RASD_TYPE_NET,
+ CIM_RASD_TYPE_MEM,
+ 0};
+
+ conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
+ if (conn == NULL)
+ return s;
+
+ count = get_domain_list(conn, &domains);
+ if (count <= 0) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to get domain list");
+ goto out;
+ }
+
+ if (rasd_type_from_classname(CLASSNAME(ref), &type) == CMPI_RC_OK) {
+ types[0] = type;
+ types[1] = 0;
+ }
+
+ for (i = 0; i < count; i++) {
+ for (j = 0; types[j] != 0; j++) {
+ CU_DEBUG("Doing RASD type %i for %s",
+ type, virDomainGetName(domains[i]));
+ rasds_for_domain(_BROKER,
+ virDomainGetName(domains[i]),
+ types[j],
+ ref,
+ list);
+ }
+ virDomainFree(domains[i]);
+ }
+
+ s = (CMPIStatus){CMPI_RC_OK, NULL};
+
+ out:
+ virConnectClose(conn);
+ free(domains);
+
+ return s;
+}
+
+static CMPIStatus return_enum_rasds(const CMPIObjectPath *ref,
+ const CMPIResult *results,
+ const bool names_only)
+{
+ struct inst_list list;
+ CMPIStatus s;
+
+ inst_list_init(&list);
+
+ s = _enum_rasds(ref, &list);
+ if (s.rc == CMPI_RC_OK) {
+ if (names_only)
+ cu_return_instance_names(results, &list);
+ else
+ cu_return_instances(results, &list);
+ }
+
+ inst_list_free(&list);
+
+ return s;
+}
+
+static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self,
+ const CMPIContext *context,
+ const CMPIResult *results,
+ const CMPIObjectPath *reference)
+{
+ return return_enum_rasds(reference, results, true);
+}
+
+static CMPIStatus EnumInstances(CMPIInstanceMI *self,
+ const CMPIContext *context,
+ const CMPIResult *results,
+ const CMPIObjectPath *reference,
+ const char **properties)
+{
+
+ return return_enum_rasds(reference, results, false);
+}
+
static CMPIStatus GetInstance(CMPIInstanceMI *self,
const CMPIContext *context,
const CMPIResult *results,
@@ -516,8 +611,6 @@ DEFAULT_CI();
DEFAULT_CI();
DEFAULT_MI();
DEFAULT_DI();
-DEFAULT_EI();
-DEFAULT_EIN();
DEFAULT_INST_CLEANUP();
DEFAULT_EQ();
16 years, 10 months
[PATCH] Fix names_only tag in VSMC EI
by lizg@cn.ibm.com
# HG changeset patch
# User Zhengang Li <lizg(a)cn.ibm.com>
# Date 1203411892 -28800
# Node ID 9f40e7cbae6915450613f1c1056df31ec721f692
# Parent 7b5611c03994d1568ba69560f5afad284df06bd0
Fix names_only tag in VSMC EI
VirtualSystemManagementCapabilities' EI method has a 'true' names_only
param. This causes sfcb fail to give a correct response. wbemcli gave
me the following on the original code:
wbemei http://localhost/root/virt:Xen_VirtualSystemManagementCapabilities
*
* wbemei: Http Exception: server returned nothing (no headers, no data)
*
Signed-off-by: Zhengang Li <lizg(a)cn.ibm.com>
diff -r 7b5611c03994 -r 9f40e7cbae69 src/Virt_VirtualSystemManagementCapabilities.c
--- a/src/Virt_VirtualSystemManagementCapabilities.c Fri Feb 15 13:35:31 2008 -0800
+++ b/src/Virt_VirtualSystemManagementCapabilities.c Tue Feb 19 17:04:52 2008 +0800
@@ -175,7 +175,7 @@ static CMPIStatus EnumInstances(CMPIInst
const char **properties)
{
- return return_vsm_cap(reference, results, true, false);
+ return return_vsm_cap(reference, results, false, false);
}
static CMPIStatus GetInstance(CMPIInstanceMI *self,
16 years, 10 months
[PATCH] (#2) Add Enumeration support to RASD
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1203373962 28800
# Node ID c118dc77598088e3bd866df48787e5999aeb9d10
# Parent 7b5611c03994d1568ba69560f5afad284df06bd0
(#2) Add Enumeration support to RASD
Supports enumerating a specific RASD type, as well as the parent classes
KVM_RASD, Xen_RASD, as well as CIM_RASD.
Changes:
- Remove printf() in place of a CU_DEBUG() (before Kaitlin got a chance to
complain, I'll have you know)
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 7b5611c03994 -r c118dc775980 src/Virt_RASD.c
--- a/src/Virt_RASD.c Fri Feb 15 13:35:31 2008 -0800
+++ b/src/Virt_RASD.c Mon Feb 18 14:32:42 2008 -0800
@@ -34,6 +34,7 @@
#include "device_parsing.h"
#include "misc_util.h"
+#include "cs_util.h"
#include "Virt_RASD.h"
#include "svpc_types.h"
@@ -442,6 +443,100 @@ CMPIrc rasd_classname_from_type(uint16_t
return rc;
}
+static CMPIStatus _enum_rasds(const CMPIObjectPath *ref,
+ struct inst_list *list)
+{
+ virConnectPtr conn = NULL;
+ virDomainPtr *domains = NULL;
+ int count;
+ int i, j;
+ uint16_t type;
+ CMPIStatus s;
+ uint16_t types[] = {CIM_RASD_TYPE_PROC,
+ CIM_RASD_TYPE_DISK,
+ CIM_RASD_TYPE_NET,
+ CIM_RASD_TYPE_MEM,
+ 0};
+
+ conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
+ if (conn == NULL)
+ return s;
+
+ count = get_domain_list(conn, &domains);
+ if (count <= 0) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to get domain list");
+ goto out;
+ }
+
+ if (rasd_type_from_classname(CLASSNAME(ref), &type) == CMPI_RC_OK) {
+ types[0] = type;
+ types[1] = 0;
+ }
+
+ for (i = 0; i < count; i++) {
+ for (j = 0; types[j] != 0; j++) {
+ CU_DEBUG(("Doing RASD type %i for %s",
+ type, virDomainGetName(domains[i]));
+ rasds_for_domain(_BROKER,
+ virDomainGetName(domains[i]),
+ types[j],
+ ref,
+ list);
+ }
+ virDomainFree(domains[i]);
+ }
+
+ s = (CMPIStatus){CMPI_RC_OK, NULL};
+
+ out:
+ virConnectClose(conn);
+ free(domains);
+
+ return s;
+}
+
+static CMPIStatus return_enum_rasds(const CMPIObjectPath *ref,
+ const CMPIResult *results,
+ const bool names_only)
+{
+ struct inst_list list;
+ CMPIStatus s;
+
+ inst_list_init(&list);
+
+ s = _enum_rasds(ref, &list);
+ if (s.rc == CMPI_RC_OK) {
+ if (names_only)
+ cu_return_instance_names(results, &list);
+ else
+ cu_return_instances(results, &list);
+ }
+
+ inst_list_free(&list);
+
+ return s;
+}
+
+static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self,
+ const CMPIContext *context,
+ const CMPIResult *results,
+ const CMPIObjectPath *reference)
+{
+ return return_enum_rasds(reference, results, true);
+}
+
+static CMPIStatus EnumInstances(CMPIInstanceMI *self,
+ const CMPIContext *context,
+ const CMPIResult *results,
+ const CMPIObjectPath *reference,
+ const char **properties)
+{
+
+ return return_enum_rasds(reference, results, false);
+}
+
static CMPIStatus GetInstance(CMPIInstanceMI *self,
const CMPIContext *context,
const CMPIResult *results,
@@ -516,8 +611,6 @@ DEFAULT_CI();
DEFAULT_CI();
DEFAULT_MI();
DEFAULT_DI();
-DEFAULT_EI();
-DEFAULT_EIN();
DEFAULT_INST_CLEANUP();
DEFAULT_EQ();
16 years, 10 months
[PATCH] Add Enumeration support to RASD
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1203373617 28800
# Node ID 4618b355bc157e201cec22d5eeb8e265e3a84fd6
# Parent 7b5611c03994d1568ba69560f5afad284df06bd0
Add Enumeration support to RASD
Supports enumerating a specific RASD type, as well as the parent classes
KVM_RASD, Xen_RASD, as well as CIM_RASD.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 7b5611c03994 -r 4618b355bc15 src/Virt_RASD.c
--- a/src/Virt_RASD.c Fri Feb 15 13:35:31 2008 -0800
+++ b/src/Virt_RASD.c Mon Feb 18 14:26:57 2008 -0800
@@ -34,6 +34,7 @@
#include "device_parsing.h"
#include "misc_util.h"
+#include "cs_util.h"
#include "Virt_RASD.h"
#include "svpc_types.h"
@@ -442,6 +443,100 @@ CMPIrc rasd_classname_from_type(uint16_t
return rc;
}
+static CMPIStatus _enum_rasds(const CMPIObjectPath *ref,
+ struct inst_list *list)
+{
+ virConnectPtr conn = NULL;
+ virDomainPtr *domains = NULL;
+ int count;
+ int i, j;
+ uint16_t type;
+ CMPIStatus s;
+ uint16_t types[] = {CIM_RASD_TYPE_PROC,
+ CIM_RASD_TYPE_DISK,
+ CIM_RASD_TYPE_NET,
+ CIM_RASD_TYPE_MEM,
+ 0};
+
+ conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
+ if (conn == NULL)
+ return s;
+
+ count = get_domain_list(conn, &domains);
+ if (count <= 0) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to get domain list");
+ goto out;
+ }
+
+ if (rasd_type_from_classname(CLASSNAME(ref), &type) == CMPI_RC_OK) {
+ types[0] = type;
+ types[1] = 0;
+ }
+
+ for (i = 0; i < count; i++) {
+ for (j = 0; types[j] != 0; j++) {
+ printf("Doing RASD type %i for %s\n",
+ type, virDomainGetName(domains[i]));
+ rasds_for_domain(_BROKER,
+ virDomainGetName(domains[i]),
+ types[j],
+ ref,
+ list);
+ }
+ virDomainFree(domains[i]);
+ }
+
+ s = (CMPIStatus){CMPI_RC_OK, NULL};
+
+ out:
+ virConnectClose(conn);
+ free(domains);
+
+ return s;
+}
+
+static CMPIStatus return_enum_rasds(const CMPIObjectPath *ref,
+ const CMPIResult *results,
+ const bool names_only)
+{
+ struct inst_list list;
+ CMPIStatus s;
+
+ inst_list_init(&list);
+
+ s = _enum_rasds(ref, &list);
+ if (s.rc == CMPI_RC_OK) {
+ if (names_only)
+ cu_return_instance_names(results, &list);
+ else
+ cu_return_instances(results, &list);
+ }
+
+ inst_list_free(&list);
+
+ return s;
+}
+
+static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self,
+ const CMPIContext *context,
+ const CMPIResult *results,
+ const CMPIObjectPath *reference)
+{
+ return return_enum_rasds(reference, results, true);
+}
+
+static CMPIStatus EnumInstances(CMPIInstanceMI *self,
+ const CMPIContext *context,
+ const CMPIResult *results,
+ const CMPIObjectPath *reference,
+ const char **properties)
+{
+
+ return return_enum_rasds(reference, results, false);
+}
+
static CMPIStatus GetInstance(CMPIInstanceMI *self,
const CMPIContext *context,
const CMPIResult *results,
@@ -516,8 +611,6 @@ DEFAULT_CI();
DEFAULT_CI();
DEFAULT_MI();
DEFAULT_DI();
-DEFAULT_EI();
-DEFAULT_EIN();
DEFAULT_INST_CLEANUP();
DEFAULT_EQ();
16 years, 10 months
[PATCH] Update cu_statusf() in get_vsms()
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1203111331 28800
# Node ID cbe6502dfe7f201fa09fd2d3d105babb1c62e573
# Parent 6792d7ab0cc36e99d95b6b8afd50fec887334007
Update cu_statusf() in get_vsms().
Use broker local to function instead of the broker belonging to the provider.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 6792d7ab0cc3 -r cbe6502dfe7f src/Virt_VSMigrationCapabilities.c
--- a/src/Virt_VSMigrationCapabilities.c Fri Feb 15 09:57:43 2008 -0800
+++ b/src/Virt_VSMigrationCapabilities.c Fri Feb 15 13:35:31 2008 -0800
@@ -73,7 +73,7 @@ static CMPIStatus set_method_properties(
CMSetProperty(inst, "SynchronousMethodsSupported",
(CMPIValue *)&array, CMPI_uint16A);
- cu_statusf(_BROKER, &s,
+ cu_statusf(broker, &s,
CMPI_RC_OK,
"");
return s;
diff -r 6792d7ab0cc3 -r cbe6502dfe7f src/Virt_VSMigrationService.c
--- a/src/Virt_VSMigrationService.c Fri Feb 15 09:57:43 2008 -0800
+++ b/src/Virt_VSMigrationService.c Fri Feb 15 13:35:31 2008 -0800
@@ -793,7 +793,7 @@ CMPIStatus get_migration_service(const C
CMSetProperty(inst, "SystemCreationClassName",
(CMPIValue *)ccname, CMPI_chars);
- cu_statusf(_BROKER, &s,
+ cu_statusf(broker, &s,
CMPI_RC_OK,
"");
diff -r 6792d7ab0cc3 -r cbe6502dfe7f src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Fri Feb 15 09:57:43 2008 -0800
+++ b/src/Virt_VirtualSystemManagementService.c Fri Feb 15 13:35:31 2008 -0800
@@ -1235,7 +1235,7 @@ CMPIStatus get_vsms(const CMPIObjectPath
goto out;
}
- cu_statusf(_BROKER, &s,
+ cu_statusf(broker, &s,
CMPI_RC_OK,
"");
out:
16 years, 10 months