os-cmpi-xen

annotate src/Xen_ProcessorPool.c @ 32:75b18359b74d

Fixed a few compilation warnings, fixed 'make dist' target, and updated release tag in configure.ac to 0.1.1.

Signed-off-by: Jim Fehlig <jfehlig@novell.com>
author jfehlig@jfehlig3.provo.novell.com
date Tue Oct 24 16:51:30 2006 -0600 (2006-10-24)
parents 33d4316c01a2
children 26f10941718e
rev   line source
jbulpin@0 1 // Copyright (C) 2006 IBM Corporation
jbulpin@0 2 //
jbulpin@0 3 // This library is free software; you can redistribute it and/or
jbulpin@0 4 // modify it under the terms of the GNU Lesser General Public
jbulpin@0 5 // License as published by the Free Software Foundation; either
jbulpin@0 6 // version 2.1 of the License, or (at your option) any later version.
jbulpin@0 7 //
jbulpin@0 8 // This library is distributed in the hope that it will be useful,
jbulpin@0 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
jbulpin@0 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
jbulpin@0 11 // Lesser General Public License for more details.
jbulpin@0 12 //
jbulpin@0 13 // You should have received a copy of the GNU Lesser General Public
jbulpin@0 14 // License along with this library; if not, write to the Free Software
jbulpin@0 15 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
jbulpin@0 16 // ============================================================================
jbulpin@0 17 // Authors: Dr. Gareth S. Bestor, <bestor@us.ibm.com>
jfehlig@25 18 // Jim Fehlig, <jfehlig@novell.com>
jbulpin@0 19 // Contributors:
jbulpin@0 20 // Description:
jbulpin@0 21 // ============================================================================
jbulpin@0 22
jfehlig@32 23 #include <string.h>
jfehlig@32 24
jbulpin@0 25 /* Include the required CMPI data types, function headers, and macros */
jbulpin@0 26 #include "cmpidt.h"
jbulpin@0 27 #include "cmpift.h"
jbulpin@0 28 #include "cmpimacs.h"
jbulpin@0 29
jfehlig@25 30 #include "provider_common.h"
jbulpin@0 31
jbulpin@0 32 // ----------------------------------------------------------------------------
jbulpin@0 33 // COMMON GLOBAL VARIABLES
jbulpin@0 34 // ----------------------------------------------------------------------------
jbulpin@0 35
jbulpin@0 36 /* Handle to the CIM broker. Initialized when the provider lib is loaded. */
jfehlig@31 37 static const CMPIBroker *_BROKER;
jbulpin@0 38
jbulpin@0 39 /* Include utility functions */
jbulpin@0 40 #include "cmpiutil.h"
jbulpin@0 41
jbulpin@0 42 /* Include _SBLIM_TRACE() logging support */
jbulpin@0 43 #include "cmpitrace.h"
jbulpin@0 44
jbulpin@0 45 /* Include the abstract resource access functions and abstracted _RESOURCES and _RESOURCE data types. */
jbulpin@0 46 #include "Xen_ProcessorPool_Resource.h"
jbulpin@0 47
jbulpin@0 48
jbulpin@0 49 // ============================================================================
jbulpin@0 50 // CMPI INSTANCE PROVIDER FUNCTION TABLE
jbulpin@0 51 // ============================================================================
jbulpin@0 52
jbulpin@0 53 // ----------------------------------------------------------------------------
jbulpin@0 54 // Info for the class supported by the instance provider
jbulpin@0 55 // ----------------------------------------------------------------------------
jbulpin@0 56
jbulpin@0 57 /* Name of the class implemented by this instance provider. */
jbulpin@0 58 /*** CUSTOMIZE FOR EACH PROVIDER ***/
jbulpin@0 59 static char * _CLASSNAME = "Xen_ProcessorPool";
jbulpin@0 60
jbulpin@0 61 /* NULL terminated list of key properties of this class. */
jbulpin@0 62 /*** CUSTOMIZE FOR EACH PROVIDER ***/
jfehlig@14 63 const static char * _KEYNAMES[] = {"InstanceID", NULL};
jbulpin@0 64
jbulpin@0 65 // ----------------------------------------------------------------------------
jbulpin@0 66 // Cleanup()
jbulpin@0 67 // Perform any necessary cleanup immediately before this provider is unloaded.
jbulpin@0 68 // ----------------------------------------------------------------------------
jbulpin@0 69 static CMPIStatus Cleanup(
jbulpin@0 70 CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */
jfehlig@31 71 const CMPIContext * context, /* [in] Additional context info, if any. */
jfehlig@31 72 CMPIBoolean terminating) /* [in] True if MB is terminating */
jbulpin@0 73 {
jbulpin@0 74 CMPIStatus status = { CMPI_RC_OK, NULL }; /* Return status of CIM operations. */
jbulpin@0 75
jbulpin@0 76 _SBLIM_ENTER("Cleanup");
jbulpin@0 77 _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
jbulpin@0 78 _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
jbulpin@0 79
jbulpin@0 80 /* Nothing needs to be done for cleanup. */
jbulpin@0 81 _SBLIM_RETURNSTATUS(status);
jbulpin@0 82 }
jbulpin@0 83
jbulpin@0 84 // ----------------------------------------------------------------------------
jbulpin@0 85 // EnumInstanceNames()
jbulpin@0 86 // Return a list of all the instances names (return their object paths only).
jbulpin@0 87 // ----------------------------------------------------------------------------
jbulpin@0 88 static CMPIStatus EnumInstanceNames(
jbulpin@0 89 CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */
jfehlig@31 90 const CMPIContext * context, /* [in] Additional context info, if any. */
jfehlig@31 91 const CMPIResult * results, /* [out] Results of this operation. */
jfehlig@31 92 const CMPIObjectPath * reference) /* [in] Contains target namespace and classname. */
jbulpin@0 93 {
jbulpin@0 94 CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */
jfehlig@25 95 _RESOURCES * resources = NULL; /* Handle to the list of system resources. */
jbulpin@0 96 _RESOURCE * resource; /* Handle to each system resource. */
jbulpin@0 97 char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
jbulpin@0 98 int found = 0; /* Found any instances? */
jbulpin@0 99
jbulpin@0 100 _SBLIM_ENTER("EnumInstanceNames");
jbulpin@0 101 _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
jbulpin@0 102 _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
jbulpin@0 103 _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
jbulpin@0 104 _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
jbulpin@0 105
jfehlig@25 106 if (strcmp(namespace, HOST_INSTRUMENTATION_NS) == 0) {
jfehlig@25 107 _SBLIM_TRACE(1,("--- \"%s\" is not a valid namespace for %s", namespace, _CLASSNAME));
jfehlig@25 108 goto exit;
jfehlig@25 109 }
jfehlig@25 110
jbulpin@0 111 /* Get a handle to the list of system resources. */
jbulpin@0 112 if (!Xen_ProcessorPool_getResources(&resources)) {
jbulpin@0 113 _SBLIM_TRACE(1,("--- _getResources() failed"));
jbulpin@0 114 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources");
jbulpin@0 115 goto exit;
jbulpin@0 116 }
jbulpin@0 117
jbulpin@0 118 /* Enumerate thru the list of system resources and return a CMPIInstance for each. */
jfehlig@16 119 while (Xen_ProcessorPool_getNextResource(resources, &resource, _BROKER, context)) {
jbulpin@0 120 /* Create a new CMPIInstance to store this resource. */
jbulpin@0 121 CMPIInstance * instance = _CMNewInstance(_BROKER, namespace, _CLASSNAME, &status);
jbulpin@0 122 if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instance)) {
jbulpin@0 123 _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status.msg)));
jbulpin@0 124 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIInstance");
jbulpin@0 125 goto exit;
jbulpin@0 126 }
jbulpin@0 127
jbulpin@0 128 /* Set the instance property values from the resource data. */
jbulpin@0 129 if (!Xen_ProcessorPool_setInstanceFromResource(resource, instance, _BROKER)) {
jbulpin@0 130 _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed"));
jbulpin@0 131 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data");
jbulpin@0 132 goto exit;
jbulpin@0 133 }
jbulpin@0 134
jbulpin@0 135 /* Free the resource data. */
jbulpin@0 136 if (!Xen_ProcessorPool_freeResource(resource)) {
jbulpin@0 137 _SBLIM_TRACE(1,("--- _freeResource() failed"));
jbulpin@0 138 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data");
jbulpin@0 139 goto exit;
jbulpin@0 140 }
jbulpin@0 141
jbulpin@0 142 /* Return the CMPIObjectPath for this instance. */
jbulpin@0 143 CMPIObjectPath * objectpath = CMGetObjectPath(instance, &status);
jbulpin@0 144 if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
jbulpin@0 145 _SBLIM_TRACE(1,("--- CMGetObjectPath() failed - %s", CMGetCharPtr(status.msg)));
jbulpin@0 146 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot get CMPIObjectPath for instance");
jbulpin@0 147 goto exit;
jbulpin@0 148 }
jbulpin@0 149 CMSetNameSpace(objectpath, namespace); /* Note - CMGetObjectPath() does not preserve the namespace! */
jbulpin@0 150
jbulpin@0 151 _SBLIM_TRACE(3,("--- objectpath=\"%s\"", CMGetCharPtr(CDToString(_BROKER, objectpath, NULL))));
jbulpin@0 152 CMReturnObjectPath(results, objectpath);
jbulpin@0 153 found++;
jbulpin@0 154 }
jbulpin@0 155
jbulpin@0 156 _SBLIM_TRACE(2,("--- %d object paths found", found));
jbulpin@0 157 CMReturnDone(results);
jbulpin@0 158
jbulpin@0 159 exit:
jbulpin@0 160 /* Free the list of system resources. */
jbulpin@0 161 if (!Xen_ProcessorPool_freeResources(resources)) {
jbulpin@0 162 _SBLIM_TRACE(1,("--- _freeResources() failed"));
jbulpin@0 163 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources");
jbulpin@0 164 }
jbulpin@0 165
jbulpin@0 166 _SBLIM_RETURNSTATUS(status);
jbulpin@0 167 }
jbulpin@0 168
jbulpin@0 169 // ----------------------------------------------------------------------------
jbulpin@0 170 // EnumInstances()
jbulpin@0 171 // Return a list of all the instances (return all the instance data).
jbulpin@0 172 // ----------------------------------------------------------------------------
jbulpin@0 173 static CMPIStatus EnumInstances(
jbulpin@0 174 CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */
jfehlig@31 175 const CMPIContext * context, /* [in] Additional context info, if any. */
jfehlig@31 176 const CMPIResult * results, /* [out] Results of this operation. */
jfehlig@31 177 const CMPIObjectPath * reference, /* [in] Contains target namespace and classname. */
jbulpin@0 178 const char ** properties) /* [in] List of desired properties (NULL=all). */
jbulpin@0 179 {
jbulpin@0 180 CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */
jfehlig@25 181 _RESOURCES * resources = NULL; /* Handle to the list of system resources. */
jbulpin@0 182 _RESOURCE * resource; /* Handle to each system resource. */
jbulpin@0 183 char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
jbulpin@0 184 int found = 0; /* Found any resource instances? */
jbulpin@0 185
jbulpin@0 186 _SBLIM_ENTER("EnumInstances");
jbulpin@0 187 _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
jbulpin@0 188 _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
jbulpin@0 189 _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
jbulpin@0 190 _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
jbulpin@0 191
jfehlig@25 192 if (strcmp(namespace, HOST_INSTRUMENTATION_NS) == 0) {
jfehlig@25 193 _SBLIM_TRACE(1,("--- \"%s\" is not a valid namespace for %s", namespace, _CLASSNAME));
jfehlig@25 194 goto exit;
jfehlig@25 195 }
jfehlig@25 196
jbulpin@0 197 /* Get a handle to the list of system resources. */
jbulpin@0 198 if (!Xen_ProcessorPool_getResources(&resources)) {
jbulpin@0 199 _SBLIM_TRACE(1,("--- _getResources() failed"));
jbulpin@0 200 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources");
jbulpin@0 201 goto exit;
jbulpin@0 202 }
jbulpin@0 203
jbulpin@0 204 /* Enumerate thru the list of system resources and return a CMPIInstance for each. */
jfehlig@16 205 while (Xen_ProcessorPool_getNextResource(resources, &resource, _BROKER, context)) {
jbulpin@0 206 /* Create a new CMPIInstance to store this resource. */
jbulpin@0 207 CMPIInstance * instance = _CMNewInstance(_BROKER, namespace, _CLASSNAME, &status);
jbulpin@0 208 if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instance)) {
jbulpin@0 209 _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status.msg)));
jbulpin@0 210 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIInstance");
jbulpin@0 211 goto exit;
jbulpin@0 212 }
jbulpin@0 213
jbulpin@0 214 /* Setup a filter to only return the desired properties. */
jbulpin@0 215 status = CMSetPropertyFilter(instance, properties, _KEYNAMES);
jbulpin@0 216 if (status.rc != CMPI_RC_OK) {
jbulpin@0 217 _SBLIM_TRACE(1, ("--- CMSetPropertyFilter() failed - %s", CMGetCharPtr(status.msg)));
jbulpin@0 218 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Cannot set property filter");
jbulpin@0 219 goto exit;
jbulpin@0 220 }
jbulpin@0 221
jbulpin@0 222 /* Set the instance property values from the resource data. */
jbulpin@0 223 if (!Xen_ProcessorPool_setInstanceFromResource(resource, instance, _BROKER)) {
jbulpin@0 224 _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed"));
jbulpin@0 225 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data");
jbulpin@0 226 goto exit;
jbulpin@0 227 }
jbulpin@0 228
jbulpin@0 229 /* Free the resource data. */
jbulpin@0 230 if (!Xen_ProcessorPool_freeResource(resource)) {
jbulpin@0 231 _SBLIM_TRACE(1,("--- _freeResource() failed"));
jbulpin@0 232 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data");
jbulpin@0 233 goto exit;
jbulpin@0 234 }
jbulpin@0 235
jbulpin@0 236 /* Return the CMPIInstance for this instance. */
jbulpin@0 237 _SBLIM_TRACE(3,("--- instance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, instance, NULL))));
jbulpin@0 238 CMReturnInstance(results, instance);
jbulpin@0 239 found++;
jbulpin@0 240 }
jbulpin@0 241
jbulpin@0 242 _SBLIM_TRACE(2,("--- %d instances found", found));
jbulpin@0 243 CMReturnDone(results);
jbulpin@0 244
jbulpin@0 245 exit:
jbulpin@0 246 /* Free the list of system resources. */
jbulpin@0 247 if (!Xen_ProcessorPool_freeResources(resources)) {
jbulpin@0 248 _SBLIM_TRACE(1,("--- _freeResources() failed"));
jbulpin@0 249 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources");
jbulpin@0 250 }
jbulpin@0 251
jbulpin@0 252 _SBLIM_RETURNSTATUS(status);
jbulpin@0 253 }
jbulpin@0 254
jbulpin@0 255 // ----------------------------------------------------------------------------
jbulpin@0 256 // GetInstance()
jbulpin@0 257 // Return the instance data for the specified instance only.
jbulpin@0 258 // ----------------------------------------------------------------------------
jbulpin@0 259 static CMPIStatus GetInstance(
jbulpin@0 260 CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */
jfehlig@31 261 const CMPIContext * context, /* [in] Additional context info, if any. */
jfehlig@31 262 const CMPIResult * results, /* [out] Results of this operation. */
jfehlig@31 263 const CMPIObjectPath * reference, /* [in] Contains the target namespace, classname and object path. */
jbulpin@0 264 const char ** properties) /* [in] List of desired properties (NULL=all). */
jbulpin@0 265 {
jbulpin@0 266 CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */
jfehlig@25 267 _RESOURCES * resources = NULL; /* Handle to the list of system resources. */
jbulpin@0 268 _RESOURCE * resource; /* Handle to the system resource. */
jbulpin@0 269 char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
jbulpin@0 270 int found = 0; /* Found the target instance? */
jbulpin@0 271
jbulpin@0 272 _SBLIM_ENTER("GetInstance");
jbulpin@0 273 _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
jbulpin@0 274 _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
jbulpin@0 275 _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
jbulpin@0 276 _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
jbulpin@0 277
jfehlig@25 278 if (strcmp(namespace, HOST_INSTRUMENTATION_NS) == 0) {
jfehlig@25 279 _SBLIM_TRACE(1,("--- \"%s\" is not a valid namespace for %s", namespace, _CLASSNAME));
jfehlig@25 280 goto exit;
jfehlig@25 281 }
jfehlig@25 282
jbulpin@0 283 /* Get a handle to the list of system resources. */
jbulpin@0 284 if (!Xen_ProcessorPool_getResources(&resources)) {
jbulpin@0 285 _SBLIM_TRACE(1,("--- _getResources() failed"));
jbulpin@0 286 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources");
jbulpin@0 287 goto exit;
jbulpin@0 288 }
jbulpin@0 289
jbulpin@0 290 /* Get the target resource. */
jfehlig@16 291 found = Xen_ProcessorPool_getResourceForObjectPath(resources, &resource, reference, _BROKER, context);
jbulpin@0 292 if (!found || (resource == NULL)) {
jbulpin@0 293 _SBLIM_TRACE(1,("--- Target instance not found"));
jbulpin@0 294 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_FOUND, "Target instance not found");
jbulpin@0 295 goto exit;
jbulpin@0 296 }
jbulpin@0 297
jbulpin@0 298 /* Create a new CMPIInstance to store this resource. */
jbulpin@0 299 CMPIInstance * instance = _CMNewInstance(_BROKER, namespace, _CLASSNAME, &status);
jbulpin@0 300 if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instance)) {
jbulpin@0 301 _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status.msg)));
jbulpin@0 302 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIInstance");
jbulpin@0 303 goto exit;
jbulpin@0 304 }
jbulpin@0 305
jbulpin@0 306 /* Setup a filter to only return the desired properties. */
jbulpin@0 307 status = CMSetPropertyFilter(instance, properties, _KEYNAMES);
jbulpin@0 308 if (status.rc != CMPI_RC_OK) {
jbulpin@0 309 _SBLIM_TRACE(1, ("--- CMSetPropertyFilter() failed - %s", CMGetCharPtr(status.msg)));
jbulpin@0 310 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Cannot set property filter");
jbulpin@0 311 goto exit;
jbulpin@0 312 }
jbulpin@0 313
jbulpin@0 314 /* Set the instance property values from the resource data. */
jbulpin@0 315 if (!Xen_ProcessorPool_setInstanceFromResource(resource, instance, _BROKER)) {
jbulpin@0 316 _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed"));
jbulpin@0 317 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data");
jbulpin@0 318 goto exit;
jbulpin@0 319 }
jbulpin@0 320
jbulpin@0 321 /* Free the resource data. */
jbulpin@0 322 if (!Xen_ProcessorPool_freeResource(resource)) {
jbulpin@0 323 _SBLIM_TRACE(1,("--- _freeResource() failed"));
jbulpin@0 324 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data");
jbulpin@0 325 goto exit;
jbulpin@0 326 }
jbulpin@0 327
jbulpin@0 328 /* Return the CMPIInstance for this instance. */
jbulpin@0 329 _SBLIM_TRACE(3,("--- instance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, instance, NULL))));
jbulpin@0 330 CMReturnInstance(results, instance);
jbulpin@0 331
jbulpin@0 332 _SBLIM_TRACE(2,("--- instance found"));
jbulpin@0 333 CMReturnDone(results);
jbulpin@0 334
jbulpin@0 335 exit:
jbulpin@0 336 /* Free the list of system resources. */
jbulpin@0 337 if (!Xen_ProcessorPool_freeResources(resources)) {
jbulpin@0 338 _SBLIM_TRACE(1,("--- _freeResources() failed"));
jbulpin@0 339 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources");
jbulpin@0 340 }
jbulpin@0 341
jbulpin@0 342 _SBLIM_RETURNSTATUS(status);
jbulpin@0 343 }
jbulpin@0 344
jbulpin@0 345 // ----------------------------------------------------------------------------
jbulpin@0 346 // SetInstance()
jbulpin@0 347 // Save modified instance data for the specified instance.
jbulpin@0 348 // ----------------------------------------------------------------------------
jbulpin@0 349 static CMPIStatus SetInstance(
jbulpin@0 350 CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */
jfehlig@31 351 const CMPIContext * context, /* [in] Additional context info, if any. */
jfehlig@31 352 const CMPIResult * results, /* [out] Results of this operation. */
jfehlig@31 353 const CMPIObjectPath * reference, /* [in] Contains the target namespace, classname and object path. */
jfehlig@31 354 const CMPIInstance * newinstance, /* [in] Contains the new instance data. */
jfehlig@31 355 const char **properties)
jbulpin@0 356 {
jbulpin@0 357 CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */
jfehlig@25 358 _RESOURCES * resources = NULL; /* Handle to the list of system resources. */
jbulpin@0 359 _RESOURCE * resource; /* Handle to the system resource. */
jbulpin@0 360 char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
jbulpin@0 361 int found = 0; /* Found the target instance? */
jbulpin@0 362
jbulpin@0 363 _SBLIM_ENTER("SetInstance");
jbulpin@0 364 _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
jbulpin@0 365 _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
jbulpin@0 366 _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
jbulpin@0 367 _SBLIM_TRACE(2, ("--- newinstance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, newinstance, NULL))));
jbulpin@0 368 _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
jbulpin@0 369
jfehlig@25 370 if (strcmp(namespace, HOST_INSTRUMENTATION_NS) == 0) {
jfehlig@25 371 _SBLIM_TRACE(1,("--- \"%s\" is not a valid namespace for %s", namespace, _CLASSNAME));
jfehlig@25 372 goto exit;
jfehlig@25 373 }
jfehlig@25 374
jbulpin@0 375 /* Get a handle to the list of system resources. */
jbulpin@0 376 if (!Xen_ProcessorPool_getResources(&resources)) {
jbulpin@0 377 _SBLIM_TRACE(1,("--- _getResources() failed"));
jbulpin@0 378 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources");
jbulpin@0 379 goto exit;
jbulpin@0 380 }
jbulpin@0 381
jbulpin@0 382 /* Get the target resource. */
jfehlig@16 383 found = Xen_ProcessorPool_getResourceForObjectPath(resources, &resource, reference, _BROKER, context);
jbulpin@0 384 if (!found || (resource == NULL)) {
jbulpin@0 385 _SBLIM_TRACE(1,("--- Target instance not found"));
jbulpin@0 386 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_FOUND, "Target instance not found");
jbulpin@0 387 goto exit;
jbulpin@0 388 }
jbulpin@0 389
jbulpin@0 390 _SBLIM_TRACE(2,("--- instance found", found));
jbulpin@0 391
jbulpin@0 392 /* Update the target resource data with the new instance property values. */
jbulpin@0 393 int rc = Xen_ProcessorPool_setResourceFromInstance(resource, newinstance, _BROKER);
jbulpin@0 394
jbulpin@0 395 /* Free the resource data. */
jbulpin@0 396 if (!Xen_ProcessorPool_freeResource(resource)) {
jbulpin@0 397 _SBLIM_TRACE(1,("--- _freeResource() failed"));
jbulpin@0 398 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data");
jbulpin@0 399 goto exit;
jbulpin@0 400 }
jbulpin@0 401
jbulpin@0 402 if (rc != 1) {
jbulpin@0 403 if (rc == -1) {
jbulpin@0 404 _SBLIM_TRACE(1,("--- _setResourceFromInstance() unsupported"));
jbulpin@0 405 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL);
jbulpin@0 406 } else {
jbulpin@0 407 _SBLIM_TRACE(1,("--- _setResourceFromInstance() failed"));
jbulpin@0 408 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set resource data from instance properties");
jbulpin@0 409 }
jbulpin@0 410 goto exit;
jbulpin@0 411 }
jbulpin@0 412
jbulpin@0 413 exit:
jbulpin@0 414 /* Free the list of system resources. */
jbulpin@0 415 if (!Xen_ProcessorPool_freeResources(resources)) {
jbulpin@0 416 _SBLIM_TRACE(1,("--- _freeResources() failed"));
jbulpin@0 417 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources");
jbulpin@0 418 }
jbulpin@0 419
jbulpin@0 420 _SBLIM_RETURNSTATUS(status);
jbulpin@0 421 }
jbulpin@0 422
jbulpin@0 423 // ----------------------------------------------------------------------------
jbulpin@0 424 // CreateInstance()
jbulpin@0 425 // Create a new instance from the specified instance data.
jbulpin@0 426 // ----------------------------------------------------------------------------
jbulpin@0 427 static CMPIStatus CreateInstance(
jbulpin@0 428 CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */
jfehlig@31 429 const CMPIContext * context, /* [in] Additional context info, if any. */
jfehlig@31 430 const CMPIResult * results, /* [out] Results of this operation. */
jfehlig@31 431 const CMPIObjectPath * reference, /* [in] Contains the target namespace, classname and object path. */
jfehlig@31 432 const CMPIInstance * newinstance) /* [in] Contains the new instance data. */
jbulpin@0 433 {
jbulpin@0 434 CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */
jfehlig@25 435 _RESOURCES * resources = NULL; /* Handle to the list of system resources. */
jbulpin@0 436 _RESOURCE * resource; /* Handle to the system resource. */
jbulpin@0 437 char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
jbulpin@0 438 int found = 0; /* Found the target instance? */
jbulpin@0 439
jbulpin@0 440 _SBLIM_ENTER("CreateInstance");
jbulpin@0 441 _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
jbulpin@0 442 _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
jbulpin@0 443 _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
jbulpin@0 444 _SBLIM_TRACE(2, ("--- newinstance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, newinstance, NULL))));
jbulpin@0 445 _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
jbulpin@0 446
jfehlig@25 447 if (strcmp(namespace, HOST_INSTRUMENTATION_NS) == 0) {
jfehlig@25 448 _SBLIM_TRACE(1,("--- \"%s\" is not a valid namespace for %s", namespace, _CLASSNAME));
jfehlig@25 449 goto exit;
jfehlig@25 450 }
jfehlig@25 451
jbulpin@0 452 /* WORKAROUND FOR PEGASUS BUG?! reference does not contain object path, only namespace & classname. */
jbulpin@0 453 reference = CMGetObjectPath(newinstance, NULL);
jbulpin@0 454
jbulpin@0 455 /* Get a handle to the list of system resources. */
jbulpin@0 456 if (!Xen_ProcessorPool_getResources(&resources)) {
jbulpin@0 457 _SBLIM_TRACE(1,("--- _getResources() failed"));
jbulpin@0 458 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources");
jbulpin@0 459 goto exit;
jbulpin@0 460 }
jbulpin@0 461
jbulpin@0 462 /* Get the target resource. */
jfehlig@16 463 found = Xen_ProcessorPool_getResourceForObjectPath(resources, &resource, reference, _BROKER, context);
jbulpin@0 464
jbulpin@0 465 /* Free the resource data. */
jbulpin@0 466 if (!Xen_ProcessorPool_freeResource(resource)) {
jbulpin@0 467 _SBLIM_TRACE(1,("--- _freeResource() failed"));
jbulpin@0 468 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data");
jbulpin@0 469 goto exit;
jbulpin@0 470 }
jbulpin@0 471
jbulpin@0 472 if (found) {
jbulpin@0 473 _SBLIM_TRACE(1,("--- Target instance already exists"));
jbulpin@0 474 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_ALREADY_EXISTS, "Target instance already exists");
jbulpin@0 475 goto exit;
jbulpin@0 476 }
jbulpin@0 477
jbulpin@0 478 /* Create a new resource with the new instance property values. */
jbulpin@0 479 int rc = Xen_ProcessorPool_createResourceFromInstance(resources, &resource, newinstance, _BROKER);
jbulpin@0 480 if (rc != 1) {
jbulpin@0 481 if (rc == -1) {
jbulpin@0 482 _SBLIM_TRACE(1,("--- _createResourceFromInstance() unsupported"));
jbulpin@0 483 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL);
jbulpin@0 484 } else {
jbulpin@0 485 _SBLIM_TRACE(1,("--- _createResourceFromInstance() failed"));
jbulpin@0 486 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to create resource data from instance properties");
jbulpin@0 487 }
jbulpin@0 488 goto exit;
jbulpin@0 489 }
jbulpin@0 490
jbulpin@0 491 /* Return the object path for the newly created instance. */
jbulpin@0 492 CMPIObjectPath * objectpath = CMGetObjectPath(newinstance, NULL);
jbulpin@0 493 CMSetNameSpace(objectpath, namespace);
jbulpin@0 494 CMReturnObjectPath(results, objectpath);
jbulpin@0 495 CMReturnDone(results);
jbulpin@0 496
jbulpin@0 497 exit:
jbulpin@0 498 /* Free the list of system resources. */
jbulpin@0 499 if (!Xen_ProcessorPool_freeResources(resources)) {
jbulpin@0 500 _SBLIM_TRACE(1,("--- _freeResources() failed"));
jbulpin@0 501 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources");
jbulpin@0 502 }
jbulpin@0 503
jbulpin@0 504 _SBLIM_RETURNSTATUS(status);
jbulpin@0 505 }
jbulpin@0 506
jbulpin@0 507 // ----------------------------------------------------------------------------
jbulpin@0 508 // DeleteInstance()
jbulpin@0 509 // Delete or remove the specified instance from the system.
jbulpin@0 510 // ----------------------------------------------------------------------------
jbulpin@0 511 static CMPIStatus DeleteInstance(
jbulpin@0 512 CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */
jfehlig@31 513 const CMPIContext * context, /* [in] Additional context info, if any. */
jfehlig@31 514 const CMPIResult * results, /* [out] Results of this operation. */
jfehlig@31 515 const CMPIObjectPath * reference) /* [in] Contains the target namespace, classname and object path. */
jbulpin@0 516 {
jbulpin@0 517 CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */
jfehlig@25 518 _RESOURCES * resources = NULL; /* Handle to the list of system resources. */
jbulpin@0 519 _RESOURCE * resource; /* Handle to the system resource. */
jbulpin@0 520 char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
jbulpin@0 521 int found = 0; /* Found the target instance? */
jbulpin@0 522
jbulpin@0 523 _SBLIM_ENTER("DeleteInstance");
jbulpin@0 524 _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
jbulpin@0 525 _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
jbulpin@0 526 _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
jbulpin@0 527 _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
jbulpin@0 528
jfehlig@25 529 if (strcmp(namespace, HOST_INSTRUMENTATION_NS) == 0) {
jfehlig@25 530 _SBLIM_TRACE(1,("--- \"%s\" is not a valid namespace for %s", namespace, _CLASSNAME));
jfehlig@25 531 goto exit;
jfehlig@25 532 }
jfehlig@25 533
jbulpin@0 534 /* Get a handle to the list of system resources. */
jbulpin@0 535 if (!Xen_ProcessorPool_getResources(&resources)) {
jbulpin@0 536 _SBLIM_TRACE(1,("--- _getResources() failed"));
jbulpin@0 537 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources");
jbulpin@0 538 goto exit;
jbulpin@0 539 }
jbulpin@0 540
jbulpin@0 541 /* Get the target resource. */
jfehlig@16 542 found = Xen_ProcessorPool_getResourceForObjectPath(resources, &resource, reference, _BROKER, context);
jbulpin@0 543 if (!found || (resource == NULL)) {
jbulpin@0 544 _SBLIM_TRACE(1,("--- Target instance not found"));
jbulpin@0 545 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_FOUND, "Target instance not found");
jbulpin@0 546 goto exit;
jbulpin@0 547 }
jbulpin@0 548
jbulpin@0 549 _SBLIM_TRACE(2,("--- instance found", found));
jbulpin@0 550
jbulpin@0 551 /* Delete the target resource. */
jbulpin@0 552 int rc = Xen_ProcessorPool_deleteResource(resources, resource);
jbulpin@0 553
jbulpin@0 554 /* Free the resource data. */
jbulpin@0 555 if (!Xen_ProcessorPool_freeResource(resource)) {
jbulpin@0 556 _SBLIM_TRACE(1,("--- _freeResource() failed"));
jbulpin@0 557 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data");
jbulpin@0 558 goto exit;
jbulpin@0 559 }
jbulpin@0 560
jbulpin@0 561 if (rc != 1) {
jbulpin@0 562 if (rc == -1) {
jbulpin@0 563 _SBLIM_TRACE(1,("--- __deleteResource() unsupported"));
jbulpin@0 564 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL);
jbulpin@0 565 } else {
jbulpin@0 566 _SBLIM_TRACE(1,("--- _deleteResource() failed"));
jbulpin@0 567 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to delete resource");
jbulpin@0 568 }
jbulpin@0 569 goto exit;
jbulpin@0 570 }
jbulpin@0 571
jbulpin@0 572 exit:
jbulpin@0 573 /* Free the list of system resources. */
jbulpin@0 574 if (!Xen_ProcessorPool_freeResources(resources)) {
jbulpin@0 575 _SBLIM_TRACE(1,("--- _freeResources() failed"));
jbulpin@0 576 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources");
jbulpin@0 577 }
jbulpin@0 578
jbulpin@0 579 _SBLIM_RETURNSTATUS(status);
jbulpin@0 580 }
jbulpin@0 581
jbulpin@0 582
jbulpin@0 583 // ----------------------------------------------------------------------------
jbulpin@0 584 // ExecQuery()
jbulpin@0 585 // Return a list of all the instances that satisfy the specified query filter.
jbulpin@0 586 // ----------------------------------------------------------------------------
jbulpin@0 587 static CMPIStatus ExecQuery(
jbulpin@0 588 CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */
jfehlig@31 589 const CMPIContext * context, /* [in] Additional context info, if any. */
jfehlig@31 590 const CMPIResult * results, /* [out] Results of this operation. */
jfehlig@31 591 const CMPIObjectPath * reference, /* [in] Contains the target namespace and classname. */
jfehlig@31 592 const char * language, /* [in] Name of the query language. */
jfehlig@31 593 const char * query) /* [in] Text of the query written in the query language. */
jbulpin@0 594 {
jbulpin@0 595 CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */
jbulpin@0 596 char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
jbulpin@0 597
jbulpin@0 598 _SBLIM_ENTER("ExecQuery");
jbulpin@0 599 _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
jbulpin@0 600 _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
jbulpin@0 601 _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
jbulpin@0 602 _SBLIM_TRACE(2, ("--- language=\"%s\"", language));
jbulpin@0 603 _SBLIM_TRACE(2, ("--- query=\"%s\"", query));
jbulpin@0 604 _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
jbulpin@0 605
jfehlig@25 606 if (strcmp(namespace, HOST_INSTRUMENTATION_NS) == 0) {
jfehlig@25 607 _SBLIM_TRACE(1,("--- \"%s\" is not a valid namespace for %s", namespace, _CLASSNAME));
jfehlig@25 608 goto exit;
jfehlig@25 609 }
jfehlig@25 610
jbulpin@0 611 /* EXECQUERY() IS NOT YET SUPPORTED FOR THIS CLASS */
jbulpin@0 612 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL);
jbulpin@0 613
jbulpin@0 614 CMReturnDone(results);
jbulpin@0 615
jbulpin@0 616 exit:
jbulpin@0 617 _SBLIM_RETURNSTATUS(status);
jbulpin@0 618 }
jbulpin@0 619
jbulpin@0 620 // ----------------------------------------------------------------------------
jbulpin@0 621 // Initialize()
jbulpin@0 622 // Perform any necessary initialization immediately after this provider is
jbulpin@0 623 // first loaded.
jbulpin@0 624 // ----------------------------------------------------------------------------
jbulpin@0 625 static void Initialize(
jbulpin@0 626 CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */
jfehlig@31 627 const CMPIContext * context) /* [in] Additional context info, if any. */
jbulpin@0 628 {
jbulpin@0 629 _SBLIM_ENTER("Initialize");
jbulpin@0 630 _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
jfehlig@1 631 // _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
jbulpin@0 632
jbulpin@0 633 /* Nothing needs to be done to initialize this provider */
jbulpin@0 634 _SBLIM_RETURN();
jbulpin@0 635 }
jbulpin@0 636
jbulpin@0 637 // ============================================================================
jbulpin@0 638 // CMPI INSTANCE PROVIDER FUNCTION TABLE SETUP
jbulpin@0 639 // ============================================================================
jfehlig@1 640 CMInstanceMIStub( , Xen_ProcessorPool, _BROKER, Initialize(&mi, ctx));