[PATCH 0 of 3] Bring providers up to speed with new std_indication

Not a ton of explanation needed here. This is the sister set to the new libcmpiutil std_indication changes.

# HG changeset patch # User Jay Gagnon <grendel@linux.vnet.ibm.com> # Date 1203954850 18000 # Node ID f09ab8e032c9cac3d3815a0f539f40437c1c115f # Parent d72742466a8892154997d2f210cb9ceeff035962 Update ComputerSystemMigration to new std_indication Essentially, it's been gutted. All this provider ever needed to be was a skeleton that passed along CSMI instances. All it does now is enough to tell std_indication that all the defaults are just fine. Signed-off-by: Jay Gagnon <grendel@linux.vnet.ibm.com> diff -r d72742466a88 -r f09ab8e032c9 src/Virt_ComputerSystemMigrationIndication.c --- a/src/Virt_ComputerSystemMigrationIndication.c Tue Feb 19 15:29:52 2008 -0800 +++ b/src/Virt_ComputerSystemMigrationIndication.c Mon Feb 25 10:54:10 2008 -0500 @@ -42,61 +42,11 @@ static const CMPIBroker *_BROKER; -#ifdef CMPI_EI_VOID -# define _EI_RTYPE void -# define _EI_RET() return -#else -# define _EI_RTYPE CMPIStatus -# define _EI_RET() return (CMPIStatus){CMPI_RC_OK, NULL} -#endif +DECLARE_FILTER(xen_migrate, "Xen_ComputerSystemMigrationIndication"); -static CMPIStatus ActivateFilter(CMPIIndicationMI* mi, - const CMPIContext* ctx, - const CMPISelectExp* se, - const char *ns, - const CMPIObjectPath* op, - CMPIBoolean first) -{ - CMPIStatus s = {CMPI_RC_OK, NULL}; - - return s; -} - -static CMPIStatus DeActivateFilter(CMPIIndicationMI* mi, - const CMPIContext* ctx, - const CMPISelectExp* se, - const char *ns, - const CMPIObjectPath* op, - CMPIBoolean last) -{ - return (CMPIStatus){CMPI_RC_OK, NULL}; -} - -static _EI_RTYPE EnableIndications(CMPIIndicationMI* mi, - const CMPIContext *ctx) -{ - struct std_indication_ctx *_ctx; - _ctx = (struct std_indication_ctx *)mi->hdl; - _ctx->enabled = true; - CU_DEBUG("ComputerSystemModifiedIndication enabled"); - - _EI_RET(); -} - -static _EI_RTYPE DisableIndications(CMPIIndicationMI* mi, - const CMPIContext *ctx) -{ - struct std_indication_ctx *_ctx; - _ctx = (struct std_indication_ctx *)mi->hdl; - _ctx->enabled = false; - CU_DEBUG("ComputerSystemModifiedIndication disabled"); - - _EI_RET(); -} - -static struct std_indication_handler csi = { - .raise_fn = NULL, - .trigger_fn = NULL, +static struct std_ind_filter *filters[] = { + &xen_migrate, + NULL, }; DEFAULT_IND_CLEANUP(); @@ -104,10 +54,11 @@ DEFAULT_MP(); DEFAULT_MP(); STDI_IndicationMIStub(, - Virt_ComputerSystemMigrationIndication, + Virt_ComputerSystemMigrationIndicationProvider, _BROKER, libvirt_cim_init(), - &csi); + NULL, + filters); /* * Local Variables:

JG> # HG changeset patch JG> # User Jay Gagnon <grendel@linux.vnet.ibm.com> JG> # Date 1203954850 18000 JG> # Node ID f09ab8e032c9cac3d3815a0f539f40437c1c115f JG> # Parent d72742466a8892154997d2f210cb9ceeff035962 JG> Update ComputerSystemMigration to new std_indication Hard to complain with a diffstat like this: Virt_ComputerSystemMigrationIndication.c | 63 +++---------------------------- 1 file changed, 7 insertions(+), 56 deletions(-) +1 from me :) -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

