os-cmpi-xen

changeset 130:e82eeb0764d6

Ported Xen_MemorySettingData to 'Cmpilify' interface.

Removed corresponding resource files that are no longer used.

Added support for memory ballooning via 'modify' operation on Xen_MemorySettingData.

Signed-off-by: Jim Fehlig <jfehlig@novell.com>
author Jim Fehlig <jfehlig@novell.com>
date Tue Jul 17 16:10:55 2007 -0600 (2007-07-17)
parents 6494910456a8
children dc1be661c5ee
files ChangeLog src/Makefile.am src/Xen_MemorySettingData.c src/Xen_MemorySettingData_Resource.c src/Xen_MemorySettingData_Resource.h
line diff
     1.1 --- a/ChangeLog	Mon Jul 16 17:22:22 2007 -0600
     1.2 +++ b/ChangeLog	Tue Jul 17 16:10:55 2007 -0600
     1.3 @@ -1,3 +1,12 @@
     1.4 +-------------------------------------------------------------------
     1.5 +Tue Jul 17 16:07:53 MDT 2007 - jfehlig@novell.com
     1.6 +
     1.7 +         - Ported Xen_MemorySettingData to 'Cmpilify' interface.
     1.8 +           Removed corresponding resource files that are no longer
     1.9 +           used.
    1.10 +         - Added support for memory ballooning via 'modify'
    1.11 +           operation on Xen_MemorySettingData.
    1.12 +
    1.13  -------------------------------------------------------------------
    1.14  Mon Jul 16 17:20:05 MDT 2007 - jfehlig@novell.com
    1.15  
     2.1 --- a/src/Makefile.am	Mon Jul 16 17:22:22 2007 -0600
     2.2 +++ b/src/Makefile.am	Tue Jul 17 16:10:55 2007 -0600
     2.3 @@ -52,7 +52,6 @@ noinst_HEADERS = \
     2.4  	Xen_Console_Resource.h \
     2.5  	Xen_VirtualizationCapabilities_Resource.h \
     2.6  	Xen_ComputerSystemSettingData_Resource.h \
     2.7 -	Xen_MemorySettingData_Resource.h \
     2.8  	Xen_NetworkPortSettingData_Resource.h \
     2.9  	Xen_ConsoleSettingData_Resource.h \
    2.10  	Xen_MemoryPool_Resource.h \
    2.11 @@ -251,7 +250,7 @@ libXen_ProcessorElementSettingData_la_CF
    2.12  libXen_ProcessorElementSettingData_la_LIBADD = libXen_ProviderCommon.la
    2.13  libXen_ProcessorElementSettingData_la_LDFLAGS = -module -avoid-version -no-undefined
    2.14  
    2.15 -libXen_MemorySettingData_la_SOURCES = Xen_MemorySettingData.c Xen_MemorySettingData_Resource.c
    2.16 +libXen_MemorySettingData_la_SOURCES = Xen_MemorySettingData.c
    2.17  libXen_MemorySettingData_la_CFLAGS = -I../ @LIBXEN_CFLAGS@
    2.18  libXen_MemorySettingData_la_LIBADD = libXen_ProviderCommon.la
    2.19  libXen_MemorySettingData_la_LDFLAGS = -module -avoid-version -no-undefined
     3.1 --- a/src/Xen_MemorySettingData.c	Mon Jul 16 17:22:22 2007 -0600
     3.2 +++ b/src/Xen_MemorySettingData.c	Tue Jul 17 16:10:55 2007 -0600
     3.3 @@ -16,616 +16,490 @@
     3.4  // ============================================================================
     3.5  // Authors:       Dr. Gareth S. Bestor, <bestor@us.ibm.com>
     3.6  // Contributors:  Jim Fehlig, <jfehlig@novell.com>
     3.7 -// Description:
     3.8 +//		          Raj Subrahmanian <raj.subrahmanian@unisys.com>
     3.9 +// Description:   Implementation of memory RASD.
    3.10  // ============================================================================
    3.11  
    3.12 -/* Include the required CMPI data types, function headers, and macros */
    3.13 -#include "cmpidt.h"
    3.14 -#include "cmpift.h"
    3.15 -#include "cmpimacs.h"
    3.16 -
    3.17 -/* Include utility functions */
    3.18 -#include "cmpiutil.h"
    3.19 +/* Common declarations for each CMPI "Cimpler" instance provider */
    3.20 +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    3.21 +#include <cmpidt.h>
    3.22 +#include <cmpimacs.h>
    3.23  
    3.24 -/* Include _SBLIM_TRACE() logging support */
    3.25 -#include "cmpitrace.h"
    3.26 +#include "cmpilify.h"
    3.27  
    3.28 -/* Include Xen utilities */
    3.29 -#include "xen_utils.h"
    3.30  
    3.31 -/* Include the abstract resource access functions and abstracted _RESOURCES and _RESOURCE data types. */
    3.32 -#include "Xen_MemorySettingData_Resource.h"
    3.33 +static const CMPIInstanceMI* mi;
    3.34  
    3.35  
    3.36 -// ----------------------------------------------------------------------------
    3.37 -// COMMON GLOBAL VARIABLES
    3.38 -// ----------------------------------------------------------------------------
    3.39 +#define _BROKER (((CMPILIFYInstanceMI*)(mi->hdl))->brkr)
    3.40 +#define _CLASS (((CMPILIFYInstanceMI*)(mi->hdl))->cn)
    3.41 +#define _KEYS (((CMPILIFYInstanceMI*)(mi->hdl))->kys)
    3.42 +
    3.43 +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    3.44 +
    3.45 +#include <stdlib.h>
    3.46 +#include <assert.h>
    3.47 +
    3.48 +#include <xen_common.h>
    3.49 +#include <xen_host.h>
    3.50 +#include <xen_vm.h>
    3.51 +#include <xen_vm_metrics.h>
    3.52 +
    3.53 +#include "cmpitrace.h"
    3.54 +#include "xen_utils.h"
    3.55 +#include "provider_common.h"
    3.56  
    3.57 -/* Handle to the CIM broker. Initialized when the provider lib is loaded. */
    3.58 -static const CMPIBroker *_BROKER;
    3.59 +
    3.60 +/* C struct to store data for a single resource. */
    3.61 +typedef struct {
    3.62 +   int is_vm_record;
    3.63 +   union
    3.64 +   {
    3.65 +      xen_vm_record *vm_rec;
    3.66 +      CMPIInstance *cmpi_inst;
    3.67 +   } u;
    3.68 +} memory_resource;
    3.69 +
    3.70 +
    3.71 +/* C struct to store the data for all resources. */
    3.72 +typedef struct {
    3.73 +   xen_vm_set *domains;
    3.74 +   size_t cur_domain;
    3.75 +} memory_resources;
    3.76 +
    3.77  
    3.78  /* Xen session object.  Initialize when the provider is loaded, close when
    3.79   * provider unloaded. */
    3.80  static xen_utils_session *session = NULL;
    3.81  
    3.82  
    3.83 -// ============================================================================
    3.84 -// CMPI INSTANCE PROVIDER FUNCTION TABLE
    3.85 -// ============================================================================
    3.86 -
    3.87 -// ----------------------------------------------------------------------------
    3.88 -// Info for the class supported by the instance provider
    3.89 -// ----------------------------------------------------------------------------
    3.90 -
    3.91 -/* Name of the class implemented by this instance provider. */
    3.92 -/*** CUSTOMIZE FOR EACH PROVIDER ***/
    3.93 -static char * _CLASSNAME = "Xen_MemorySettingData";
    3.94 -
    3.95 -/* NULL terminated list of key properties of this class. */
    3.96 -/*** CUSTOMIZE FOR EACH PROVIDER ***/
    3.97 -const static char * _KEYNAMES[] = {"InstanceID", NULL};
    3.98 +static CMPIrc load()
    3.99 +{
   3.100 +   /* Initialized Xen session object. */
   3.101 +   if (!session)
   3.102 +      xen_utils_xen_init(&session);
   3.103  
   3.104 -// ----------------------------------------------------------------------------
   3.105 -// Cleanup()
   3.106 -// Perform any necessary cleanup immediately before this provider is unloaded.
   3.107 -// ----------------------------------------------------------------------------
   3.108 -static CMPIStatus Cleanup(
   3.109 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.110 -		const CMPIContext * context,		/* [in] Additional context info, if any. */
   3.111 -        CMPIBoolean terminating)   /* [in] True if MB is terminating */
   3.112 +   return CMPI_RC_OK;
   3.113 +}
   3.114 +
   3.115 +
   3.116 +static CMPIrc unload(const int terminating)
   3.117  {
   3.118 -   CMPIStatus status = { CMPI_RC_OK, NULL };	/* Return status of CIM operations. */
   3.119 -
   3.120 -   _SBLIM_ENTER("Cleanup");
   3.121 -   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   3.122 -   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   3.123 -
   3.124 +   (void)terminating;
   3.125 +   
   3.126 +   /* Close Xen session object. */
   3.127     if (session) {
   3.128        xen_utils_xen_close(session);
   3.129        session = NULL;
   3.130     }
   3.131 -   _SBLIM_RETURNSTATUS(status);
   3.132 +
   3.133 +   return CMPI_RC_OK;
   3.134  }
   3.135  
   3.136 -// ----------------------------------------------------------------------------
   3.137 -// EnumInstanceNames()
   3.138 -// Return a list of all the instances names (return their object paths only).
   3.139 -// ----------------------------------------------------------------------------
   3.140 -static CMPIStatus EnumInstanceNames(
   3.141 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.142 -		const CMPIContext * context,		/* [in] Additional context info, if any. */
   3.143 -		const CMPIResult * results,		/* [out] Results of this operation. */
   3.144 -		const CMPIObjectPath * reference) 	/* [in] Contains target namespace and classname. */
   3.145 +
   3.146 +static CMPIrc begin(void **res_list, const char **properties)
   3.147  {
   3.148 -   CMPIStatus status = {CMPI_RC_OK, NULL};	/* Return status of CIM operations. */
   3.149 -   _RESOURCES * resources = NULL;			/* Handle to the list of system resources. */
   3.150 -   _RESOURCE * resource;			/* Handle to each system resource. */
   3.151 -   char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
   3.152 -   int found = 0;				/* Found any instances? */
   3.153 -  
   3.154 -   _SBLIM_ENTER("EnumInstanceNames");
   3.155 -   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   3.156 -   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   3.157 -   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
   3.158 -   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
   3.159 -
   3.160 +   memory_resources *resources;
   3.161 +   
   3.162 +   (void)properties;
   3.163 +   
   3.164     if (!xen_utils_validate_session(&session)) {
   3.165 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon");
   3.166 -      goto exit;
   3.167 -   }
   3.168 -
   3.169 -   /* Get a handle to the list of system resources. */
   3.170 -   if (!Xen_MemorySettingData_getResources(session, &resources)) {
   3.171 -      _SBLIM_TRACE(1,("--- _getResources() failed"));
   3.172 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources");
   3.173 -      goto exit;
   3.174 +      _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   3.175 +                   ("--- Unable to establish connection with Xend"));
   3.176 +      return CMPI_RC_ERR_FAILED;
   3.177     }
   3.178  
   3.179 -   /* Enumerate thru the list of system resources and return a CMPIInstance for each. */
   3.180 -   while (Xen_MemorySettingData_getNextResource(session, resources, &resource)) {
   3.181 -      /* Create a new CMPIInstance to store this resource. */
   3.182 -      CMPIInstance * instance = _CMNewInstance(_BROKER, namespace, _CLASSNAME, &status);
   3.183 -      if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instance)) {
   3.184 -         _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status.msg)));
   3.185 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIInstance");
   3.186 -         goto exit;
   3.187 -      }
   3.188 -
   3.189 -      /* Set the instance property values from the resource data. */
   3.190 -      if (!Xen_MemorySettingData_setInstanceFromResource(session, resource, instance, _BROKER)) {
   3.191 -         _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed"));
   3.192 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data");
   3.193 -         goto exit;
   3.194 -      }
   3.195 -
   3.196 -      /* Free the resource data. */
   3.197 -      if (!Xen_MemorySettingData_freeResource(resource)) {
   3.198 -         _SBLIM_TRACE(1,("--- _freeResource() failed"));
   3.199 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data");
   3.200 -         goto exit;
   3.201 -      }
   3.202 -
   3.203 -      /* Return the CMPIObjectPath for this instance. */
   3.204 -      CMPIObjectPath * objectpath = CMGetObjectPath(instance, &status);
   3.205 -      if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
   3.206 -         _SBLIM_TRACE(1,("--- CMGetObjectPath() failed - %s", CMGetCharPtr(status.msg)));
   3.207 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot get CMPIObjectPath for instance");
   3.208 -         goto exit;
   3.209 -      }
   3.210 -      CMSetNameSpace(objectpath, namespace); /* Note - CMGetObjectPath() does not preserve the namespace! */
   3.211 -     
   3.212 -      _SBLIM_TRACE(3,("--- objectpath=\"%s\"", CMGetCharPtr(CDToString(_BROKER, objectpath, NULL))));
   3.213 -      CMReturnObjectPath(results, objectpath);
   3.214 -      found++;
   3.215 -   }
   3.216 +   /* malloc a new handle for the resources list. */
   3.217 +   resources = (memory_resources *)calloc(1, sizeof(memory_resources));
   3.218 +   if (resources == NULL)
   3.219 +      return CMPI_RC_ERR_FAILED;
   3.220  
   3.221 -   _SBLIM_TRACE(2,("--- %d object paths found", found));
   3.222 -   CMReturnDone(results);
   3.223 -
   3.224 -exit:
   3.225 -   /* Free the list of system resources. */
   3.226 -   if (!Xen_MemorySettingData_freeResources(resources)) {
   3.227 -      _SBLIM_TRACE(1,("--- _freeResources() failed"));
   3.228 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources");
   3.229 -   }
   3.230 -  
   3.231 -   _SBLIM_RETURNSTATUS(status);
   3.232 -}
   3.233 -
   3.234 -// ----------------------------------------------------------------------------
   3.235 -// EnumInstances()
   3.236 -// Return a list of all the instances (return all the instance data).
   3.237 -// ----------------------------------------------------------------------------
   3.238 -static CMPIStatus EnumInstances(
   3.239 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.240 -		const CMPIContext * context,		/* [in] Additional context info, if any. */
   3.241 -		const CMPIResult * results,		/* [out] Results of this operation. */
   3.242 -		const CMPIObjectPath * reference,	/* [in] Contains target namespace and classname. */
   3.243 -		const char ** properties)	/* [in] List of desired properties (NULL=all). */
   3.244 -{
   3.245 -   CMPIStatus status = {CMPI_RC_OK, NULL};	/* Return status of CIM operations. */
   3.246 -   _RESOURCES * resources = NULL;			/* Handle to the list of system resources. */
   3.247 -   _RESOURCE * resource;			/* Handle to each system resource. */
   3.248 -   char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
   3.249 -   int found = 0;				/* Found any resource instances? */
   3.250 -
   3.251 -   _SBLIM_ENTER("EnumInstances");
   3.252 -   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   3.253 -   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   3.254 -   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
   3.255 -   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
   3.256 -
   3.257 -   if (!xen_utils_validate_session(&session)) {
   3.258 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon");
   3.259 -      goto exit;
   3.260 +   if(!xen_host_get_resident_vms(session->xen, &(resources->domains),
   3.261 +                                 session->host)) {
   3.262 +      _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   3.263 +                   ("--- Failed to retrieve list of domains from host"));
   3.264 +      _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
   3.265 +                            xen_utils_trace_error(session->xen));
   3.266 +      free(resources);
   3.267 +      return CMPI_RC_ERR_FAILED;
   3.268     }
   3.269  
   3.270 -   /* Get a handle to the list of system resources. */
   3.271 -   if (!Xen_MemorySettingData_getResources(session, &resources)) {
   3.272 -      _SBLIM_TRACE(1,("--- _getResources() failed"));
   3.273 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources");
   3.274 -      goto exit;
   3.275 -   }
   3.276 +   *res_list = (void *)resources;
   3.277 +   return CMPI_RC_OK;
   3.278 +}
   3.279  
   3.280 -   /* Enumerate thru the list of system resources and return a CMPIInstance for each. */
   3.281 -   while (Xen_MemorySettingData_getNextResource(session, resources, &resource)) {
   3.282 -      /* Create a new CMPIInstance to store this resource. */
   3.283 -      CMPIInstance * instance = _CMNewInstance(_BROKER, namespace, _CLASSNAME, &status);
   3.284 -      if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instance)) {
   3.285 -         _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status.msg)));
   3.286 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIInstance");
   3.287 -         goto exit;
   3.288 -      }
   3.289 -
   3.290 -      /* Setup a filter to only return the desired properties. */
   3.291 -      status = CMSetPropertyFilter(instance, properties, _KEYNAMES);
   3.292 -      if (status.rc != CMPI_RC_OK) {
   3.293 -         _SBLIM_TRACE(1, ("--- CMSetPropertyFilter() failed - %s", CMGetCharPtr(status.msg)));
   3.294 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Cannot set property filter");
   3.295 -         goto exit;
   3.296 -      }
   3.297  
   3.298 -      /* Set the instance property values from the resource data. */
   3.299 -      if (!Xen_MemorySettingData_setInstanceFromResource(session, resource, instance, _BROKER)) {
   3.300 -         _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed"));
   3.301 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data");
   3.302 -         goto exit;
   3.303 -      }
   3.304 -
   3.305 -      /* Free the resource data. */
   3.306 -      if (!Xen_MemorySettingData_freeResource(resource)) {
   3.307 -         _SBLIM_TRACE(1,("--- _freeResource() failed"));
   3.308 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data");
   3.309 -         goto exit;
   3.310 -      }
   3.311 -
   3.312 -      /* Return the CMPIInstance for this instance. */
   3.313 -      _SBLIM_TRACE(3,("--- instance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, instance, NULL))));
   3.314 -      CMReturnInstance(results, instance);
   3.315 -      found++;
   3.316 +static void end(void *res_list)
   3.317 +{
   3.318 +   if (res_list) {
   3.319 +      xen_vm_set_free(((memory_resources *)res_list)->domains);
   3.320 +      free(res_list);
   3.321     }
   3.322 -
   3.323 -   _SBLIM_TRACE(2,("--- %d instances found", found));
   3.324 -   CMReturnDone(results);
   3.325 -
   3.326 -exit:
   3.327 -   /* Free the list of system resources. */
   3.328 -   if (!Xen_MemorySettingData_freeResources(resources)) {
   3.329 -      _SBLIM_TRACE(1,("--- _freeResources() failed"));
   3.330 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources");
   3.331 -   }
   3.332 -
   3.333 -   _SBLIM_RETURNSTATUS(status);
   3.334  }
   3.335  
   3.336 -// ----------------------------------------------------------------------------
   3.337 -// GetInstance()
   3.338 -// Return the instance data for the specified instance only.
   3.339 -// ----------------------------------------------------------------------------
   3.340 -static CMPIStatus GetInstance(
   3.341 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.342 -		const CMPIContext * context,		/* [in] Additional context info, if any. */
   3.343 -		const CMPIResult * results,		/* [out] Results of this operation. */
   3.344 -		const CMPIObjectPath * reference,	/* [in] Contains the target namespace, classname and object path. */
   3.345 -		const char ** properties)		/* [in] List of desired properties (NULL=all). */
   3.346 +
   3.347 +/* Iterator to get the next resource from the resources list. */
   3.348 +static CMPIrc getnext(void *res_list, void **res, const char **properties)
   3.349  {
   3.350 -   CMPIStatus status = {CMPI_RC_OK, NULL};	/* Return status of CIM operations. */
   3.351 -   _RESOURCES * resources = NULL;			/* Handle to the list of system resources. */
   3.352 -   _RESOURCE * resource;			/* Handle to the system resource. */
   3.353 -   char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
   3.354 -   int found = 0;				/* Found the target instance? */
   3.355 +   memory_resources *resources = (memory_resources *)res_list;
   3.356 +   memory_resource *resource;
   3.357  
   3.358 -   _SBLIM_ENTER("GetInstance");
   3.359 -   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   3.360 -   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   3.361 -   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
   3.362 -   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
   3.363 +   (void)properties;
   3.364 +   
   3.365 +   if (resources == NULL)
   3.366 +      return CMPI_RC_ERR_FAILED;
   3.367  
   3.368 -   if (!xen_utils_validate_session(&session)) {
   3.369 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon");
   3.370 -      goto exit;
   3.371 -   }
   3.372 +   /* Has end of resource list been reached? */
   3.373 +   if (resources->cur_domain >= resources->domains->size)
   3.374 +      return CMPI_RC_ERR_NOT_FOUND;
   3.375  
   3.376 -   /* Get a handle to the list of system resources. */
   3.377 -   if (!Xen_MemorySettingData_getResources(session, &resources)) {
   3.378 -      _SBLIM_TRACE(1,("--- _getResources() failed"));
   3.379 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources");
   3.380 -      goto exit;
   3.381 -   }
   3.382 +   /* Get memory for resource. */
   3.383 +   resource = (memory_resource *)malloc(sizeof(memory_resource));
   3.384 +   if (resource == NULL)
   3.385 +      return CMPI_RC_ERR_FAILED;
   3.386  
   3.387 -   /* Get the target resource. */
   3.388 -   found = Xen_MemorySettingData_getResourceForObjectPath(session, resources, &resource, reference);
   3.389 -   if (!found || (resource == NULL)) {
   3.390 -      _SBLIM_TRACE(1,("--- Target instance not found"));
   3.391 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_FOUND, "Target instance not found");
   3.392 -      goto exit;
   3.393 -   }
   3.394 +   resource->is_vm_record = 1;
   3.395 +
   3.396 +   session->xen->ok = true;
   3.397  
   3.398 -   /* Create a new CMPIInstance to store this resource. */
   3.399 -   CMPIInstance * instance = _CMNewInstance(_BROKER, namespace, _CLASSNAME, &status);
   3.400 -   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instance)) {
   3.401 -      _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status.msg)));
   3.402 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIInstance");
   3.403 -      goto exit;
   3.404 -   }
   3.405 -
   3.406 -   /* Setup a filter to only return the desired properties. */
   3.407 -   status = CMSetPropertyFilter(instance, properties, _KEYNAMES);
   3.408 -   if (status.rc != CMPI_RC_OK) {
   3.409 -      _SBLIM_TRACE(1, ("--- CMSetPropertyFilter() failed - %s", CMGetCharPtr(status.msg)));
   3.410 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Cannot set property filter");
   3.411 -      goto exit;
   3.412 -   }
   3.413 -
   3.414 -   /* Set the instance property values from the resource data. */
   3.415 -   if (!Xen_MemorySettingData_setInstanceFromResource(session, resource, instance, _BROKER)) {
   3.416 -      _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed"));
   3.417 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data");
   3.418 -      goto exit;
   3.419 +   if (!xen_vm_get_record(session->xen, &(resource->u.vm_rec),
   3.420 +                          resources->domains->contents[resources->cur_domain])) {
   3.421 +      free(resource);
   3.422 +      _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   3.423 +                   ("--- Failed to retrieve VM record from xend"));
   3.424 +      _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
   3.425 +                            xen_utils_trace_error(session->xen));
   3.426 +      return CMPI_RC_ERR_FAILED;
   3.427     }
   3.428  
   3.429 -   /* Free the resource data. */
   3.430 -   if (!Xen_MemorySettingData_freeResource(resource)) {
   3.431 -      _SBLIM_TRACE(1,("--- _freeResource() failed"));
   3.432 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data");
   3.433 -      goto exit;
   3.434 -   }
   3.435 -
   3.436 -   /* Return the CMPIInstance for this instance. */
   3.437 -   _SBLIM_TRACE(3,("--- instance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, instance, NULL))));
   3.438 -   CMReturnInstance(results, instance);
   3.439 -
   3.440 -   _SBLIM_TRACE(2,("--- instance found"));
   3.441 -   CMReturnDone(results);
   3.442 -
   3.443 -exit:
   3.444 -   /* Free the list of system resources. */
   3.445 -   if (!Xen_MemorySettingData_freeResources(resources)) {
   3.446 -      _SBLIM_TRACE(1,("--- _freeResources() failed"));
   3.447 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources");
   3.448 -   }
   3.449 -
   3.450 -   _SBLIM_RETURNSTATUS(status);
   3.451 +   resources->cur_domain++;
   3.452 +   *res = (void *)resource;
   3.453 +   return CMPI_RC_OK;
   3.454  }
   3.455  
   3.456 -// ----------------------------------------------------------------------------
   3.457 -// SetInstance()
   3.458 -// Save modified instance data for the specified instance.
   3.459 -// ----------------------------------------------------------------------------
   3.460 -static CMPIStatus SetInstance(
   3.461 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.462 -		const CMPIContext * context,		/* [in] Additional context info, if any. */
   3.463 -		const CMPIResult * results,		/* [out] Results of this operation. */
   3.464 -		const CMPIObjectPath * reference,	/* [in] Contains the target namespace, classname and object path. */
   3.465 -		const CMPIInstance * newinstance,	/* [in] Contains the new instance data. */
   3.466 -        const char **properties)
   3.467 +
   3.468 +static CMPIrc get(const void *res_id, void **res, const char **properties)
   3.469  {
   3.470 -   CMPIStatus status = {CMPI_RC_OK, NULL};	/* Return status of CIM operations. */
   3.471 -   _RESOURCES * resources = NULL;			/* Handle to the list of system resources. */
   3.472 -   _RESOURCE * resource = NULL;	       		/* Handle to the system resource. */
   3.473 -   char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
   3.474 -   int found = 0;				/* Found the target instance? */
   3.475 -   char error_msg[XEN_UTILS_ERROR_BUF_LEN];
   3.476 +   CMPIInstance *inst = (CMPIInstance *)res_id;
   3.477 +   CMPIData data;
   3.478 +   CMPIStatus status = {CMPI_RC_OK, NULL};
   3.479 +   char *prop_val;
   3.480 +   char sys_name[MAX_SYSTEM_NAME_LEN];
   3.481 +   memory_resource *resource;
   3.482 +   
   3.483 +   (void)properties;
   3.484 +   
   3.485 +   if (CMIsNullObject(inst) || res == NULL)
   3.486 +      return CMPI_RC_ERR_FAILED;
   3.487  
   3.488 -   _SBLIM_ENTER("SetInstance");
   3.489 -   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   3.490 -   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   3.491 -   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
   3.492 -   _SBLIM_TRACE(2, ("--- newinstance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, newinstance, NULL))));
   3.493 -   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
   3.494 +   /* Obtain the target domain name from instance's "SystemName" property. */
   3.495 +   data = CMGetProperty(inst, "InstanceID", &status);
   3.496 +   if ((status.rc != CMPI_RC_OK) || CMIsNullValue(data))
   3.497 +      return CMPI_RC_ERR_FAILED;
   3.498 +
   3.499 +   prop_val = CMGetCharPtr(data.value.string);
   3.500 +   if ((prop_val == NULL) || (*prop_val == '\0'))
   3.501 +      return CMPI_RC_ERR_FAILED;
   3.502 +
   3.503 +   /* Extract the system name from InstanceID property. */
   3.504 +   if (!_CMPIStrncpySystemNameFromID(sys_name, prop_val, MAX_SYSTEM_NAME_LEN))
   3.505 +      return CMPI_RC_ERR_FAILED;
   3.506  
   3.507     if (!xen_utils_validate_session(&session)) {
   3.508 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon");
   3.509 -      goto exit;
   3.510 -   }
   3.511 -
   3.512 -   /* Get a handle to the list of system resources. */
   3.513 -   if (!Xen_MemorySettingData_getResources(session, &resources)) {
   3.514 -      _SBLIM_TRACE(1,("--- _getResources() failed"));
   3.515 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources");
   3.516 -      goto exit;
   3.517 -   }
   3.518 -
   3.519 -   /* Get the target resource. */
   3.520 -   found = Xen_MemorySettingData_getResourceForObjectPath(session, resources, &resource, reference);
   3.521 -   if (!found || (resource == NULL)) {
   3.522 -      _SBLIM_TRACE(1,("--- Target instance not found"));
   3.523 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_FOUND, "Target instance not found");
   3.524 -      goto exit;
   3.525 -   }
   3.526 -
   3.527 -   _SBLIM_TRACE(2,("--- instance found", found));
   3.528 -
   3.529 -   /* Update the target resource data with the new instance property values. */
   3.530 -   if (!Xen_MemorySettingData_setResourceFromInstance(session, resource, newinstance)) {
   3.531 -      XEN_UTILS_GET_ERROR_STRING(error_msg, session->xen);
   3.532 -      _SBLIM_TRACE(1,("--- deleteResource failed: %s", error_msg));
   3.533 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, error_msg);
   3.534 -      goto exit;
   3.535 +      _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   3.536 +                   ("--- Unable to establish connection with Xend"));
   3.537 +      return CMPI_RC_ERR_FAILED;
   3.538     }
   3.539 -
   3.540 -exit:
   3.541 -   if (resource)
   3.542 -      Xen_MemorySettingData_freeResource(resource);
   3.543 -   if (resources)
   3.544 -      Xen_MemorySettingData_freeResources(resources);
   3.545 -
   3.546 -   _SBLIM_RETURNSTATUS(status);
   3.547 -}
   3.548 -
   3.549 -// ----------------------------------------------------------------------------
   3.550 -// CreateInstance()
   3.551 -// Create a new instance from the specified instance data.
   3.552 -// ----------------------------------------------------------------------------
   3.553 -static CMPIStatus CreateInstance(
   3.554 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.555 -		const CMPIContext * context,		/* [in] Additional context info, if any. */
   3.556 -		const CMPIResult * results,		/* [out] Results of this operation. */
   3.557 -		const CMPIObjectPath * reference,	/* [in] Contains the target namespace, classname and object path. */
   3.558 -		const CMPIInstance * newinstance)	/* [in] Contains the new instance data. */
   3.559 -{
   3.560 -   CMPIStatus status = {CMPI_RC_OK, NULL};	/* Return status of CIM operations. */
   3.561 -   _RESOURCES * resources = NULL;			/* Handle to the list of system resources. */
   3.562 -   _RESOURCE * resource;			/* Handle to the system resource. */
   3.563 -   char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
   3.564 -   int found = 0;				/* Found the target instance? */
   3.565 -
   3.566 -   _SBLIM_ENTER("CreateInstance");
   3.567 -   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   3.568 -   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   3.569 -   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
   3.570 -   _SBLIM_TRACE(2, ("--- newinstance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, newinstance, NULL))));
   3.571 -   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
   3.572 -
   3.573 -   if (!xen_utils_validate_session(&session)) {
   3.574 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon");
   3.575 -      goto exit;
   3.576 +   
   3.577 +   /* Get the domain data for the target domain name. */
   3.578 +   xen_vm_set *vms;
   3.579 +   if (!xen_vm_get_by_name_label(session->xen, &vms, sys_name)) {
   3.580 +      _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_WARNING,
   3.581 +                   ("--- Failed to retrieve domain %s", sys_name));
   3.582 +      _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
   3.583 +                            xen_utils_trace_error(session->xen));
   3.584 +      return CMPI_RC_ERR_FAILED;
   3.585     }
   3.586  
   3.587 -   /* WORKAROUND FOR PEGASUS BUG?! reference does not contain object path, only namespace & classname. */
   3.588 -   reference = CMGetObjectPath(newinstance, NULL);
   3.589 -
   3.590 -   /* Get a handle to the list of system resources. */
   3.591 -   if (!Xen_MemorySettingData_getResources(session, &resources)) {
   3.592 -      _SBLIM_TRACE(1,("--- _getResources() failed"));
   3.593 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources");
   3.594 -      goto exit;
   3.595 -   }
   3.596 +   assert(vms->size == 1);
   3.597  
   3.598 -   /* Get the target resource. */
   3.599 -   found = Xen_MemorySettingData_getResourceForObjectPath(session, resources, &resource, reference);
   3.600 +   /* Get memory for resource. */
   3.601 +   resource = (memory_resource *)malloc(sizeof(memory_resource));
   3.602 +   if (resource == NULL) {
   3.603 +      xen_vm_set_free(vms);
   3.604 +      return CMPI_RC_ERR_FAILED;
   3.605 +   }
   3.606 +   
   3.607 +   resource->is_vm_record = 1;
   3.608  
   3.609 -   /* Free the resource data. */
   3.610 -   if (!Xen_MemorySettingData_freeResource(resource)) {
   3.611 -      _SBLIM_TRACE(1,("--- _freeResource() failed"));
   3.612 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data");
   3.613 -      goto exit;
   3.614 -   }
   3.615 -
   3.616 -   if (found) {
   3.617 -      _SBLIM_TRACE(1,("--- Target instance already exists"));
   3.618 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_ALREADY_EXISTS, "Target instance already exists");
   3.619 -      goto exit;
   3.620 +   if (!xen_vm_get_record(session->xen,
   3.621 +                          &(resource->u.vm_rec), vms->contents[0])) {
   3.622 +      _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   3.623 +                   ("--- Failed to retrieve domain record for %s", sys_name));
   3.624 +      _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
   3.625 +                            xen_utils_trace_error(session->xen));
   3.626 +      free(resource);
   3.627 +      xen_vm_set_free(vms);
   3.628 +      return CMPI_RC_ERR_FAILED;
   3.629     }
   3.630  
   3.631 -   /* Create a new resource with the new instance property values. */
   3.632 -   int rc = Xen_MemorySettingData_createResourceFromInstance(resources, &resource, newinstance, _BROKER);
   3.633 -   if (rc != 1) {
   3.634 -      if (rc == -1) {
   3.635 -         _SBLIM_TRACE(1,("--- _createResourceFromInstance() unsupported"));
   3.636 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL);
   3.637 -      } else {
   3.638 -         _SBLIM_TRACE(1,("--- _createResourceFromInstance() failed"));
   3.639 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to create resource data from instance properties");
   3.640 -      }
   3.641 -      goto exit;
   3.642 -   }
   3.643 +   xen_vm_set_free(vms);
   3.644  
   3.645 -   /* Return the object path for the newly created instance. */
   3.646 -   CMPIObjectPath * objectpath = CMGetObjectPath(newinstance, NULL);
   3.647 -   CMSetNameSpace(objectpath, namespace);
   3.648 -   CMReturnObjectPath(results, objectpath);
   3.649 -   CMReturnDone(results);
   3.650 -
   3.651 -exit:
   3.652 -   /* Free the list of system resources. */
   3.653 -   if (!Xen_MemorySettingData_freeResources(resources)) {
   3.654 -      _SBLIM_TRACE(1,("--- _freeResources() failed"));
   3.655 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources");
   3.656 -   }
   3.657 -
   3.658 -   _SBLIM_RETURNSTATUS(status);
   3.659 +   *res = (void *)resource;
   3.660 +   return CMPI_RC_OK;
   3.661  }
   3.662  
   3.663 -// ----------------------------------------------------------------------------
   3.664 -// DeleteInstance()
   3.665 -// Delete or remove the specified instance from the system.
   3.666 -// ----------------------------------------------------------------------------
   3.667 -static CMPIStatus DeleteInstance(
   3.668 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.669 -		const CMPIContext * context,		/* [in] Additional context info, if any. */
   3.670 -		const CMPIResult * results,		/* [out] Results of this operation. */
   3.671 -		const CMPIObjectPath * reference)	/* [in] Contains the target namespace, classname and object path. */
   3.672 -{
   3.673 -   CMPIStatus status = {CMPI_RC_OK, NULL};	/* Return status of CIM operations. */
   3.674 -   _RESOURCES * resources = NULL;			/* Handle to the list of system resources. */
   3.675 -   _RESOURCE * resource;		/* Handle to the system resource. */
   3.676 -   char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
   3.677 -   int found = 0;				/* Found the target instance? */
   3.678  
   3.679 -   _SBLIM_ENTER("DeleteInstance");
   3.680 -   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   3.681 -   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   3.682 -   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
   3.683 -   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
   3.684 +static void release(void *res)
   3.685 +{
   3.686 +   if (res) {
   3.687 +      memory_resource *resource = (memory_resource *)res;
   3.688 +      if (resource->is_vm_record)
   3.689 +         xen_vm_record_free(resource->u.vm_rec);
   3.690 +      free(resource);
   3.691 +   }
   3.692 +}
   3.693  
   3.694 -   if (!xen_utils_validate_session(&session)) {
   3.695 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon");
   3.696 -      goto exit;
   3.697 -   }
   3.698 -
   3.699 -   /* Get a handle to the list of system resources. */
   3.700 -   if (!Xen_MemorySettingData_getResources(session, &resources)) {
   3.701 -      _SBLIM_TRACE(1,("--- _getResources() failed"));
   3.702 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources");
   3.703 -      goto exit;
   3.704 -   }
   3.705  
   3.706 -   /* Get the target resource. */
   3.707 -   found = Xen_MemorySettingData_getResourceForObjectPath(session, resources, &resource, reference);
   3.708 -   if (!found || (resource == NULL)) {
   3.709 -      _SBLIM_TRACE(1,("--- Target instance not found"));
   3.710 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_FOUND, "Target instance not found");
   3.711 -      goto exit;
   3.712 -   }
   3.713 -
   3.714 -   _SBLIM_TRACE(2,("--- instance found", found));
   3.715 -
   3.716 -   /* Delete the target resource. */
   3.717 -   int rc = Xen_MemorySettingData_deleteResource(resources, resource);
   3.718 -
   3.719 -   /* Free the resource data. */
   3.720 -   if (!Xen_MemorySettingData_freeResource(resource)) {
   3.721 -      _SBLIM_TRACE(1,("--- _freeResource() failed"));
   3.722 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data");
   3.723 -      goto exit;
   3.724 -   }
   3.725 +static CMPIrc add(const void *res_id, const void *res)
   3.726 +{
   3.727 +   (void)res_id;
   3.728 +   (void)res;
   3.729 +   
   3.730 +   return CMPI_RC_ERR_NOT_SUPPORTED; /* unsupported */
   3.731 +}
   3.732  
   3.733 -   if (rc != 1) {
   3.734 -      if (rc == -1) {
   3.735 -         _SBLIM_TRACE(1,("--- __deleteResource() unsupported"));
   3.736 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL);
   3.737 -      } else {
   3.738 -         _SBLIM_TRACE(1,("--- _deleteResource() failed"));
   3.739 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to delete resource");
   3.740 -      }
   3.741 -      goto exit;
   3.742 -   }
   3.743  
   3.744 -exit:
   3.745 -   /* Free the list of system resources. */
   3.746 -   if (!Xen_MemorySettingData_freeResources(resources)) {
   3.747 -      _SBLIM_TRACE(1,("--- _freeResources() failed"));
   3.748 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources");
   3.749 -   }
   3.750 -
   3.751 -   _SBLIM_RETURNSTATUS(status);
   3.752 +static CMPIrc delete(const void *res_id)
   3.753 +{
   3.754 +   (void)res_id;
   3.755 +   
   3.756 +   return  CMPI_RC_ERR_NOT_SUPPORTED; /* unsupported */
   3.757  }
   3.758  
   3.759  
   3.760 -// ----------------------------------------------------------------------------
   3.761 -// ExecQuery()
   3.762 -// Return a list of all the instances that satisfy the specified query filter.
   3.763 -// ----------------------------------------------------------------------------
   3.764 -static CMPIStatus ExecQuery(
   3.765 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.766 -		const CMPIContext * context,		/* [in] Additional context info, if any. */
   3.767 -		const CMPIResult * results,		/* [out] Results of this operation. */
   3.768 -		const CMPIObjectPath * reference,	/* [in] Contains the target namespace and classname. */
   3.769 -		const char * language,		/* [in] Name of the query language. */
   3.770 -		const char * query)			/* [in] Text of the query written in the query language. */
   3.771 +static CMPIrc modify(const void *res_id, const void *modified_res,
   3.772 +                     const char **properties)
   3.773  {
   3.774 -   CMPIStatus status = {CMPI_RC_OK, NULL};      /* Return status of CIM operations. */
   3.775 -   char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
   3.776 +   CMPIInstance *target_inst = (CMPIInstance *)res_id;
   3.777 +   memory_resource *resource = (memory_resource *)modified_res;
   3.778 +   CMPIInstance *modified_inst;
   3.779 +   CMPIStatus status = {CMPI_RC_OK, NULL};
   3.780 +   CMPIData data;
   3.781 +   char *inst_id;
   3.782 +   char sys_name[MAX_SYSTEM_NAME_LEN];
   3.783 +
   3.784 +   (void)properties;
   3.785 +   
   3.786 +   if (CMIsNullObject(target_inst) || resource == NULL ||
   3.787 +       resource->is_vm_record)
   3.788 +      return CMPI_RC_ERR_FAILED;
   3.789 +
   3.790 +   modified_inst = resource->u.cmpi_inst;   
   3.791 +
   3.792 +   /* Get target resource */
   3.793 +   data = CMGetProperty(target_inst, "InstanceID", &status);
   3.794 +   if ((status.rc != CMPI_RC_OK) || CMIsNullValue(data))
   3.795 +      return CMPI_RC_ERR_FAILED;
   3.796 +
   3.797 +   inst_id = CMGetCharPtr(data.value.string);
   3.798 +   if ((inst_id == NULL) || (*inst_id == '\0'))
   3.799 +      return CMPI_RC_ERR_FAILED;
   3.800 +
   3.801 +   /* Extract the system name from InstanceID property. */
   3.802 +   if (!_CMPIStrncpySystemNameFromID(sys_name, inst_id, MAX_SYSTEM_NAME_LEN))
   3.803 +      return CMPI_RC_ERR_FAILED;
   3.804 +
   3.805 +   if (!xen_utils_validate_session(&session)) {
   3.806 +      _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   3.807 +                   ("--- Unable to establish connection with Xend"));
   3.808 +      return CMPI_RC_ERR_FAILED;
   3.809 +   }
   3.810 +   
   3.811 +   /* Get the domain data for the target domain name. */
   3.812 +   xen_vm_set *vms;
   3.813 +   if (!xen_vm_get_by_name_label(session->xen, &vms, sys_name)) {
   3.814 +      _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_WARNING,
   3.815 +                   ("--- Failed to retrieve domain %s", sys_name));
   3.816 +      _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
   3.817 +                            xen_utils_trace_error(session->xen));
   3.818 +      return CMPI_RC_ERR_FAILED;
   3.819 +   }
   3.820 +
   3.821 +   assert(vms->size == 1);
   3.822 +
   3.823 +   xen_vm_record *vm_rec;
   3.824 +   if (!xen_vm_get_record(session->xen, &vm_rec, vms->contents[0])) {
   3.825 +      _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   3.826 +                   ("--- Failed to retrieve domain record for %s", sys_name));
   3.827 +      _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
   3.828 +                            xen_utils_trace_error(session->xen));
   3.829 +      xen_vm_set_free(vms);
   3.830 +      return CMPI_RC_ERR_FAILED;
   3.831 +   }
   3.832  
   3.833 -   _SBLIM_ENTER("ExecQuery");
   3.834 -   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   3.835 -   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   3.836 -   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
   3.837 -   _SBLIM_TRACE(2, ("--- language=\"%s\"", language));
   3.838 -   _SBLIM_TRACE(2, ("--- query=\"%s\"", query));
   3.839 -   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
   3.840 +   xen_vm_set_free(vms);
   3.841 +
   3.842 +   /* Only support modifying the amount of memory. */
   3.843 +   /* In what units is memory specified?  Default to 'Bytes'. */
   3.844 +   char *units = "Bytes";
   3.845 +   data = CMGetProperty(modified_inst, "AllocationUnits", &status);
   3.846 +   if ((status.rc == CMPI_RC_OK) && !CMIsNullValue(data))
   3.847 +      units = CMGetCharPtr(data.value.string);
   3.848  
   3.849 -   /* EXECQUERY() IS NOT YET SUPPORTED FOR THIS CLASS */
   3.850 -   CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL);
   3.851 +   data = CMGetProperty(modified_inst, "VirtualQuantity", &status);
   3.852 +   if ((status.rc != CMPI_RC_OK) || CMIsNullValue(data)) {
   3.853 +      _SBLIM_TRACE(1,("--- Unable to determine VirtualQuantity in Memory RASD"));
   3.854 +      xen_vm_record_free(vm_rec);
   3.855 +      return CMPI_RC_ERR_FAILED;
   3.856 +   }
   3.857 +   
   3.858 +   uint64_t req_mem = data.value.uint64;
   3.859 +   if (strstr(units, "Kilo"))
   3.860 +      req_mem = req_mem * 1024;
   3.861 +   else if (strstr(units, "Mega"))
   3.862 +      req_mem = req_mem * 1024 * 1024;
   3.863 +   else if (strstr(units, "Giga"))
   3.864 +      req_mem = req_mem * 1024 * 1024 * 1024;
   3.865 +   
   3.866 +   if ((req_mem < vm_rec->memory_static_min) || 
   3.867 +       (req_mem > vm_rec->memory_static_max)) {
   3.868 +      _SBLIM_TRACE(1,("--- Unable to set memory outside of range %lld Mb - %lld Mb",
   3.869 +                      vm_rec->memory_static_min,
   3.870 +                      vm_rec->memory_static_max));
   3.871 +      xen_vm_record_free(vm_rec);
   3.872 +      return CMPI_RC_ERR_FAILED;
   3.873 +   }
   3.874 +  
   3.875 +   /* Note:
   3.876 +    * If the VM is active, set dynamic_[max|min]_live as well as non-live
   3.877 +    * values.  Until we move to the 'dual configuration' specified in
   3.878 +    * Virtual System Profile, both state and defined configuration need to
   3.879 +    * be modified.
   3.880 +    */
   3.881 +   _SBLIM_TRACE(2,("--- modifying %s memory settings", sys_name));
   3.882 +   if (vm_rec->power_state == XEN_VM_POWER_STATE_RUNNING) {
   3.883 +      xen_vm_set_memory_dynamic_max_live(session->xen, vm_rec->handle, req_mem);
   3.884 +      xen_vm_set_memory_dynamic_min_live(session->xen, vm_rec->handle, req_mem);
   3.885 +   }
   3.886 +      
   3.887 +   xen_vm_set_memory_dynamic_max(session->xen, vm_rec->handle, req_mem);
   3.888 +   xen_vm_set_memory_dynamic_min(session->xen, vm_rec->handle, req_mem);
   3.889  
   3.890 -   CMReturnDone(results);
   3.891 -
   3.892 -exit:
   3.893 -   _SBLIM_RETURNSTATUS(status);
   3.894 +   if (!session->xen->ok) {
   3.895 +      _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   3.896 +                   ("--- Failed to set dynamic memory values for %s", sys_name));
   3.897 +      _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
   3.898 +                            xen_utils_trace_error(session->xen));
   3.899 +      xen_vm_record_free(vm_rec);
   3.900 +      return CMPI_RC_ERR_FAILED;
   3.901 +   }
   3.902 +      
   3.903 +   xen_vm_record_free(vm_rec);
   3.904 +   return CMPI_RC_OK;
   3.905  }
   3.906  
   3.907 -// ----------------------------------------------------------------------------
   3.908 -// Initialize()
   3.909 -// Perform any necessary initialization immediately after this provider is
   3.910 -// first loaded.
   3.911 -// ----------------------------------------------------------------------------
   3.912 -static void Initialize(
   3.913 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.914 -		const CMPIContext * context)		/* [in] Additional context info, if any. */
   3.915 +
   3.916 +/* Set CMPIInstance properties from the resource data. */
   3.917 +static CMPIrc setproperties(CMPIInstance *inst, const void *res,
   3.918 +                            const char **properties)
   3.919  {
   3.920 -   _SBLIM_ENTER("Initialize");
   3.921 -   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   3.922 -   //   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   3.923 +   char buf[1024];
   3.924 +
   3.925 +   (void)properties;
   3.926 +   
   3.927 +   if (res == NULL)
   3.928 +      return CMPI_RC_ERR_FAILED;
   3.929 +
   3.930 +   if (CMIsNullObject(inst))
   3.931 +      return CMPI_RC_ERR_FAILED;
   3.932 +
   3.933 +   if (!((memory_resource *)res)->is_vm_record)
   3.934 +      return CMPI_RC_ERR_FAILED;
   3.935 +   
   3.936 +   xen_vm_record *vm_rec = ((memory_resource *)res)->u.vm_rec;
   3.937 +
   3.938 +   /* Set the CMPIInstance properties from the resource data. */
   3.939 +   snprintf(buf, 1024, "Xen:%s:Memory0", vm_rec->name_label);
   3.940 +   CMSetProperty(inst, "InstanceID", (CMPIValue *)buf, CMPI_chars);
   3.941 +
   3.942 +   CMSetProperty(inst, "ElementName", (CMPIValue *)"Memory0", CMPI_chars);
   3.943 +
   3.944 +   int type = 4; /* 4 == Memory */
   3.945 +   CMSetProperty(inst, "ResourceType", (CMPIValue *)&type, CMPI_uint16);
   3.946  
   3.947 -   /* Initialized Xen session object. */
   3.948 -   if (session == NULL)
   3.949 -      xen_utils_xen_init(&session);
   3.950 +   int consumerVisibility = 2; /* 2 == Passed-Through */
   3.951 +   CMSetProperty(inst, "ConsumerVisibility",
   3.952 +                 (CMPIValue *)&consumerVisibility, CMPI_uint16);
   3.953  
   3.954 -   _SBLIM_RETURN();
   3.955 +   int64_t memory;
   3.956 +   // Get the memory_actual
   3.957 +   if (vm_rec->metrics->is_record)
   3.958 +      memory = vm_rec->metrics->u.record->memory_actual;
   3.959 +   else	
   3.960 +      xen_vm_metrics_get_memory_actual(session->xen, &memory,
   3.961 +                                       vm_rec->metrics->u.handle);;
   3.962 +   CMSetProperty(inst, "Reservation", (CMPIValue *)&memory, CMPI_uint64);
   3.963 +   memory = vm_rec->memory_dynamic_max;
   3.964 +   CMSetProperty(inst, "VirtualQuantity", (CMPIValue *)&memory, CMPI_uint64);
   3.965 +   CMSetProperty(inst, "Limit", (CMPIValue *)&memory, CMPI_uint64);
   3.966 +   
   3.967 +   CMSetProperty(inst, "AllocationUnits", (CMPIValue *)"Bytes", CMPI_chars);
   3.968 +
   3.969 +   int alloctype = 1;
   3.970 +   CMSetProperty(inst, "AutomaticAllocation",
   3.971 +                 (CMPIValue *)&alloctype, CMPI_boolean);
   3.972 +   CMSetProperty(inst, "AutomaticDeallocation",
   3.973 +                 (CMPIValue *)&alloctype, CMPI_boolean);
   3.974 +
   3.975 +   /*
   3.976 +    * TODO:
   3.977 +    * PoolID, Weight, HostResource
   3.978 +    */
   3.979 +
   3.980 +   return CMPI_RC_OK;
   3.981  }
   3.982  
   3.983 -// ============================================================================
   3.984 -// CMPI INSTANCE PROVIDER FUNCTION TABLE SETUP
   3.985 -// ============================================================================
   3.986 -CMInstanceMIStub( , Xen_MemorySettingData, _BROKER, Initialize(&mi, ctx));
   3.987 +
   3.988 +/*
   3.989 + * Set resource data from the CMPIInstance properties.  Only needs to
   3.990 + * be implemented if add() and/or modify() are supported.
   3.991 + */
   3.992 +static CMPIrc extract(void **res, const CMPIInstance *inst,
   3.993 +                      const char **properties)
   3.994 +{
   3.995 +   memory_resource *resource;
   3.996 +   
   3.997 +   (void)properties;
   3.998 +   
   3.999 +   /* Get memory for resource. */
  3.1000 +   resource = (memory_resource *)calloc(1, sizeof(memory_resource));
  3.1001 +   if (resource == NULL)
  3.1002 +      return CMPI_RC_ERR_FAILED;
  3.1003 +
  3.1004 +   resource->u.cmpi_inst = (CMPIInstance *)inst;
  3.1005 +   *res = (void *)resource;
  3.1006 +   return CMPI_RC_OK;
  3.1007 +}
  3.1008 +
  3.1009 +
  3.1010 +/* Get resource id from CMPIInstance properties. */
  3.1011 +static CMPIrc extractid(void **res_id, const CMPIInstance* inst)
  3.1012 +{
  3.1013 +   *res_id = (void *)inst;
  3.1014 +   return CMPI_RC_OK;
  3.1015 +}
  3.1016 +
  3.1017 +
  3.1018 +/* Release resource id created in resId4inst(). */
  3.1019 +static void releaseid(void* res_id)
  3.1020 +{
  3.1021 +   (void)res_id;
  3.1022 +}
  3.1023 +
  3.1024 +
  3.1025 +/* Setup CMPILIFY function tables and instance provider entry point.*/
  3.1026 +/* CMPILIFYInstanceMIStub(<CLASS>,<PROVIDER_NAME>,<keys>,<CMPIInstanceMI_HANDLE>) */
  3.1027 +static char * keys[] = {"InstanceID", NULL};
  3.1028 +
  3.1029 +CMPILIFYInstanceMIStub(Xen_MemorySettingData, Xen_MemorySettingData, keys, mi)
     4.1 --- a/src/Xen_MemorySettingData_Resource.c	Mon Jul 16 17:22:22 2007 -0600
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,232 +0,0 @@
     4.4 -// Copyright (C) 2006 IBM Corporation
     4.5 -//
     4.6 -//    This library is free software; you can redistribute it and/or
     4.7 -//    modify it under the terms of the GNU Lesser General Public
     4.8 -//    License as published by the Free Software Foundation; either
     4.9 -//    version 2.1 of the License, or (at your option) any later version.
    4.10 -//
    4.11 -//    This library is distributed in the hope that it will be useful,
    4.12 -//    but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.13 -//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    4.14 -//    Lesser General Public License for more details.
    4.15 -//
    4.16 -//    You should have received a copy of the GNU Lesser General Public
    4.17 -//    License along with this library; if not, write to the Free Software
    4.18 -//    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    4.19 -// ============================================================================
    4.20 -// Authors:       Dr. Gareth S. Bestor, <bestor@us.ibm.com>
    4.21 -// Contributors:  Jim Fehlig, <jfehlig@novell.com>
    4.22 -//		  Raj Subrahmanian <raj.subrahmanian@unisys.com>
    4.23 -// Description:   
    4.24 -// ============================================================================
    4.25 -
    4.26 -#include <stdlib.h>
    4.27 -#include <string.h>
    4.28 -#include <assert.h>
    4.29 -
    4.30 -#include <xen_common.h>
    4.31 -#include <xen_vm.h>
    4.32 -#include <xen_vm_metrics.h>
    4.33 -#include "Xen_MemorySettingData_Resource.h"
    4.34 -
    4.35 -/* Include the required CMPI data types, function headers, and macros. */
    4.36 -#include "cmpidt.h"
    4.37 -#include "cmpift.h"
    4.38 -#include "cmpimacs.h"
    4.39 -
    4.40 -/* Include _SBLIM_TRACE() logging support */
    4.41 -#include "cmpitrace.h"
    4.42 -
    4.43 -#include "xen_utils.h"
    4.44 -#include "provider_common.h"
    4.45 -
    4.46 -// ----------------------------------------------------------------------------
    4.47 -
    4.48 -/* Get a handle to the list of all system resources for this class. */
    4.49 -int Xen_MemorySettingData_getResources(xen_utils_session *session,
    4.50 -                                       _RESOURCES ** resources)
    4.51 -{
    4.52 -   return xen_utils_get_domain_resources(session, resources);
    4.53 -}
    4.54 -
    4.55 -// ----------------------------------------------------------------------------
    4.56 -
    4.57 -/* Free/deallocate/cleanup the resources list after use. */
    4.58 -int Xen_MemorySettingData_freeResources(_RESOURCES * resources)
    4.59 -{
    4.60 -   return xen_utils_free_domain_resources(resources);
    4.61 -}
    4.62 -
    4.63 -// ----------------------------------------------------------------------------
    4.64 -
    4.65 -/* Iterator to get the next resource from the resources list. */
    4.66 -int Xen_MemorySettingData_getNextResource(xen_utils_session *session,
    4.67 -                                          _RESOURCES * resources,
    4.68 -                                          _RESOURCE ** resource)
    4.69 -{
    4.70 -   return xen_utils_get_next_domain_resource(session, resources, resource);
    4.71 -}
    4.72 -
    4.73 -// ----------------------------------------------------------------------------
    4.74 -
    4.75 -/* Get the specific resource that matches the CMPI object path. */
    4.76 -int Xen_MemorySettingData_getResourceForObjectPath(xen_utils_session *session,
    4.77 -                                                   _RESOURCES * resources,
    4.78 -                                                   _RESOURCE ** resource,
    4.79 -                                                   const CMPIObjectPath * objectpath)
    4.80 -{
    4.81 -   char *instId;
    4.82 -   char name [MAX_SYSTEM_NAME_LEN];
    4.83 -   CMPIStatus status = {CMPI_RC_OK, NULL};	/* Return status of CIM operations. */
    4.84 -
    4.85 -   /* Check input params are valid. */
    4.86 -   if (resources == NULL) return 0;
    4.87 -   if (CMIsNullObject(objectpath)) return 0;
    4.88 -
    4.89 -   /* Obtain the target resource identifier from the CMPIObjectPath key(s). */
    4.90 -   CMPIData iddata = CMGetKey(objectpath, "InstanceID", &status);
    4.91 -   if ((status.rc != CMPI_RC_OK) || CMIsNullValue(iddata)) return 0;
    4.92 -
    4.93 -   /* Extract the id string from the CMPIString. */
    4.94 -   instId = CMGetCharPtr(iddata.value.string);
    4.95 -   if ((instId == NULL) || (*instId == '\0')) return 0;
    4.96 -
    4.97 -   /* Extract the system name from InstanceID property. */
    4.98 -   if (!_CMPIStrncpySystemNameFromID(name, instId, MAX_SYSTEM_NAME_LEN))
    4.99 -      return 0;
   4.100 -
   4.101 -   /* Get the domain data for the target domain name. */
   4.102 -   xen_vm_set *vms;
   4.103 -   if (!xen_vm_get_by_name_label(session->xen, &vms, name)) {
   4.104 -      /* Error is in session object! */
   4.105 -      *resource = NULL;
   4.106 -      return 0;
   4.107 -   }
   4.108 -
   4.109 -   assert(vms->size == 1);
   4.110 -   if (!xen_vm_get_record(session->xen, resource, vms->contents[0])) {
   4.111 -      /* Error description in session object! */
   4.112 -      xen_vm_set_free(vms);
   4.113 -      return 0;
   4.114 -   }
   4.115 -
   4.116 -   xen_vm_set_free(vms);
   4.117 -
   4.118 -   return 1;
   4.119 -}
   4.120 -
   4.121 -// ----------------------------------------------------------------------------
   4.122 -
   4.123 -/* Free/deallocate/cleanup the resource after use. */
   4.124 -int Xen_MemorySettingData_freeResource(_RESOURCE * resource)
   4.125 -{
   4.126 -   return xen_utils_free_domain_resource(resource);
   4.127 -}
   4.128 -
   4.129 -// ---------------------------------------------------------------------------- 
   4.130 -
   4.131 -/* Set the property values of a CMPI instance from a specific resource. */
   4.132 -int Xen_MemorySettingData_setInstanceFromResource(xen_utils_session *session,
   4.133 -                                                  _RESOURCE * resource,
   4.134 -                                                  const CMPIInstance * instance,
   4.135 -                                                  const CMPIBroker * broker)
   4.136 -{
   4.137 -   char buf[1024];
   4.138 -
   4.139 -   if (resource == NULL) return 0;
   4.140 -   if (CMIsNullObject(instance)) return 0;
   4.141 -
   4.142 -   /* Set the CMPIInstance properties from the resource data. */
   4.143 -   snprintf(buf, 1024, "Xen:%s:Memory1", resource->name_label);
   4.144 -   CMSetProperty(instance, "InstanceID",(CMPIValue *)buf, CMPI_chars);
   4.145 -
   4.146 -   CMSetProperty(instance, "ElementName",(CMPIValue *)"Memory1", CMPI_chars);
   4.147 -
   4.148 -   int type = 4; /* 4 == Memory */
   4.149 -   CMSetProperty(instance, "ResourceType",(CMPIValue *)&type, CMPI_uint16);
   4.150 -
   4.151 -   int consumerVisibility = 2; /* 2 == Passed-Through */
   4.152 -   CMSetProperty(instance, "ConsumerVisibility" , (CMPIValue *)&consumerVisibility, CMPI_uint16);
   4.153 -
   4.154 -   int64_t memory;
   4.155 -   // Get the memory_actual
   4.156 -   if (resource->metrics->is_record)
   4.157 -	memory=resource->metrics->u.record->memory_actual;
   4.158 -   else	
   4.159 -	xen_vm_metrics_get_memory_actual(session->xen, &memory, resource->metrics->u.handle);;
   4.160 -   CMSetProperty(instance, "Reservation",(CMPIValue *)&memory, CMPI_uint64);
   4.161 -   memory = resource->memory_dynamic_max;
   4.162 -   CMSetProperty(instance, "VirtualQuantity",(CMPIValue *)&memory, CMPI_uint64);
   4.163 -   CMSetProperty(instance, "Limit",(CMPIValue *)&memory, CMPI_uint64);
   4.164 -   
   4.165 -   CMSetProperty(instance, "AllocationUnits",(CMPIValue *)"Bytes", CMPI_chars);
   4.166 -
   4.167 -   int alloctype = 1;
   4.168 -   CMSetProperty(instance, "AutomaticAllocation" , (CMPIValue *)&alloctype, CMPI_boolean);
   4.169 -   CMSetProperty(instance, "AutomaticDeallocation" , (CMPIValue *)&alloctype, CMPI_boolean);
   4.170 -
   4.171 -   /*
   4.172 -    * TODO:
   4.173 -    * PoolID, Weight, HostResource
   4.174 -    */
   4.175 -
   4.176 -   return 1;
   4.177 -}
   4.178 -
   4.179 -// ----------------------------------------------------------------------------
   4.180 -
   4.181 -/* Delete the specified resource from the system. */
   4.182 -int Xen_MemorySettingData_deleteResource(_RESOURCES * resources,
   4.183 -                                         _RESOURCE * resource)
   4.184 -{
   4.185 -   /* Unsupported. */
   4.186 -   return -1;
   4.187 -}
   4.188 -
   4.189 -// ----------------------------------------------------------------------------
   4.190 -
   4.191 -/* Modify the specified resource using the property values of a CMPI instance. */
   4.192 -int Xen_MemorySettingData_setResourceFromInstance(xen_utils_session *session,
   4.193 -                                                  _RESOURCE * resource,
   4.194 -                                                  const CMPIInstance * instance)
   4.195 -{
   4.196 -   CMPIData propertyvalue;
   4.197 -   uint64_t req_mem;
   4.198 -
   4.199 -   CMPIStatus status = {CMPI_RC_OK, NULL};
   4.200 -   
   4.201 -   /* Only support modifying the amount of memory. */
   4.202 -   _SBLIM_TRACE(2,("--- modifying %s memory settings", resource->name_label));
   4.203 -   propertyvalue = CMGetProperty(instance, "VirtualQuantity", &status);
   4.204 -   if ((status.rc != CMPI_RC_OK) || CMIsNullValue(propertyvalue)) {
   4.205 -      _SBLIM_TRACE(1,("--- Unable to determine VirtualQuantity in Memory RASD"));
   4.206 -      return 0;
   4.207 -   }
   4.208 -      
   4.209 -   req_mem = propertyvalue.value.uint64;
   4.210 -   if ((req_mem < resource->memory_static_min) || 
   4.211 -       (req_mem > resource->memory_static_max)) {
   4.212 -      _SBLIM_TRACE(1,("--- Unable to set memory outside of range %lld Mb - %lld Mb",
   4.213 -                      resource->memory_static_min,
   4.214 -                      resource->memory_static_max));
   4.215 -      return 0;
   4.216 -   }
   4.217 -
   4.218 -   if (req_mem > resource->memory_dynamic_max)
   4.219 -      return (xen_vm_set_memory_dynamic_max(session->xen, resource->handle, req_mem));
   4.220 -   else
   4.221 -      return (xen_vm_set_memory_dynamic_max(session->xen, resource->handle, req_mem));
   4.222 -}
   4.223 -
   4.224 -// ----------------------------------------------------------------------------
   4.225 -
   4.226 -/* Create a new resource using the property values of a CMPI instance. */
   4.227 -int Xen_MemorySettingData_createResourceFromInstance(_RESOURCES * resources,
   4.228 -                                                     _RESOURCE ** resource,
   4.229 -                                                     const CMPIInstance * instance,
   4.230 -                                                     const CMPIBroker * broker)
   4.231 -{
   4.232 -   /* Unsupported. */
   4.233 -   return -1;
   4.234 -}
   4.235 -
     5.1 --- a/src/Xen_MemorySettingData_Resource.h	Mon Jul 16 17:22:22 2007 -0600
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,101 +0,0 @@
     5.4 -// Copyright (C) 2006 IBM Corporation
     5.5 -//
     5.6 -//    This library is free software; you can redistribute it and/or
     5.7 -//    modify it under the terms of the GNU Lesser General Public
     5.8 -//    License as published by the Free Software Foundation; either
     5.9 -//    version 2.1 of the License, or (at your option) any later version.
    5.10 -//
    5.11 -//    This library is distributed in the hope that it will be useful,
    5.12 -//    but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.13 -//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    5.14 -//    Lesser General Public License for more details.
    5.15 -//
    5.16 -//    You should have received a copy of the GNU Lesser General Public
    5.17 -//    License along with this library; if not, write to the Free Software
    5.18 -//    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    5.19 -// ============================================================================
    5.20 -// Authors:       Dr. Gareth S. Bestor, <bestor@us.ibm.com>
    5.21 -// Contributors:  Jim Fehlig, <jfehlig@novell.com>
    5.22 -// Description:
    5.23 -// ============================================================================
    5.24 -
    5.25 -/* Include required libxen headers. */
    5.26 -#include <xen_common.h>
    5.27 -#include <xen_vm.h>
    5.28 -
    5.29 -#include "xen_utils.h"
    5.30 -
    5.31 -/*** CUSTOMIZE FOR EACH PROVIDER ***/
    5.32 -/* DEFINE A HANDLE TO REPRESENT THE 'LIST' OF ALL SYSTEM RESOURCES.
    5.33 -   THE MAIN PROVIDER CODE DOES NOT NEED TO KNOW THE PARTICULARS OF HOW THIS
    5.34 -   LIST IS IMPLEMENTED - IT MAY BE AN ARRAY, LINKED LIST, FILE, ETC.
    5.35 -   THIS HANDLE IS PASSED INTO THE APPROPRIATE RESOURCE ACCESS METHODS WHEN
    5.36 -   ACCESSING/ITERATING/ADDING/REMOVING RESOURCES INSTANCES. */
    5.37 -typedef xen_domain_resources  _RESOURCES;
    5.38 -
    5.39 -/*** CUSTOMIZE FOR EACH PROVIDER ***/
    5.40 -/* DEFINE A HANDLE TO BE USED FOR EACH INSTANCE OF A SYSTEM RESOURCE.
    5.41 -   THE MAIN PROVIDER CODE DOES NOT NEED TO KNOW THE PARTICULARS OF HOW EACH
    5.42 -   RESOURCE IS REPRESENTED, BUT TYPICALLY IT IS A STRUCTURE MIRRORING THE
    5.43 -   PROPERTIES IN THE CIM CLASS. THIS HANDLE IS PASSED BETWEEN THE RESOURCE
    5.44 -   ACCESS METHODS WHEN MANIPULATING SPECIFIC RESOURCE INSTANCES. */
    5.45 -typedef xen_vm_record  _RESOURCE;
    5.46 -
    5.47 -
    5.48 -/* NOTHING BELOW THIS LINE SHOULD NEED TO BE CHANGED. */
    5.49 -
    5.50 -/* Include the required CMPI data types. */
    5.51 -#include "cmpidt.h"
    5.52 -
    5.53 -// ----------------------------------------------------------------------------
    5.54 -// Generic resource access methods for CMPI providers.
    5.55 -// Return value:
    5.56 -//	-1 = Unsupported
    5.57 -//	 0 = Failed
    5.58 -//	 1 = OK
    5.59 -// ----------------------------------------------------------------------------
    5.60 -
    5.61 -/* Get a handle to the list of all system resources for this class. */
    5.62 -int Xen_MemorySettingData_getResources(xen_utils_session *session,
    5.63 -                                       _RESOURCES ** resources);
    5.64 -
    5.65 -/* Free/deallocate/cleanup the resources list after use. */
    5.66 -int Xen_MemorySettingData_freeResources(_RESOURCES * resources);
    5.67 -
    5.68 -/* Iterator to get the next resource from the resources list. */
    5.69 -int Xen_MemorySettingData_getNextResource(xen_utils_session *session,
    5.70 -                                          _RESOURCES * resources,
    5.71 -                                          _RESOURCE ** resource);
    5.72 -
    5.73 -/* Get the specific resource that matches the CMPI object path. */
    5.74 -int Xen_MemorySettingData_getResourceForObjectPath(xen_utils_session *session,
    5.75 -                                                   _RESOURCES * resources,
    5.76 -                                                   _RESOURCE ** resource,
    5.77 -                                                   const CMPIObjectPath * objectpath);
    5.78 -
    5.79 -/* Free/deallocate/cleanup a resource after use. */
    5.80 -int Xen_MemorySettingData_freeResource(_RESOURCE * resource);
    5.81 -
    5.82 -/* Set the property values of a CMPI instance from a specific resource. */
    5.83 -int Xen_MemorySettingData_setInstanceFromResource(xen_utils_session *session,
    5.84 -						  _RESOURCE * resource,
    5.85 -                                                  const CMPIInstance * instance,
    5.86 -                                                  const CMPIBroker * broker);
    5.87 -
    5.88 -// THE FOLLOWING METHODS MAY/NOT BE SUPPORTED BY THE SYSTEM FOR THIS CLASS
    5.89 -
    5.90 -/* Delete the specified resource from the system. */
    5.91 -int Xen_MemorySettingData_deleteResource(_RESOURCES * resources,
    5.92 -                                         _RESOURCE * resource);
    5.93 -
    5.94 -/* Modify the specified resource using the property values of a CMPI instance. */
    5.95 -int Xen_MemorySettingData_setResourceFromInstance(xen_utils_session *session,
    5.96 -                                                  _RESOURCE * resource,
    5.97 -                                                  const CMPIInstance * instance);
    5.98 -
    5.99 -/* Create a new resource using the property values of a CMPI instance. */
   5.100 -int Xen_MemorySettingData_createResourceFromInstance(_RESOURCES * resources,
   5.101 -                                                     _RESOURCE ** resource,
   5.102 -                                                     const CMPIInstance * instance,
   5.103 -                                                     const CMPIBroker * broker);
   5.104 -