[PATCH 0 of 6] (#2) Add resource indication feature.

This patch adds feature to raise indications when resource(s) are added/deleted or modified. Signed-off-by: Sharad Mishra <snmishra@us.ibm.com>

# HG changeset patch # User snmishra@us.ibm.com # Date 1252684847 25200 # Node ID 92570a0539103628c8ccf0166983e9d85bb7431d # Parent f4e1a60c1d64888c6f8e53c9ed4ea15651825a69 Add resource indication feature Makefile changes. MOF and Registration files for the resource indication provider were added. Changes were made to src/Makefile.am to build resource indication provider. Signed-off-by: Sharad Mishra <snmishra@us.ibm.com> diff -r f4e1a60c1d64 -r 92570a053910 Makefile.am --- a/Makefile.am Fri Sep 04 14:12:46 2009 -0700 +++ b/Makefile.am Fri Sep 11 09:00:47 2009 -0700 @@ -27,6 +27,7 @@ schema/RegisteredProfile.mof \ schema/ElementConformsToProfile.mof \ schema/ComputerSystemIndication.mof \ + schema/ResourceAllocationSettingDataIndication.mof \ schema/ComputerSystemMigrationIndication.mof \ schema/Virt_ResourceAllocationSettingData.mof \ schema/ResourceAllocationSettingData.mof \ @@ -101,6 +102,7 @@ schema/DiskPool.registration \ schema/HostedResourcePool.registration \ schema/ComputerSystemIndication.registration \ + schema/ResourceAllocationSettingDataIndication.registration \ schema/ComputerSystemMigrationIndication.registration \ schema/ResourceAllocationSettingData.registration \ schema/ResourcePoolConfigurationService.registration \ diff -r f4e1a60c1d64 -r 92570a053910 src/Makefile.am --- a/src/Makefile.am Fri Sep 04 14:12:46 2009 -0700 +++ b/src/Makefile.am Fri Sep 11 09:00:47 2009 -0700 @@ -48,6 +48,7 @@ libVirt_VirtualSystemSnapshotServiceCapabilities.la \ libVirt_SystemDevice.la \ libVirt_ComputerSystemIndication.la \ + libVirt_ResourceAllocationSettingDataIndication.la \ libVirt_ComputerSystemMigrationIndication.la \ libVirt_VirtualSystemManagementCapabilities.la \ libVirt_AllocationCapabilities.la \ @@ -86,6 +87,10 @@ libVirt_ComputerSystemIndication_la_SOURCES = Virt_ComputerSystemIndication.c libVirt_ComputerSystemIndication_la_LIBADD = -lVirt_ComputerSystem -lVirt_HostSystem -lpthread -lrt +libVirt_ResourceAllocationSettingDataIndication_la_DEPENDENCIES = libVirt_ComputerSystem.la +libVirt_ResourceAllocationSettingDataIndication_la_SOURCES = Virt_ResourceAllocationSettingDataIndication.c +libVirt_ResourceAllocationSettingDataIndication_la_LIBADD = -lVirt_ComputerSystem + libVirt_ComputerSystemMigrationIndication_la_DEPENDENCIES = libVirt_ComputerSystem.la libVirt_ComputerSystemMigrationIndication_la_SOURCES = Virt_ComputerSystemMigrationIndication.c libVirt_ComputerSystemMigrationIndication_la_LIBADD = -lVirt_ComputerSystem

# HG changeset patch # User snmishra@us.ibm.com # Date 1252684847 25200 # Node ID 44e2c3144f199c7e552e3f5066186289b424b5db # Parent 92570a0539103628c8ccf0166983e9d85bb7431d Modify Virt_CS so set_source-inst_props() can be used by other providers. Signed-off-by: Sharad Mishra <snmishra@us.ibm.com> diff -r 92570a053910 -r 44e2c3144f19 src/Virt_ComputerSystemIndication.c --- a/src/Virt_ComputerSystemIndication.c Fri Sep 11 09:00:47 2009 -0700 +++ b/src/Virt_ComputerSystemIndication.c Fri Sep 11 09:00:47 2009 -0700 @@ -192,9 +192,9 @@ return ret; } -static void set_source_inst_props(const CMPIBroker *broker, +void set_source_inst_props(const CMPIBroker *broker, const CMPIContext *context, - CMPIObjectPath *ref, + const CMPIObjectPath *ref, CMPIInstance *ind) { const char *host; diff -r 92570a053910 -r 44e2c3144f19 src/Virt_ComputerSystemIndication.h --- a/src/Virt_ComputerSystemIndication.h Fri Sep 11 09:00:47 2009 -0700 +++ b/src/Virt_ComputerSystemIndication.h Fri Sep 11 09:00:47 2009 -0700 @@ -29,6 +29,10 @@ const CMPIObjectPath *newsystem, char *type); +void set_source_inst_props(const CMPIBroker *broker, + const CMPIContext *context, + const CMPIObjectPath *ref, + CMPIInstance *ind); #endif /*

# HG changeset patch # User snmishra@us.ibm.com # Date 1252684847 25200 # Node ID 74607c71855e6baeeb49bbc134b773acc39675fb # Parent 44e2c3144f199c7e552e3f5066186289b424b5db Modify Virt_RASD so that rasd_from_vdev() can be used by other providers. Signed-off-by: Sharad Mishra <snmishra@us.ibm.com> diff -r 44e2c3144f19 -r 74607c71855e src/Virt_RASD.c --- a/src/Virt_RASD.c Fri Sep 11 09:00:47 2009 -0700 +++ b/src/Virt_RASD.c Fri Sep 11 09:00:47 2009 -0700 @@ -368,7 +368,7 @@ return s; } -static CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, +CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, struct virt_device *dev, const char *host, const CMPIObjectPath *ref, diff -r 44e2c3144f19 -r 74607c71855e src/Virt_RASD.h --- a/src/Virt_RASD.h Fri Sep 11 09:00:47 2009 -0700 +++ b/src/Virt_RASD.h Fri Sep 11 09:00:47 2009 -0700 @@ -66,6 +66,13 @@ const uint16_t type, const char *host, struct virt_device **list); + +CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, + struct virt_device *dev, + const char *host, + const CMPIObjectPath *ref, + const char **properties); + #endif /*

# HG changeset patch # User snmishra@us.ibm.com # Date 1252684847 25200 # Node ID 25932f2392c13145502b7e45baadffc0d4dff431 # Parent 74607c71855e6baeeb49bbc134b773acc39675fb (#2) Support for resource indication was added to Virt_VirtualSystemManagementService #2 - Took care of some coding style issues - Added debug message when failed to get InstanceID of an instance in _update_resources_for function. - Broke down _update_resources_for function into two functions for better readability. - Added "RES_IND_" to CREATED, DELETED and MODIFIED constants. - Added check and debug message for prev_inst returned in get_previous_instance(). Code added to call resource indication when resources are added or deleted or modified. Signed-off-by: Sharad Mishra <snmishra@us.ibm.com> diff -r 74607c71855e -r 25932f2392c1 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Fri Sep 11 09:00:47 2009 -0700 +++ b/src/Virt_VirtualSystemManagementService.c Fri Sep 11 09:00:47 2009 -0700 @@ -63,6 +63,9 @@ #define BRIDGE_TYPE "bridge" #define NETWORK_TYPE "network" #define USER_TYPE "user" +#define RASD_IND_CREATED "ResourceAllocationSettingDataCreatedIndication" +#define RASD_IND_DELETED "ResourceAllocationSettingDataDeletedIndication" +#define RASD_IND_MODIFIED "ResourceAllocationSettingDataModifiedIndication" const static CMPIBroker *_BROKER; @@ -442,7 +445,7 @@ ret = cu_get_str_prop(inst, "VirtualSystemIdentifier", &val); if (ret != CMPI_RC_OK) goto out; - + free(domain->name); domain->name = strdup(val); @@ -1416,7 +1419,67 @@ return s; } -static CMPIInstance *create_system(CMPIInstance *vssd, +static CMPIStatus raise_rasd_indication(const CMPIContext *context, + const char *base_type, + CMPIInstance *prev_inst, + const CMPIObjectPath *ref, + struct inst_list *list) +{ + char *type; + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *instc = NULL; + CMPIInstance *ind = NULL; + CMPIObjectPath *op = NULL; + int i; + + CU_DEBUG("raise_rasd_indication"); + + type = get_typed_class(CLASSNAME(ref), base_type); + ind = get_typed_instance(_BROKER, + CLASSNAME(ref), + base_type, + NAMESPACE(ref)); + if (ind == NULL) { + CU_DEBUG("Failed to get indication instance"); + s.rc = CMPI_RC_ERR_FAILED; + goto out; + } + + /* PreviousInstance is set only for modify case. */ + if (prev_inst != NULL) + CMSetProperty(ind, + "PreviousInstance", + (CMPIValue *)&prev_inst, + CMPI_instance); + + for (i = 0; i < list->cur; i++) { + instc = list->list[i]; + op = CMGetObjectPath(instc, NULL); + CMPIString *str = CMGetClassName(op, NULL); + + CU_DEBUG("class name is %s\n", CMGetCharsPtr(str, NULL)); + + CMSetProperty(ind, + "SourceInstance", + (CMPIValue *)&instc, + CMPI_instance); + set_source_inst_props(_BROKER, context, ref, ind); + + s = stdi_raise_indication(_BROKER, + context, + type, + NAMESPACE(ref), + ind); + } + + out: + free(type); + return s; + +} + +static CMPIInstance *create_system(const CMPIContext *context, + CMPIInstance *vssd, CMPIArray *resources, const CMPIObjectPath *ref, const CMPIObjectPath *refconf, @@ -1427,9 +1490,13 @@ const char *msg = NULL; virConnectPtr conn = NULL; virDomainPtr dom = NULL; + struct inst_list list; + const char *props[] = {NULL}; struct domain *domain = NULL; + inst_list_init(&list); + if (refconf != NULL) { *s = get_reference_domain(&domain, ref, refconf); if (s->rc != CMPI_RC_OK) @@ -1477,14 +1544,35 @@ CU_DEBUG("System XML:\n%s", xml); inst = connect_and_create(xml, ref, s); - if (inst != NULL) + if (inst != NULL) { update_dominfo(domain, CLASSNAME(ref)); + *s = enum_rasds(_BROKER, + ref, + domain->name, + CIM_RES_TYPE_ALL, + props, + &list); + + if (s->rc != CMPI_RC_OK) { + CU_DEBUG("Failed to enumerate rasd\n"); + goto out; + } + + raise_rasd_indication(context, + RASD_IND_CREATED, + NULL, + ref, + &list); + } + + out: cleanup_dominfo(&domain); free(xml); virDomainFree(dom); virConnectClose(conn); + inst_list_free(&list); return inst; } @@ -1530,7 +1618,7 @@ if (s.rc != CMPI_RC_OK) goto out; - sys = create_system(vssd, res, reference, refconf, &s); + sys = create_system(context, vssd, res, reference, refconf, &s); if (sys == NULL) goto out; @@ -1564,12 +1652,15 @@ CMPIObjectPath *sys; virConnectPtr conn = NULL; virDomainPtr dom = NULL; + struct inst_list list; + const char *props[] = {NULL}; + inst_list_init(&list); conn = connect_by_classname(_BROKER, CLASSNAME(reference), &status); if (conn == NULL) { - rc = -1; + rc = IM_RC_NOT_SUPPORTED; goto error; } @@ -1580,6 +1671,18 @@ if (dom_name == NULL) goto error; + status = enum_rasds(_BROKER, + reference, + dom_name, + CIM_RES_TYPE_ALL, + props, + &list); + + if (status.rc != CMPI_RC_OK) { + CU_DEBUG("Failed to enumerate rasd"); + goto error; + } + dom = virDomainLookupByName(conn, dom_name); if (dom == NULL) { CU_DEBUG("No such domain `%s'", dom_name); @@ -1605,11 +1708,17 @@ error: if (rc == IM_RC_SYS_NOT_FOUND) - virt_set_status(_BROKER, &status, + virt_set_status(_BROKER, + &status, CMPI_RC_ERR_NOT_FOUND, conn, "Referenced domain `%s' does not exist", dom_name); + else if (rc == IM_RC_NOT_SUPPORTED) + virt_set_status(_BROKER, &status, + CMPI_RC_ERR_NOT_FOUND, + conn, + "Unable to connect to libvirt"); else if (rc == IM_RC_FAILED) virt_set_status(_BROKER, &status, CMPI_RC_ERR_NOT_FOUND, @@ -1617,6 +1726,11 @@ "Unable to retrieve domain name"); else if (rc == IM_RC_OK) { status = (CMPIStatus){CMPI_RC_OK, NULL}; + raise_rasd_indication(context, + RASD_IND_DELETED, + NULL, + reference, + &list); trigger_indication(context, "ComputerSystemDeletedIndication", reference); @@ -1625,7 +1739,7 @@ virDomainFree(dom); virConnectClose(conn); CMReturnData(results, &rc, CMPI_uint32); - + inst_list_free(&list); return status; } @@ -2071,7 +2185,51 @@ return s; } -static CMPIStatus _update_resources_for(const CMPIObjectPath *ref, +static CMPIInstance *get_previous_instance(struct domain *dominfo, + const CMPIObjectPath *ref, + uint16_t type, + const char *devid) +{ + CMPIStatus s; + const char *props[] = {NULL}; + const char *inst_id; + struct inst_list list; + CMPIInstance *prev_inst = NULL; + int i, ret; + + inst_list_init(&list); + s = enum_rasds(_BROKER, ref, dominfo->name, type, props, &list); + if (s.rc != CMPI_RC_OK) { + CU_DEBUG("Failed to enumerate rasd"); + goto out; + } + + for(i = 0; i < list.cur; i++) { + prev_inst = list.list[i]; + ret = cu_get_str_prop(prev_inst, + "InstanceID", + &inst_id); + + if (ret != CMPI_RC_OK) { + CU_DEBUG("Cannot get InstanceID ... ignoring"); + continue; + } + + if (STREQ(inst_id, get_fq_devid(dominfo->name, (char *)devid))) + break; + } + + if (prev_inst == NULL) + CU_DEBUG("PreviousInstance is NULL"); + + out: + inst_list_free(&list); + + return prev_inst; +} + +static CMPIStatus _update_resources_for(const CMPIContext *context, + const CMPIObjectPath *ref, virDomainPtr dom, const char *devid, CMPIInstance *rasd, @@ -2081,8 +2239,12 @@ struct domain *dominfo = NULL; uint16_t type; char *xml = NULL; + const char *indication; CMPIObjectPath *op; + struct inst_list list; + CMPIInstance *prev_inst = NULL; + inst_list_init(&list); if (!get_dominfo(dom, &dominfo)) { virt_set_status(_BROKER, &s, CMPI_RC_ERR_FAILED, @@ -2116,6 +2278,27 @@ if (xml != NULL) { CU_DEBUG("New XML:\n%s", xml); connect_and_create(xml, ref, &s); + + if (func == &resource_add) { + indication = strdup(RASD_IND_CREATED); + } + else if (func == &resource_del) { + indication = strdup(RASD_IND_DELETED); + } + else { + indication = strdup(RASD_IND_MODIFIED); + prev_inst = get_previous_instance(dominfo, ref, type, devid); + } + + if (inst_list_add(&list, rasd) == 0) { + CU_DEBUG("Unable to add RASD instance to the list\n"); + goto out; + } + raise_rasd_indication(context, + indication, + prev_inst, + ref, + &list); } else { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, @@ -2125,6 +2308,7 @@ out: cleanup_dominfo(&dominfo); free(xml); + inst_list_free(&list); return s; } @@ -2153,7 +2337,8 @@ return s; } -static CMPIStatus _update_resource_settings(const CMPIObjectPath *ref, +static CMPIStatus _update_resource_settings(const CMPIContext *context, + const CMPIObjectPath *ref, const char *domain, CMPIArray *resources, const CMPIResult *results, @@ -2208,9 +2393,14 @@ goto end; } - s = _update_resources_for(ref, dom, devid, inst, func); + s = _update_resources_for(context, + ref, + dom, + devid, + inst, + func); - end: + end: free(name); free(devid); virDomainFree(dom); @@ -2310,7 +2500,9 @@ return s; } - if (cu_get_ref_arg(argsin, "AffectedConfiguration", &sys) != CMPI_RC_OK) { + if (cu_get_ref_arg(argsin, + "AffectedConfiguration", + &sys) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_INVALID_PARAMETER, "Missing AffectedConfiguration parameter"); @@ -2324,11 +2516,13 @@ return s; } - s = _update_resource_settings(reference, + s = _update_resource_settings(context, + reference, domain, arr, results, resource_add); + free(domain); return s; @@ -2351,7 +2545,8 @@ return s; } - return _update_resource_settings(reference, + return _update_resource_settings(context, + reference, NULL, arr, results, @@ -2384,7 +2579,8 @@ if (s.rc != CMPI_RC_OK) goto out; - s = _update_resource_settings(reference, + s = _update_resource_settings(context, + reference, NULL, resource_arr, results,

# HG changeset patch # User Sharad Mishra <snmishra@us.ibm.com> # Date 1253031557 25200 # Node ID cbcf788b362077e7ed289895dc1ce851e405b1ae # Parent 25932f2392c13145502b7e45baadffc0d4dff431 Add the mof and reg files needed to register the resource indication provider Signed-off-by: Sharad Mishra <snmishra@us.ibm.com> diff -r 25932f2392c1 -r cbcf788b3620 schema/ResourceAllocationSettingDataIndication.mof --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/ResourceAllocationSettingDataIndication.mof Tue Sep 15 09:19:17 2009 -0700 @@ -0,0 +1,66 @@ +// Copyright IBM Corp. 2007 + +[Description ("Xen_ResourceAllocationSettingData created"), + Provider("cmpi::Virt_ResourceAllocationSettingDataIndication") +] +class Xen_ResourceAllocationSettingDataCreatedIndication : CIM_InstCreation +{ +}; + +[Description ("Xen_ResourceAllocationSettingData deleted"), + Provider("cmpi::Virt_ResourceAllocationSettingDataIndication") +] +class Xen_ResourceAllocationSettingDataDeletedIndication : CIM_InstDeletion +{ +}; + +[Description ("Xen_ResourceAllocationSettingData modified"), + Provider("cmpi::Virt_ResourceAllocationSettingDataIndication") +] +class Xen_ResourceAllocationSettingDataModifiedIndication : CIM_InstModification +{ +}; + + +[Description ("KVM_ResourceAllocationSettingData created"), + Provider("cmpi::Virt_ResourceAllocationSettingDataIndication") +] +class KVM_ResourceAllocationSettingDataCreatedIndication : CIM_InstCreation +{ +}; + +[Description ("KVM_ResourceAllocationSettingData deleted"), + Provider("cmpi::Virt_ResourceAllocationSettingDataIndication") +] +class KVM_ResourceAllocationSettingDataDeletedIndication : CIM_InstDeletion +{ +}; + +[Description ("KVM_ResourceAllocationSettingData modified"), + Provider("cmpi::Virt_ResourceAllocationSettingDataIndication") +] +class KVM_ResourceAllocationSettingDataModifiedIndication : CIM_InstModification +{ +}; + + +[Description ("LXC_ResourceAllocationSettingData created"), + Provider("cmpi::Virt_ResourceAllocationSettingDataIndication") +] +class LXC_ResourceAllocationSettingDataCreatedIndication : CIM_InstCreation +{ +}; + +[Description ("LXC_ResourceAllocationSettingData deleted"), + Provider("cmpi::Virt_ResourceAllocationSettingDataIndication") +] +class LXC_ResourceAllocationSettingDataDeletedIndication : CIM_InstDeletion +{ +}; + +[Description ("LXC_ResourceAllocationSettingData modified"), + Provider("cmpi::Virt_ResourceAllocationSettingDataIndication") +] +class LXC_ResourceAllocationSettingDataModifiedIndication : CIM_InstModification +{ +}; diff -r 25932f2392c1 -r cbcf788b3620 schema/ResourceAllocationSettingDataIndication.registration --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/ResourceAllocationSettingDataIndication.registration Tue Sep 15 09:19:17 2009 -0700 @@ -0,0 +1,11 @@ +# Copyright IBM Corp. 2007 +# Classname Namespace ProviderName ProviderModule ProviderTypes +Xen_ResourceAllocationSettingDataCreatedIndication root/virt Virt_ResourceAllocationSettingDataIndicationProvider Virt_ResourceAllocationSettingDataIndication indication method +Xen_ResourceAllocationSettingDataDeletedIndication root/virt Virt_ResourceAllocationSettingDataIndicationProvider Virt_ResourceAllocationSettingDataIndication indication method +Xen_ResourceAllocationSettingDataModifiedIndication root/virt Virt_ResourceAllocationSettingDataIndicationProvider Virt_ResourceAllocationSettingDataIndication indication method +KVM_ResourceAllocationSettingDataCreatedIndication root/virt Virt_ResourceAllocationSettingDataIndicationProvider Virt_ResourceAllocationSettingDataIndication indication method +KVM_ResourceAllocationSettingDataDeletedIndication root/virt Virt_ResourceAllocationSettingDataIndicationProvider Virt_ResourceAllocationSettingDataIndication indication method +KVM_ResourceAllocationSettingDataModifiedIndication root/virt Virt_ResourceAllocationSettingDataIndicationProvider Virt_ResourceAllocationSettingDataIndication indication method +LXC_ResourceAllocationSettingDataCreatedIndication root/virt Virt_ResourceAllocationSettingDataIndicationProvider Virt_ResourceAllocationSettingDataIndication indication method +LXC_ResourceAllocationSettingDataDeletedIndication root/virt Virt_ResourceAllocationSettingDataIndicationProvider Virt_ResourceAllocationSettingDataIndication indication method +LXC_ResourceAllocationSettingDataModifiedIndication root/virt Virt_ResourceAllocationSettingDataIndicationProvider Virt_ResourceAllocationSettingDataIndication indication method

# HG changeset patch # User Sharad Mishra <snmishra@us.ibm.com> # Date 1253031558 25200 # Node ID 335b5e307df79e4e4cfdfc15d13424c759da8b53 # Parent cbcf788b362077e7ed289895dc1ce851e405b1ae Add resource indication provider. Signed-off-by: Sharad Mishra <snmishra@us.ibm.com> diff -r cbcf788b3620 -r 335b5e307df7 src/Virt_ResourceAllocationSettingDataIndication.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_ResourceAllocationSettingDataIndication.c Tue Sep 15 09:19:18 2009 -0700 @@ -0,0 +1,155 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Sharad Mishra <snmishra@us.ibm.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include <stdio.h> +#include <string.h> + +#include <cmpidt.h> +#include <cmpift.h> +#include <cmpimacs.h> + +#include <libvirt/libvirt.h> +#include <libcmpiutil/libcmpiutil.h> +#include <libcmpiutil/std_indication.h> +#include <misc_util.h> +#include <cs_util.h> + +static const CMPIBroker *_BROKER; + +DECLARE_FILTER(xen_created, + "Xen_ResourceAllocationSettingDataCreatedIndication"); +DECLARE_FILTER(xen_deleted, + "Xen_ResourceAllocationSettingDataDeletedIndication"); +DECLARE_FILTER(xen_modified, + "Xen_ResourceAllocationSettingDataModifiedIndication"); +DECLARE_FILTER(kvm_created, + "KVM_ResourceAllocationSettingDataCreatedIndication"); +DECLARE_FILTER(kvm_deleted, + "KVM_ResourceAllocationSettingDataDeletedIndication"); +DECLARE_FILTER(kvm_modified, + "KVM_ResourceAllocationSettingDataModifiedIndication"); +DECLARE_FILTER(lxc_created, + "LXC_ResourceAllocationSettingDataCreatedIndication"); +DECLARE_FILTER(lxc_deleted, + "LXC_ResourceAllocationSettingDataDeletedIndication"); +DECLARE_FILTER(lxc_modified, + "LXC_ResourceAllocationSettingDataModifiedIndication"); + +static struct std_ind_filter *filters[] = { + &xen_created, + &xen_deleted, + &xen_modified, + &kvm_created, + &kvm_deleted, + &kvm_modified, + &lxc_created, + &lxc_deleted, + &lxc_modified, + NULL, +}; + + +static CMPIStatus raise_indication(const CMPIBroker *broker, + const CMPIContext *ctx, + const CMPIInstance *ind) +{ + struct std_indication_ctx *_ctx = NULL; + CMPIStatus s = {CMPI_RC_OK, NULL}; + struct ind_args *args = NULL; + CMPIObjectPath *ref = NULL; + + _ctx = malloc(sizeof(struct std_indication_ctx)); + if (_ctx == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to allocate indication context"); + goto out; + } + + _ctx->brkr = broker; + _ctx->handler = NULL; + _ctx->filters = filters; + _ctx->enabled = 1; + + args = malloc(sizeof(struct ind_args)); + if (args == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to allocate ind_args"); + goto out; + } + + ref = CMGetObjectPath(ind, &s); + if (ref == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Got a null object path"); + goto out; + } + + /* FIXME: This is a Pegasus work around. Pegsus loses the namespace + when an ObjectPath is pulled from an instance */ + + + CMSetNameSpace(ref, "root/virt"); + args->ns = strdup(NAMESPACE(ref)); + args->classname = strdup(CLASSNAME(ref)); + args->_ctx = _ctx; + + s = stdi_deliver(broker, ctx, args, (CMPIInstance *)ind); + if (s.rc == CMPI_RC_OK) { + CU_DEBUG("Indication delivered"); + } else { + CU_DEBUG("Not delivered: %s", CMGetCharPtr(s.msg)); + } + + out: + return s; +} + +static struct std_indication_handler rasdi = { + .raise_fn = raise_indication, + .trigger_fn = NULL, + .activate_fn = NULL, + .deactivate_fn = NULL, + .enable_fn = NULL, + .disable_fn = NULL, +}; + +DEFAULT_IND_CLEANUP(); +DEFAULT_AF(); +DEFAULT_MP(); + +STDI_IndicationMIStub(, + Virt_ResourceAllocationSettingDataIndicationProvider, + _BROKER, + libvirt_cim_init(), + &rasdi, + filters); + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */
participants (1)
-
Sharad Mishra