# HG changeset patch # User Jay Gagnon <grendel@linux.vnet.ibm.com> # Date 1203954855 18000 # Node ID 3434ff4b4321cc649d36cb15171cc1e685186f18 # Parent f09ab8e032c9cac3d3815a0f539f40437c1c115f Add "Provider" to end of provider names for indications Not directly related to new std_indication, but some debugging work revealed that the provider name and .so name were identical, which isn't great policy since you can't tell which is which in debug output. Signed-off-by: Jay Gagnon <grendel@linux.vnet.ibm.com> diff -r f09ab8e032c9 -r 3434ff4b4321 schema/ComputerSystemIndication.registration --- a/schema/ComputerSystemIndication.registration Mon Feb 25 10:54:10 2008 -0500 +++ b/schema/ComputerSystemIndication.registration Mon Feb 25 10:54:15 2008 -0500 @@ -1,8 +1,8 @@ # Copyright IBM Corp. 2007 # Classname Namespace ProviderName ProviderModule ProviderTypes -Xen_ComputerSystemCreatedIndication root/virt Virt_ComputerSystemIndication Virt_ComputerSystemIndication indication method -Xen_ComputerSystemDeletedIndication root/virt Virt_ComputerSystemIndication Virt_ComputerSystemIndication indication method -Xen_ComputerSystemModifiedIndication root/virt Virt_ComputerSystemIndication Virt_ComputerSystemIndication indication method -KVM_ComputerSystemCreatedIndication root/virt Virt_ComputerSystemIndication Virt_ComputerSystemIndication indication method -KVM_ComputerSystemDeletedIndication root/virt Virt_ComputerSystemIndication Virt_ComputerSystemIndication indication method -KVM_ComputerSystemModifiedIndication root/virt Virt_ComputerSystemIndication Virt_ComputerSystemIndication indication method +Xen_ComputerSystemCreatedIndication root/virt Virt_ComputerSystemIndicationProvider Virt_ComputerSystemIndication indication method +Xen_ComputerSystemDeletedIndication root/virt Virt_ComputerSystemIndicationProvider Virt_ComputerSystemIndication indication method +Xen_ComputerSystemModifiedIndication root/virt Virt_ComputerSystemIndicationProvider Virt_ComputerSystemIndication indication method +KVM_ComputerSystemCreatedIndication root/virt Virt_ComputerSystemIndicationProvider Virt_ComputerSystemIndication indication method +KVM_ComputerSystemDeletedIndication root/virt Virt_ComputerSystemIndicationProvider Virt_ComputerSystemIndication indication method +KVM_ComputerSystemModifiedIndication root/virt Virt_ComputerSystemIndicationProvider Virt_ComputerSystemIndication indication method diff -r f09ab8e032c9 -r 3434ff4b4321 schema/ComputerSystemMigrationIndication.registration --- a/schema/ComputerSystemMigrationIndication.registration Mon Feb 25 10:54:10 2008 -0500 +++ b/schema/ComputerSystemMigrationIndication.registration Mon Feb 25 10:54:15 2008 -0500 @@ -1,4 +1,4 @@ # Copyright IBM Corp. 2007 # Classname Namespace ProviderName ProviderModule ProviderTypes -Xen_ComputerSystemMigrationIndication root/virt Virt_ComputerSystemMigrationIndication Virt_ComputerSystemMigrationIndication indication method -KVM_ComputerSystemMigrationIndication root/virt Virt_ComputerSystemMigrationIndication Virt_ComputerSystemMigrationIndication indication method +Xen_ComputerSystemMigrationIndication root/virt Virt_ComputerSystemMigrationIndicationProvider Virt_ComputerSystemMigrationIndication indication method +KVM_ComputerSystemMigrationIndication root/virt Virt_ComputerSystemMigrationIndicationProvider Virt_ComputerSystemMigrationIndication indication method

