[PATCH] Update EC to add support for VSMS to VSMC association
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1202490035 28800
# Node ID 54ffc7df5a17a13811ad65f968b7d780330630f7
# Parent 59c1d98cf8989adff7530eac08abee7b79a6cc03
Update EC to add support for VSMS to VSMC association.
Removed the instance property validation. The get_vsms() (etc) calls will need to be updated to handle the reference validation.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 59c1d98cf898 -r 54ffc7df5a17 src/Makefile.am
--- a/src/Makefile.am Fri Feb 08 07:59:01 2008 -0800
+++ b/src/Makefile.am Fri Feb 08 09:00:35 2008 -0800
@@ -99,14 +99,16 @@ libVirt_AllocationCapabilities_la_SOURCE
libVirt_AllocationCapabilities_la_SOURCES = Virt_AllocationCapabilities.c
libVirt_AllocationCapabilities_la_LIBADD = -lVirt_DevicePool
-libVirt_ElementCapabilities_la_DEPENDENCIES = libVirt_VirtualSystemManagementCapabilities.la libVirt_EnabledLogicalElementCapabilities.la libVirt_ComputerSystem.la libVirt_HostSystem.la libVirt_VSMigrationCapabilities.la
+libVirt_ElementCapabilities_la_DEPENDENCIES = libVirt_VirtualSystemManagementCapabilities.la libVirt_EnabledLogicalElementCapabilities.la libVirt_ComputerSystem.la libVirt_HostSystem.la libVirt_VSMigrationCapabilities.la libVirt_VirtualSystemManagementService.la libVirt_VSMigrationService.la
libVirt_ElementCapabilities_la_SOURCES = Virt_ElementCapabilities.c
libVirt_ElementCapabilities_la_LIBADD = -lVirt_VirtualSystemManagementCapabilities \
-lVirt_EnabledLogicalElementCapabilities \
-lVirt_ComputerSystem \
-lVirt_HostSystem \
-lVirt_VSMigrationCapabilities \
- -lVirt_AllocationCapabilities
+ -lVirt_AllocationCapabilities \
+ -lVirt_VirtualSystemManagementService \
+ -lVirt_VSMigrationService
libVirt_SettingsDefineCapabilities_la_DEPENDENCIES = libVirt_RASD.la libVirt_DevicePool.la
libVirt_SettingsDefineCapabilities_la_SOURCES = Virt_SettingsDefineCapabilities.c
diff -r 59c1d98cf898 -r 54ffc7df5a17 src/Virt_ElementCapabilities.c
--- a/src/Virt_ElementCapabilities.c Fri Feb 08 07:59:01 2008 -0800
+++ b/src/Virt_ElementCapabilities.c Fri Feb 08 09:00:35 2008 -0800
@@ -33,6 +33,8 @@
#include <libcmpiutil/std_association.h>
#include "Virt_VirtualSystemManagementCapabilities.h"
+#include "Virt_VirtualSystemManagementService.h"
+#include "Virt_VSMigrationService.h"
#include "Virt_EnabledLogicalElementCapabilities.h"
#include "Virt_ComputerSystem.h"
#include "Virt_HostSystem.h"
@@ -48,31 +50,63 @@
const static CMPIBroker *_BROKER;
-static CMPIStatus validate_host_caps_ref(const CMPIObjectPath *ref)
-{
- CMPIStatus s = {CMPI_RC_OK, NULL};
- CMPIInstance *inst;
- const char *prop;
- char* classname;
-
+static CMPIStatus validate_caps_get_service(const CMPIObjectPath *ref,
+ CMPIInstance **inst)
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ CMPIInstance *_inst;
+ char* classname;
+
classname = class_base_name(CLASSNAME(ref));
if (STREQC(classname, "VirtualSystemManagementCapabilities")) {
- s = get_vsm_cap(_BROKER, ref, &inst);
+ s = get_vsm_cap(_BROKER, ref, &_inst);
+ if ((s.rc != CMPI_RC_OK) || (_inst == NULL))
+ goto out;
+
+ s = get_vsms(ref, &_inst, _BROKER);
} else if (STREQC(classname, "VirtualSystemMigrationCapabilities")) {
- s = get_migration_caps(ref, &inst, _BROKER);
- }
-
- if (s.rc != CMPI_RC_OK)
- goto out;
-
- prop = cu_compare_ref(ref, inst);
- if (prop != NULL) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_NOT_FOUND,
- "No such instance (%s)", prop);
- }
-
+ s = get_migration_caps(ref, &_inst, _BROKER);
+ if ((s.rc != CMPI_RC_OK) || (_inst == NULL))
+ goto out;
+
+ s = get_migration_service(ref, &_inst, _BROKER);
+ } else
+ CMSetStatus(&s, CMPI_RC_ERR_NOT_FOUND);
+
+ *inst = _inst;
+ out:
+ free(classname);
+
+ return s;
+}
+
+static CMPIStatus validate_service_get_caps(const CMPIObjectPath *ref,
+ CMPIInstance **inst)
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ CMPIInstance *_inst;
+ char* classname;
+
+ classname = class_base_name(CLASSNAME(ref));
+
+ if (STREQC(classname, "VirtualSystemManagementService")) {
+ s = get_vsms(ref, &_inst, _BROKER);
+ if ((s.rc != CMPI_RC_OK) || (_inst == NULL))
+ goto out;
+
+ s = get_vsm_cap(_BROKER, ref, &_inst);
+ } else if (STREQC(classname, "VirtualSystemMigrationService")) {
+ s = get_migration_service(ref, &_inst, _BROKER);
+ if ((s.rc != CMPI_RC_OK) || (_inst == NULL))
+ goto out;
+
+ s = get_migration_caps(ref, &_inst, _BROKER);
+ } else
+ CMSetStatus(&s, CMPI_RC_ERR_NOT_FOUND);
+
+ *inst = _inst;
+
out:
free(classname);
@@ -105,19 +139,22 @@ static CMPIStatus sys_to_cap(const CMPIO
return s;
}
-static CMPIStatus cap_to_sys(const CMPIObjectPath *ref,
- struct std_assoc_info *info,
- struct inst_list *list)
-{
- CMPIInstance *inst;
- CMPIStatus s = {CMPI_RC_OK, NULL};
-
- if (!match_hypervisor_prefix(ref, info))
- goto out;
-
- s = validate_host_caps_ref(ref);
- if (s.rc != CMPI_RC_OK)
- goto out;
+static CMPIStatus cap_to_sys_or_service(const CMPIObjectPath *ref,
+ struct std_assoc_info *info,
+ struct inst_list *list)
+{
+ CMPIInstance *inst = NULL;
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+
+ if (!match_hypervisor_prefix(ref, info))
+ goto out;
+
+ s = validate_caps_get_service(ref, &inst);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
+
+ if (inst != NULL)
+ inst_list_add(list, inst);
s = get_host_cs(_BROKER, ref, &inst);
if (s.rc != CMPI_RC_OK)
@@ -125,6 +162,26 @@ static CMPIStatus cap_to_sys(const CMPIO
inst_list_add(list, inst);
+ out:
+ return s;
+}
+
+static CMPIStatus service_to_cap(const CMPIObjectPath *ref,
+ struct std_assoc_info *info,
+ struct inst_list *list)
+{
+ CMPIInstance *inst = NULL;
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+
+ if (!match_hypervisor_prefix(ref, info))
+ goto out;
+
+ s = validate_service_get_caps(ref, &inst);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
+
+ if (inst != NULL)
+ inst_list_add(list, inst);
out:
return s;
}
@@ -245,6 +302,16 @@ static char* host_system[] = {
NULL
};
+static char* host_sys_and_service[] = {
+ "Xen_HostSystem",
+ "KVM_HostSystem",
+ "Xen_VirtualSystemManagementService",
+ "KVM_VirtualSystemManagementService",
+ "Xen_VirtualSystemMigrationService",
+ "KVM_VirtualSystemMigrationService",
+ NULL
+};
+
static char* virtual_system_management_capabilities[] = {
"Xen_VirtualSystemManagementCapabilities",
"Xen_VirtualSystemMigrationCapabilities",
@@ -266,16 +333,37 @@ static struct std_assoc system_to_vsm_ca
.make_ref = make_ref
};
-static struct std_assoc vsm_cap_to_system = {
+static struct std_assoc vsm_cap_to_sys_or_service = {
.source_class = (char**)&virtual_system_management_capabilities,
.source_prop = "Capabilities",
- .target_class = (char**)&host_system,
+ .target_class = (char**)&host_sys_and_service,
.target_prop = "ManagedElement",
.assoc_class = (char**)&assoc_classname,
- .handler = cap_to_sys,
+ .handler = cap_to_sys_or_service,
+ .make_ref = make_ref
+};
+
+static char* service[] = {
+ "Xen_VirtualSystemManagementService",
+ "KVM_VirtualSystemManagementService",
+ "Xen_VirtualSystemMigrationService",
+ "KVM_VirtualSystemMigrationService",
+ NULL
+};
+
+static struct std_assoc _service_to_cap = {
+ .source_class = (char**)&service,
+ .source_prop = "ManagedElement",
+
+ .target_class = (char**)&virtual_system_management_capabilities,
+ .target_prop = "Capabilities",
+
+ .assoc_class = (char**)&assoc_classname,
+
+ .handler = service_to_cap,
.make_ref = make_ref
};
@@ -363,7 +451,8 @@ static struct std_assoc resource_pool_to
static struct std_assoc *assoc_handlers[] = {
&system_to_vsm_cap,
- &vsm_cap_to_system,
+ &vsm_cap_to_sys_or_service,
+ &_service_to_cap,
&ele_cap_to_cs,
&cs_to_ele_cap,
&alloc_cap_to_resource_pool,
16 years, 10 months
[PATCH 0 of 3] [RFC][CU] Add CIMXML EO parser
by Dan Smith
This is a first stab. Looking for comments and review. It's pretty raw
at the moment, but it does work for me. I still need to do nested
objects, but if people are happy with it now, we can bring it into the tree
and add the nested bit after that (which would be my preference).
Keep your eyes peeled for leaks and broken bits, as I'm sure there are some :)
16 years, 10 months
[PATCH] Update the method param structs to support new optional struct element
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1202774057 28800
# Node ID 41f5de794c5b1d9575eea874e48bd50c978e153e
# Parent f93b5748946ab3486649094ec23e9d7fef5257dc
Update the method param structs to support new optional struct element.
This patch is dependant on the optional argument libcmpiutil patch.
For now, all arguments are required. But future support for optional parameters is needed.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r f93b5748946a -r 41f5de794c5b src/Virt_ComputerSystem.c
--- a/src/Virt_ComputerSystem.c Fri Feb 08 14:13:34 2008 -0800
+++ b/src/Virt_ComputerSystem.c Mon Feb 11 15:54:17 2008 -0800
@@ -782,8 +782,8 @@ static struct method_handler RequestStat
static struct method_handler RequestStateChange = {
.name = "RequestStateChange",
.handler = state_change,
- .args = {{"RequestedState", CMPI_uint16},
- {"TimeoutPeriod", CMPI_dateTime},
+ .args = {{"RequestedState", CMPI_uint16, false},
+ {"TimeoutPeriod", CMPI_dateTime, false},
ARG_END
}
};
diff -r f93b5748946a -r 41f5de794c5b src/Virt_VSMigrationService.c
--- a/src/Virt_VSMigrationService.c Fri Feb 08 14:13:34 2008 -0800
+++ b/src/Virt_VSMigrationService.c Mon Feb 11 15:54:17 2008 -0800
@@ -704,8 +704,8 @@ static struct method_handler vsimth = {
static struct method_handler vsimth = {
.name = "CheckVirtualSystemIsMigratableToHost",
.handler = vs_migratable_host,
- .args = {{"ComputerSystem", CMPI_ref},
- {"DestinationHost", CMPI_string},
+ .args = {{"ComputerSystem", CMPI_ref, false},
+ {"DestinationHost", CMPI_string, false},
ARG_END
}
};
@@ -713,8 +713,8 @@ static struct method_handler vsimts = {
static struct method_handler vsimts = {
.name = "CheckVirtualSystemIsMigratableToSystem",
.handler = vs_migratable_system,
- .args = {{"ComputerSystem", CMPI_ref},
- {"DestinationSystem", CMPI_ref},
+ .args = {{"ComputerSystem", CMPI_ref, false},
+ {"DestinationSystem", CMPI_ref, false},
ARG_END
}
};
@@ -722,8 +722,8 @@ static struct method_handler mvsth = {
static struct method_handler mvsth = {
.name = "MigrateVirtualSystemToHost",
.handler = migrate_vs_host,
- .args = {{"ComputerSystem", CMPI_ref},
- {"DestinationHost", CMPI_string},
+ .args = {{"ComputerSystem", CMPI_ref, false},
+ {"DestinationHost", CMPI_string, false},
ARG_END
}
};
@@ -731,8 +731,8 @@ static struct method_handler mvsts = {
static struct method_handler mvsts = {
.name = "MigrateVirtualSystemToSystem",
.handler = migrate_vs_system,
- .args = {{"ComputerSystem", CMPI_ref},
- {"DestinationSystem", CMPI_ref},
+ .args = {{"ComputerSystem", CMPI_ref, false},
+ {"DestinationSystem", CMPI_ref, false},
ARG_END
}
};
diff -r f93b5748946a -r 41f5de794c5b src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Fri Feb 08 14:13:34 2008 -0800
+++ b/src/Virt_VirtualSystemManagementService.c Mon Feb 11 15:54:17 2008 -0800
@@ -1098,9 +1098,9 @@ static struct method_handler DefineSyste
static struct method_handler DefineSystem = {
.name = "DefineSystem",
.handler = define_system,
- .args = {{"SystemSettings", CMPI_instance},
- {"ResourceSettings", CMPI_instanceA},
- {"ReferenceConfiguration", CMPI_string},
+ .args = {{"SystemSettings", CMPI_instance, false},
+ {"ResourceSettings", CMPI_instanceA, false},
+ {"ReferenceConfiguration", CMPI_string, false},
ARG_END
}
};
@@ -1108,7 +1108,7 @@ static struct method_handler DestroySyst
static struct method_handler DestroySystem = {
.name = "DestroySystem",
.handler = destroy_system,
- .args = {{"AffectedSystem", CMPI_ref},
+ .args = {{"AffectedSystem", CMPI_ref, false},
ARG_END
}
};
@@ -1116,8 +1116,8 @@ static struct method_handler AddResource
static struct method_handler AddResourceSettings = {
.name = "AddResourceSettings",
.handler = add_resource_settings,
- .args = {{"AffectedConfiguration", CMPI_ref},
- {"ResourceSettings", CMPI_instanceA},
+ .args = {{"AffectedConfiguration", CMPI_ref, false},
+ {"ResourceSettings", CMPI_instanceA, false},
ARG_END
}
};
@@ -1125,7 +1125,7 @@ static struct method_handler ModifyResou
static struct method_handler ModifyResourceSettings = {
.name = "ModifyResourceSettings",
.handler = mod_resource_settings,
- .args = {{"ResourceSettings", CMPI_instanceA},
+ .args = {{"ResourceSettings", CMPI_instanceA, false},
ARG_END
}
};
@@ -1133,7 +1133,7 @@ static struct method_handler ModifySyste
static struct method_handler ModifySystemSettings = {
.name = "ModifySystemSettings",
.handler = mod_system_settings,
- .args = {{"SystemSettings", CMPI_instance},
+ .args = {{"SystemSettings", CMPI_instance, false},
ARG_END
}
};
@@ -1141,7 +1141,7 @@ static struct method_handler RemoveResou
static struct method_handler RemoveResourceSettings = {
.name = "RemoveResourceSettings",
.handler = rm_resource_settings,
- .args = {{"ResourceSettings", CMPI_refA},
+ .args = {{"ResourceSettings", CMPI_refA, false},
ARG_END
}
};
16 years, 10 months
[PATCH] [CU] Add support for optional method arguments
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1202773946 28800
# Node ID b36fabb5b94524b5252cb8ed355d54f648a219fa
# Parent cc846858f60cb7ce5b859015c9a120d784074eed
[CU] Add support for optional method arguments.
If no argument is supplied for a given parameter, skip any additional argument validation.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r cc846858f60c -r b36fabb5b945 std_invokemethod.c
--- a/std_invokemethod.c Wed Feb 06 08:27:12 2008 -0800
+++ b/std_invokemethod.c Mon Feb 11 15:52:26 2008 -0800
@@ -184,7 +184,8 @@ static int validate_arg_type(struct meth
int ret;
argdata = CMGetArg(args, arg->name, s);
- if ((s->rc != CMPI_RC_OK) || (CMIsNullValue(argdata))) {
+ if (((s->rc != CMPI_RC_OK) || (CMIsNullValue(argdata)))
+ && !arg->optional) {
CMSetStatus(s, CMPI_RC_ERR_INVALID_PARAMETER);
CU_DEBUG("Method parameter `%s' missing",
arg->name);
@@ -204,12 +205,14 @@ static int validate_arg_type(struct meth
if (ret != 1)
return 0;
- } else {
+ } else if (!arg->optional) {
CMSetStatus(s, CMPI_RC_ERR_TYPE_MISMATCH);
CU_DEBUG("Method parameter `%s' type check failed",
arg->name);
return 0;
- }
+ } else
+ CU_DEBUG("No optional parameter supplied for `%s'",
+ arg->name);
} else {
*s = CMAddArg(new_args,
arg->name,
diff -r cc846858f60c -r b36fabb5b945 std_invokemethod.h
--- a/std_invokemethod.h Wed Feb 06 08:27:12 2008 -0800
+++ b/std_invokemethod.h Mon Feb 11 15:52:26 2008 -0800
@@ -45,6 +45,7 @@ struct method_arg {
struct method_arg {
char *name;
CMPIType type;
+ bool optional;
};
struct method_handler {
16 years, 10 months
[PATCH] (#3) Set additional attribute values in Virt_ComputerSystem.c
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1202485701 28800
# Node ID d75e7e59ae2a4acd1e8599f7851c59e1aef0d2dd
# Parent c7dd4a8358a187a3469c3d8a177950625898a227
(#3) Set additional attribute values in Virt_ComputerSystem.c
Update from patch 2 to 3:
-Fixed ordering of OtherIdentifyingInfo
-Fixed type in model string.
Update from patch 1 to patch 2:
-Condensed the functions for OtherIdentifyingInfo and IdentifyingDescriptions into one function
-Added a return variable to catch the return value of the functions called in instance_from_dom() - added a goto out in case of error.
-In the out: block, free the uuid.
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 c7dd4a8358a1 -r d75e7e59ae2a src/Virt_ComputerSystem.c
--- a/src/Virt_ComputerSystem.c Wed Feb 06 07:00:00 2008 -0800
+++ b/src/Virt_ComputerSystem.c Fri Feb 08 07:48:21 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,39 +243,114 @@ 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;
+ CMPIArray *id_desc;
+ char *desc[3] = {"Type", "Model", "UUID"};
+ 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;
+
+ id_desc = 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] = type;
+ info[1] = model;
+ info[2] = uuid;
+
+ for (i = 0; i < count; i++) {
+ CMPIString *tmp = CMNewString(broker, info[i], NULL);
+ CMSetArrayElementAt(id_info, i,
+ &tmp,
+ CMPI_string);
+
+ tmp = CMNewString(broker, desc[i], NULL);
+ CMSetArrayElementAt(id_desc, i,
+ &tmp,
+ CMPI_string);
+ }
+
+ CMSetProperty(instance, "OtherIdentifyingInfo",
+ &id_info, CMPI_stringA);
+
+ 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 = NULL;
+ int ret = 1;
+
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;
+ ret = 0;
+ goto out;
}
if (!set_capdesc_from_dom(dom, instance)) {
/* Print trace error */
- return 0;
+ ret = 0;
+ goto out;
}
if (!set_state_from_dom(broker, dom, instance)) {
/* Print trace error */
- return 0;
+ ret = 0;
+ goto out;
}
if (!set_creation_class(instance)) {
/* Print trace error */
- return 0;
+ ret = 0;
+ goto out;
+ }
+
+ if (!set_other_id_info(broker, uuid, prefix, instance)) {
+ /* Print trace error */
+ ret = 0;
+ goto out;
}
/* More attributes here, of course */
- return 1;
+ out:
+ free(uuid);
+
+ return ret;
}
/* Given a hypervisor connection and a domain name, return an instance */
@@ -294,7 +373,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 +409,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, 10 months
[PATCH] (#4) Make the ProcRASD show CPU pinning information
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1202486140 28800
# Node ID a9d5094d7af37968f66e8c10c641f7682e2def3e
# Parent da31d60724565fb6da4bed307bcc69d710680306
(#4) Make the ProcRASD show CPU pinning information
This is done by embedding instances of the physical processor objects into
the HostResource[] field of the ProcRASD (per the MOF).
In order for the linkage to be present, you need sblim-cmpi-base.
Changes:
- Set the values on the instance and not as keys in the ref
- Remove silly double-semicolons from proc_set_cpu()
- Actually report the correct pinning information
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r da31d6072456 -r a9d5094d7af3 src/Virt_RASD.c
--- a/src/Virt_RASD.c Wed Feb 06 09:18:23 2008 -0800
+++ b/src/Virt_RASD.c Fri Feb 08 07:55:40 2008 -0800
@@ -23,6 +23,7 @@
#include <string.h>
#include <inttypes.h>
#include <sys/stat.h>
+#include <unistd.h>
#include <cmpidt.h>
#include <cmpift.h>
@@ -91,6 +92,191 @@ char *rasd_to_xml(CMPIInstance *rasd)
{
/* FIXME: Remove this */
return NULL;
+}
+
+static bool proc_get_physical_ref(const CMPIBroker *broker,
+ uint32_t physnum,
+ struct inst_list *list)
+{
+ CMPIObjectPath *op = NULL;
+ CMPIStatus s;
+ char hostname[255];
+ char *devid = NULL;
+ CMPIInstance *inst;
+ bool result = false;
+
+ if (asprintf(&devid, "%i", physnum) == -1) {
+ CU_DEBUG("Failed to create DeviceID string");
+ goto out;
+ }
+
+ if (gethostname(hostname, sizeof(hostname)) == -1) {
+ CU_DEBUG("Hostname overflow");
+ goto out;
+ }
+
+ op = CMNewObjectPath(broker, "root/cimv2", "Linux_Processor", &s);
+ if ((op == NULL) || (s.rc != CMPI_RC_OK)) {
+ CU_DEBUG("Failed to get ObjectPath for processor");
+ goto out;
+ }
+
+ inst = CMNewInstance(broker, op, &s);
+ if ((inst == NULL) || (s.rc != CMPI_RC_OK)) {
+ CU_DEBUG("Failed to make instance");
+ goto out;
+ }
+
+ CMSetProperty(inst, "CreationClassName",
+ (CMPIValue *)"Linux_Processor", CMPI_chars);
+ CMSetProperty(inst, "SystemName",
+ (CMPIValue *)hostname, CMPI_chars);
+ CMSetProperty(inst, "SystemCreationClassName",
+ (CMPIValue *)"Linux_ComputerSystem", CMPI_chars);
+ CMSetProperty(inst, "DeviceID",
+ (CMPIValue *)devid, CMPI_chars);
+
+ inst_list_add(list, inst);
+
+ result = true;
+ out:
+ free(devid);
+
+ return result;
+}
+
+static uint32_t proc_set_cpu(const CMPIBroker *broker,
+ virNodeInfoPtr node,
+ virDomainPtr dom,
+ struct virt_device *dev,
+ struct inst_list *list)
+{
+ virVcpuInfoPtr vinfo = NULL;
+ virDomainInfo info;
+ uint8_t *cpumaps = NULL;
+ int ret;
+ int i;
+ int vcpu = dev->dev.vcpu.number;
+ int maplen = VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(*node));
+
+ ret = virDomainGetInfo(dom, &info);
+ if (ret == -1) {
+ CU_DEBUG("Failed to get info for domain `%s'",
+ virDomainGetName(dom));
+ goto out;
+ }
+
+ if (dev->dev.vcpu.number >= info.nrVirtCpu) {
+ CU_DEBUG("VCPU %i higher than max of %i for %s",
+ dev->dev.vcpu.number,
+ info.nrVirtCpu,
+ virDomainGetName(dom));
+ goto out;
+ }
+
+ vinfo = calloc(info.nrVirtCpu, sizeof(*vinfo));
+ if (vinfo == NULL) {
+ CU_DEBUG("Failed to allocate memory for %i virVcpuInfo",
+ info.nrVirtCpu);
+ goto out;
+ }
+
+ cpumaps = calloc(info.nrVirtCpu, maplen);
+ if (cpumaps == NULL) {
+ CU_DEBUG("Failed to allocate memory for %ix%i maps",
+ info.nrVirtCpu, maplen);
+ goto out;
+ }
+
+ ret = virDomainGetVcpus(dom, vinfo, info.nrVirtCpu, cpumaps, maplen);
+ if (ret < info.nrVirtCpu) {
+ CU_DEBUG("Failed to get VCPU info for %s",
+ virDomainGetName(dom));
+ goto out;
+ }
+
+ for (i = 0; i < VIR_NODEINFO_MAXCPUS(*node); i++) {
+ if (VIR_CPU_USABLE(cpumaps, maplen, vcpu, i)) {
+ CU_DEBUG("VCPU %i pinned to physical %i",
+ vcpu, i);
+ proc_get_physical_ref(broker, i, list);
+ } else {
+ CU_DEBUG("VCPU %i not pinned to physical %i",
+ vcpu, i);
+ }
+ }
+ out:
+ free(vinfo);
+ free(cpumaps);
+
+ return 0;
+}
+
+static CMPIStatus proc_rasd_from_vdev(const CMPIBroker *broker,
+ struct virt_device *dev,
+ const char *host,
+ const CMPIObjectPath *ref,
+ CMPIInstance *inst)
+{
+ virConnectPtr conn = NULL;
+ virDomainPtr dom = NULL;
+ virNodeInfo node;
+ CMPIStatus s;
+ CMPIArray *array;
+ struct inst_list list;
+
+ inst_list_init(&list);
+
+ conn = connect_by_classname(broker, CLASSNAME(ref), &s);
+ if (conn == NULL) {
+ cu_statusf(broker, &s,
+ CMPI_RC_ERR_FAILED,
+ "Failed to connect for ProcRASD (%s)",
+ CLASSNAME(ref));
+ goto out;
+ }
+
+ dom = virDomainLookupByName(conn, host);
+ if (dom == NULL) {
+ cu_statusf(broker, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "Unable to get domain for ProcRASD: %s", host);
+ goto out;
+ }
+
+ if (virNodeGetInfo(virDomainGetConnect(dom), &node) == -1) {
+ cu_statusf(broker, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to get node info");
+ goto out;
+ }
+
+ proc_set_cpu(broker, &node, dom, dev, &list);
+
+ if (list.cur > 0) {
+ int i;
+
+ array = CMNewArray(broker,
+ list.cur,
+ CMPI_instance,
+ &s);
+ for (i = 0; i < list.cur; i++) {
+ CMSetArrayElementAt(array,
+ i,
+ (CMPIValue *)&list.list[i],
+ CMPI_instance);
+ }
+
+ CMSetProperty(inst, "HostResource",
+ (CMPIValue *)&array, CMPI_instanceA);
+ }
+
+ out:
+ inst_list_free(&list);
+ virDomainFree(dom);
+ virConnectClose(conn);
+
+ return s;
}
static CMPIInstance *rasd_from_vdev(const CMPIBroker *broker,
@@ -159,6 +345,8 @@ static CMPIInstance *rasd_from_vdev(cons
(CMPIValue *)&dev->dev.mem.size, CMPI_uint64);
CMSetProperty(inst, "Limit",
(CMPIValue *)&dev->dev.mem.maxsize, CMPI_uint64);
+ } else if (dev->type == VIRT_DEV_VCPU) {
+ proc_rasd_from_vdev(broker, dev, host, ref, inst);
}
/* FIXME: Put the HostResource in place */
16 years, 10 months
[PATCH] [RFC] [CU] Turn std_indication's awesome knob to eleven
by Jay Gagnon
# HG changeset patch
# User Jay Gagnon <grendel(a)linux.vnet.ibm.com>
# Date 1202420200 18000
# Node ID 7feaabeb36cea13611d6dc045cd2bd946528032b
# Parent 60ecfe23d68caaa9dda1f115289f168ea8f4a297
[RFC] [CU] Turn std_indication's awesome knob to eleven
This is the prototype of a new std_indication that will handle Enable/DisableIndications and Activate/DeactivateFilter correctly, even on a per-indication basis when one provider handles more than one indication.
Those functions will also now have default_foo equivalents in std_indication, as many providers (especially raise-style ones) will have no special needs there.
The hope is that this will *require* minimal change from existing Indicatio providers, but *allow* for code reduction in most, and of course new providers should try to utilize this.
Signed-off-by: Jay Gagnon <grendel(a)linux.vnet.ibm.com>
diff -r 60ecfe23d68c -r 7feaabeb36ce instance_util.c
--- a/instance_util.c Tue Feb 05 16:01:32 2008 -0500
+++ b/instance_util.c Thu Feb 07 16:36:40 2008 -0500
@@ -251,6 +251,27 @@ CMPIInstance *cu_dup_instance(const CMPI
out:
return dest;
+}
+
+char *classname_from_inst(const CMPIBroker *broker,
+ CMPIInstance *inst,
+ CMPIStatus *s)
+{
+ char *ret = NULL;
+
+ CMPIObjectPath *ref;
+ ref = CMGetObjectPath(inst, s);
+ if ((s->rc != CMPI_RC_OK) || CMIsNullObject(ref)) {
+ cu_statusf(broker, s,
+ CMPI_RC_ERR_FAILED,
+ "Could not get objectpath from instance");
+ goto out;
+ }
+
+ ret = strdup(CLASSNAME(ref));
+
+ out:
+ return ret;
}
/*
diff -r 60ecfe23d68c -r 7feaabeb36ce libcmpiutil.h
--- a/libcmpiutil.h Tue Feb 05 16:01:32 2008 -0500
+++ b/libcmpiutil.h Thu Feb 07 16:36:40 2008 -0500
@@ -413,6 +413,19 @@ CMPIStatus cu_validate_ref(const CMPIBro
CMPIStatus cu_validate_ref(const CMPIBroker *broker,
const CMPIObjectPath *ref,
const CMPIInstance *inst);
+
+/**
+ * Returns the classname from an instance without forcing user to get
+ * ObjectPath first.
+ *
+ * @param broker A pointer to the current broker
+ * @param inst Instance to examine
+ * @param s An out pointer for returning status if error occurs
+ * @returns Classname of instance (must be freed), NULL on failure
+ */
+char *classname_from_inst(const CMPIBroker *broker,
+ CMPIInstance *inst,
+ CMPIStatus *s);
#define DEFAULT_EIN(pn) \
static CMPIStatus pn##EnumInstanceNames(CMPIInstanceMI *self, \
diff -r 60ecfe23d68c -r 7feaabeb36ce std_indication.c
--- a/std_indication.c Tue Feb 05 16:01:32 2008 -0500
+++ b/std_indication.c Thu Feb 07 16:36:40 2008 -0500
@@ -32,6 +32,45 @@
#include "std_indication.h"
+static struct std_ind_state *get_ind_state(struct std_ind_state **list,
+ char *ind_name)
+{
+ int i;
+ struct std_ind_state *state = NULL;
+
+ for (i = 0; list[i] != NULL; i++) {
+ if (STREQC((list[i])->ind_name, ind_name)) {
+ state = list[i];
+ break;
+ }
+ }
+
+ if (state == NULL)
+ CU_DEBUG("get_ind_state: failed to find %s", ind_name);
+
+ return state;
+}
+
+static bool is_ind_enabled(struct std_indication_ctx *ctx,
+ char *ind_name,
+ CMPIStatus *s)
+{
+ bool ret = false;
+ struct std_ind_state *state;
+
+ state = get_ind_state(ctx->ind_states, ind_name);
+ if (state == NULL) {
+ cu_statusf(ctx->brkr, s,
+ CMPI_RC_ERR_FAILED,
+ "No std_ind_state for %s", ind_name);
+ goto out;
+ }
+
+ ret = state->enabled;
+ out:
+ return ret;
+}
+
static CMPIStatus trigger(struct std_indication_ctx *ctx,
const CMPIContext *context)
{
@@ -61,20 +100,85 @@ static CMPIStatus raise(struct std_indic
const CMPIContext *context,
const CMPIArgs *argsin)
{
+ bool enabled;
CMPIInstance *inst;
-
- if (!ctx->enabled) {
- CU_DEBUG("Indication disabled, not raising.");
- return (CMPIStatus) {CMPI_RC_OK, NULL};
- }
-
- if (cu_get_inst_arg(argsin, "Indication", &inst) != CMPI_RC_OK)
- return (CMPIStatus){CMPI_RC_ERR_FAILED, NULL};
-
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ char *ind_name = NULL;
+
+ if (cu_get_inst_arg(argsin, "Indication", &inst) != CMPI_RC_OK) {
+ cu_statusf(ctx->brkr, &s,
+ CMPI_RC_ERR_FAILED,
+ "Could not get indication to raise");
+ goto out;
+ }
+
+ ind_name = classname_from_inst(ctx->brkr, inst, &s);
+ if (s.rc != CMPI_RC_OK || ind_name == NULL) {
+ cu_statusf(ctx->brkr, &s,
+ CMPI_RC_ERR_FAILED,
+ "Couldn't get indication name for enable check.");
+ }
+
+ enabled = is_ind_enabled(ctx, ind_name, &s);
+ if (s.rc != CMPI_RC_OK) {
+ CU_DEBUG("Problem checking enabled: '%s'", CMGetCharPtr(s.msg));
+ goto out;
+ }
+ if (!enabled) {
+ CU_DEBUG("%s disabled, not raising", ind_name);
+ goto out;
+ }
+
+ CU_DEBUG("Calling appropriate raise function");
if (ctx->handler->raise_fn == NULL)
- return default_raise(ctx->brkr, context, inst);
-
- return ctx->handler->raise_fn(ctx->brkr, context, inst);
+ s = default_raise(ctx->brkr, context, inst);
+ else
+ s = ctx->handler->raise_fn(ctx->brkr, context, inst);
+
+ out:
+ free(ind_name);
+ return s;
+}
+
+CMPIStatus stdi_set_ind_state_prop(struct std_indication_ctx *ctx,
+ char *ind_name,
+ int prop,
+ bool value)
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ struct std_ind_state *state;
+
+ CU_DEBUG("In stdi_set_ind_state_prop");
+
+ state = get_ind_state(ctx->ind_states, ind_name);
+ if (state == NULL) {
+ CU_DEBUG("state == NULL, exiting");
+ cu_statusf(ctx->brkr, &s,
+ CMPI_RC_ERR_FAILED,
+ "Provider has no indication '%s'", ind_name);
+ goto out;
+ }
+
+ CU_DEBUG("entering switch");
+ switch (prop) {
+ case STDI_PROP_FILTER:
+ state->filter_active = value;
+ CU_DEBUG("Filter: %s set to %d", ind_name, value);
+ break;
+ case STDI_PROP_ENABLE:
+ state->enabled = value;
+ CU_DEBUG("Enable: %s set to %d", ind_name, value);
+ break;
+ default:
+ CU_DEBUG("default case");
+ cu_statusf(ctx->brkr, &s,
+ CMPI_RC_ERR_FAILED,
+ "Invalid indication state property: %d", prop);
+ goto out;
+ }
+
+ out:
+ return s;
}
CMPIStatus stdi_handler(CMPIMethodMI *self,
diff -r 60ecfe23d68c -r 7feaabeb36ce std_indication.h
--- a/std_indication.h Tue Feb 05 16:01:32 2008 -0500
+++ b/std_indication.h Thu Feb 07 16:36:40 2008 -0500
@@ -58,22 +58,36 @@ typedef CMPIStatus (*raise_indication_t)
typedef CMPIStatus (*trigger_indication_t)(const CMPIContext *ctx);
+enum {STDI_PROP_FILTER,
+ STDI_PROP_ENABLE};
+
struct std_indication_handler {
raise_indication_t raise_fn;
trigger_indication_t trigger_fn;
};
+struct std_ind_state {
+ char *ind_name;
+ bool filter_active;
+ bool enabled;
+};
+
struct std_indication_ctx {
const CMPIBroker *brkr;
struct std_indication_handler *handler;
- bool enabled;
+ struct std_ind_state **ind_states;
};
-#define STDI_IndicationMIStub(pfx, pn, _broker, hook, _handler) \
+CMPIStatus stdi_set_ind_state_prop(struct std_indication_ctx *ctx,
+ char *ind_name,
+ int prop,
+ bool state);
+
+#define STDI_IndicationMIStub(pfx, pn, _broker, hook, _handler, states) \
static struct std_indication_ctx _ctx = { \
.brkr = NULL, \
.handler = _handler, \
- .enabled = false, \
+ .ind_states = states, \
}; \
\
static CMPIIndicationMIFT indMIFT__ = { \
16 years, 10 months
[PATCH] [RFC] Changes required to work with new std_indication. The trigger changes were very light, which was nice
by Jay Gagnon
# HG changeset patch
# User Jay Gagnon <grendel(a)linux.vnet.ibm.com>
# Date 1202420324 18000
# Node ID a82dd87a3830eadda678b88bf4bfcfd4f8cb1ca4
# Parent c7dd4a8358a187a3469c3d8a177950625898a227
[RFC] Changes required to work with new std_indication. The trigger changes were very light, which was nice.
Signed-off-by: Jay Gagnon <grendel(a)linux.vnet.ibm.com>
diff -r c7dd4a8358a1 -r a82dd87a3830 src/Virt_ComputerSystemIndication.c
--- a/src/Virt_ComputerSystemIndication.c Wed Feb 06 07:00:00 2008 -0800
+++ b/src/Virt_ComputerSystemIndication.c Thu Feb 07 16:38:44 2008 -0500
@@ -488,7 +488,8 @@ STDI_IndicationMIStub(,
Virt_ComputerSystemIndication,
_BROKER,
libvirt_cim_init(),
- &csi);
+ &csi,
+ NULL);
/*
* Local Variables:
diff -r c7dd4a8358a1 -r a82dd87a3830 src/Virt_ComputerSystemMigrationIndication.c
--- a/src/Virt_ComputerSystemMigrationIndication.c Wed Feb 06 07:00:00 2008 -0800
+++ b/src/Virt_ComputerSystemMigrationIndication.c Thu Feb 07 16:38:44 2008 -0500
@@ -58,7 +58,13 @@ static CMPIStatus ActivateFilter(CMPIInd
CMPIBoolean first)
{
CMPIStatus s = {CMPI_RC_OK, NULL};
+ struct std_indication_ctx *_ctx;
+ _ctx = (struct std_indication_ctx *)mi->hdl;
+ s = stdi_set_ind_state_prop(_ctx,
+ "Xen_ComputerSystemMigrationIndication",
+ STDI_PROP_FILTER,
+ true);
return s;
}
@@ -69,16 +75,31 @@ static CMPIStatus DeActivateFilter(CMPII
const CMPIObjectPath* op,
CMPIBoolean last)
{
- return (CMPIStatus){CMPI_RC_OK, NULL};
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ struct std_indication_ctx *_ctx;
+
+ _ctx = (struct std_indication_ctx *)mi->hdl;
+ s = stdi_set_ind_state_prop(_ctx,
+ "Xen_ComputerSystemMigrationIndication",
+ STDI_PROP_FILTER,
+ true);
+ return s;
}
static _EI_RTYPE EnableIndications(CMPIIndicationMI* mi,
const CMPIContext *ctx)
{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
struct std_indication_ctx *_ctx;
_ctx = (struct std_indication_ctx *)mi->hdl;
- _ctx->enabled = true;
- CU_DEBUG("ComputerSystemModifiedIndication enabled");
+
+ CU_DEBUG("New enable. Cross your fingers");
+ s = stdi_set_ind_state_prop(_ctx,
+ "Xen_ComputerSystemMigrationIndication",
+ STDI_PROP_ENABLE,
+ true);
+
+ CU_DEBUG("ComputerSystemMigrationIndication enabled");
_EI_RET();
}
@@ -86,10 +107,16 @@ static _EI_RTYPE DisableIndications(CMPI
static _EI_RTYPE DisableIndications(CMPIIndicationMI* mi,
const CMPIContext *ctx)
{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
struct std_indication_ctx *_ctx;
_ctx = (struct std_indication_ctx *)mi->hdl;
- _ctx->enabled = false;
- CU_DEBUG("ComputerSystemModifiedIndication disabled");
+
+ s = stdi_set_ind_state_prop(_ctx,
+ "Xen_ComputerSystemMigrationIndication",
+ STDI_PROP_ENABLE,
+ false);
+
+ CU_DEBUG("ComputerSystemMigrationIndication disabled");
_EI_RET();
}
@@ -97,6 +124,17 @@ static struct std_indication_handler csi
static struct std_indication_handler csi = {
.raise_fn = NULL,
.trigger_fn = NULL,
+};
+
+static struct std_ind_state migrate = {
+ .ind_name = "Xen_ComputerSystemMigrationIndication",
+ .filter_active = false,
+ .enabled = false,
+};
+
+static struct std_ind_state *states[] = {
+ &migrate,
+ NULL,
};
DEFAULT_IND_CLEANUP();
@@ -107,7 +145,8 @@ STDI_IndicationMIStub(,
Virt_ComputerSystemMigrationIndication,
_BROKER,
libvirt_cim_init(),
- &csi);
+ &csi,
+ states);
/*
* Local Variables:
16 years, 10 months