# HG changeset patch # User Jay Gagnon <grendel@linux.vnet.ibm.com> # Date 1203954964 18000 # Node ID 03485e8f9b04c3b6b01629116f436d6c78bee89e # Parent 3434ff4b4321cc649d36cb15171cc1e685186f18 Bring ComputerSystemIndication up to speed with new std_indication Move ind_args to std_indication Switch from using CBDeliver to using stdi_deliver Add new structs for new function table, enable/disable, filter mechanisms Move CMPI_VOID check to std_indication Pass ind_args around instead of individual components, add std_indication_ctx to ind_args. Signed-off-by: Jay Gagnon <grendel@linux.vnet.ibm.com> diff -r 3434ff4b4321 -r 03485e8f9b04 src/Virt_ComputerSystemIndication.c --- a/src/Virt_ComputerSystemIndication.c Mon Feb 25 10:54:15 2008 -0500 +++ b/src/Virt_ComputerSystemIndication.c Mon Feb 25 10:56:04 2008 -0500 @@ -59,36 +59,14 @@ static bool lifecycle_enabled = 0; #define WAIT_TIME 180 #define FAIL_WAIT_TIME 2 -#ifdef CMPI_EI_VOID -# define _EI_RTYPE void -# define _EI_RET() return -#else -# define _EI_RTYPE CMPIStatus -# define _EI_RET() return (CMPIStatus){CMPI_RC_OK, NULL} -#endif - struct dom_xml { char uuid[VIR_UUID_STRING_BUFLEN]; char *xml; }; -struct ind_args { - CMPIContext *context; - char *ns; - char *classname; -}; - static void free_dom_xml (struct dom_xml dom) { free(dom.xml); -} - -static void free_ind_args (struct ind_args **args) -{ - free((*args)->ns); - free((*args)->classname); - free(*args); - *args = NULL; } static char *sys_name_from_xml(char *xml) @@ -168,7 +146,7 @@ static bool _do_indication(const CMPIBro int ind_type, const char *ind_type_name, char *prefix, - char *ns) + struct ind_args *args) { CMPIObjectPath *affected_op; CMPIObjectPath *ind_op; @@ -179,13 +157,13 @@ static bool _do_indication(const CMPIBro ind = get_typed_instance(broker, prefix, ind_type_name, - ns); + args->ns); /* Generally report errors and hope to continue, since we have no one to actually return status to. */ if (ind == NULL) { CU_DEBUG("Failed to create ind, type '%s:%s_%s'", - ns, + args->ns, prefix, ind_type_name); ret = false; @@ -218,10 +196,7 @@ static bool _do_indication(const CMPIBro CU_DEBUG("Delivering Indication: %s", CMGetCharPtr(CMObjectPathToString(ind_op, NULL))); - CBDeliverIndication(broker, - ctx, - ns, - ind); + stdi_deliver(broker, ctx, args, ind); CU_DEBUG("Delivered"); out: @@ -261,7 +236,7 @@ static bool async_ind(CMPIContext *conte int ind_type, struct dom_xml prev_dom, char *prefix, - char *ns) + struct ind_args *args) { bool rc; char *name = NULL; @@ -271,7 +246,7 @@ static bool async_ind(CMPIContext *conte affected_inst = get_typed_instance(_BROKER, prefix, "ComputerSystem", - ns); + args->ns); name = sys_name_from_xml(prev_dom.xml); CU_DEBUG("Name for system: '%s'", name); @@ -298,7 +273,7 @@ static bool async_ind(CMPIContext *conte (CMPIValue *)prev_dom.uuid, CMPI_chars); rc = _do_indication(_BROKER, context, affected_inst, - ind_type, type_name, prefix, ns); + ind_type, type_name, prefix, args); out: free(name); @@ -317,7 +292,6 @@ static CMPI_THREAD_RETURN lifecycle_thre struct dom_xml *prev_xml = NULL; virConnectPtr conn; char *prefix = class_prefix_name(args->classname); - char *ns = args->ns; conn = connect_by_classname(_BROKER, args->classname, &s); if (conn == NULL) { @@ -358,7 +332,7 @@ static CMPI_THREAD_RETURN lifecycle_thre res = dom_in_list(cur_xml[i].uuid, prev_count, prev_xml); if (!res) async_ind(context, conn, CS_CREATED, - cur_xml[i], prefix, ns); + cur_xml[i], prefix, args); } @@ -366,14 +340,14 @@ static CMPI_THREAD_RETURN lifecycle_thre res = dom_in_list(prev_xml[i].uuid, cur_count, cur_xml); if (!res) async_ind(context, conn, CS_DELETED, - prev_xml[i], prefix, ns); + prev_xml[i], prefix, args); } for (i = 0; i < prev_count; i++) { res = dom_changed(prev_xml[i], cur_xml, cur_count); if (res) { async_ind(context, conn, CS_MODIFIED, - prev_xml[i], prefix, ns); + prev_xml[i], prefix, args); } free_dom_xml(prev_xml[i]); @@ -393,7 +367,7 @@ static CMPI_THREAD_RETURN lifecycle_thre out: pthread_mutex_unlock(&lifecycle_mutex); - free_ind_args(&args); + stdi_free_ind_args(&args); free(prefix); virConnectClose(conn); @@ -411,7 +385,10 @@ static CMPIStatus ActivateFilter(CMPIInd { CU_DEBUG("ActivateFilter"); CMPIStatus s = {CMPI_RC_OK, NULL}; + struct std_indication_ctx *_ctx; struct ind_args *args = malloc(sizeof(struct ind_args)); + + _ctx = (struct std_indication_ctx *)mi->hdl; if (CMIsNullObject(op)) { cu_statusf(_BROKER, &s, @@ -421,6 +398,7 @@ static CMPIStatus ActivateFilter(CMPIInd } args->ns = strdup(NAMESPACE(op)); args->classname = strdup(CLASSNAME(op)); + args->_ctx = _ctx; if (lifecycle_thread_id == 0) { args->context = CBPrepareAttachThread(_BROKER, ctx); @@ -451,8 +429,6 @@ static _EI_RTYPE EnableIndications(CMPII lifecycle_enabled = true; pthread_mutex_unlock(&lifecycle_mutex); - CU_DEBUG("ComputerSystemIndication enabled"); - _EI_RET(); } @@ -463,8 +439,6 @@ static _EI_RTYPE DisableIndications(CMPI lifecycle_enabled = false; pthread_mutex_unlock(&lifecycle_mutex); - CU_DEBUG("ComputerSystemIndication disabled"); - _EI_RET(); } @@ -478,17 +452,34 @@ static struct std_indication_handler csi static struct std_indication_handler csi = { .raise_fn = NULL, .trigger_fn = trigger_indication, + .activate_fn = ActivateFilter, + .deactivate_fn = DeActivateFilter, + .enable_fn = EnableIndications, + .disable_fn = DisableIndications, }; + +DECLARE_FILTER(xen_created, "Xen_ComputerSystemCreatedIndication"); +DECLARE_FILTER(xen_deleted, "Xen_ComputerSystemDeletedIndication"); +DECLARE_FILTER(xen_modified, "Xen_ComputerSystemModifiedIndication"); + +static struct std_ind_filter *filters[] = { + &xen_created, + &xen_deleted, + &xen_modified, + NULL, +}; + DEFAULT_IND_CLEANUP(); DEFAULT_AF(); DEFAULT_MP(); STDI_IndicationMIStub(, - Virt_ComputerSystemIndication, + Virt_ComputerSystemIndicationProvider, _BROKER, libvirt_cim_init(), - &csi); + &csi, + filters); /* * Local Variables:

JG> +DECLARE_FILTER(xen_created, "Xen_ComputerSystemCreatedIndication"); JG> +DECLARE_FILTER(xen_deleted, "Xen_ComputerSystemDeletedIndication"); JG> +DECLARE_FILTER(xen_modified, "Xen_ComputerSystemModifiedIndication"); No KVM love? I guess we need a follow-on patch to this to make the thread and everything else aware of KVM domains... -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

Dan Smith wrote:
JG> +DECLARE_FILTER(xen_created, "Xen_ComputerSystemCreatedIndication"); JG> +DECLARE_FILTER(xen_deleted, "Xen_ComputerSystemDeletedIndication"); JG> +DECLARE_FILTER(xen_modified, "Xen_ComputerSystemModifiedIndication");
No KVM love?
I guess we need a follow-on patch to this to make the thread and everything else aware of KVM domains...
Yea, I noticed that we don't really do anything with KVM in all of that, so I figured it would all get taken care of at once. -- -Jay
participants (2)
-
Dan Smith
-
Jay Gagnon