os-cmpi-xen

changeset 134:3a6f2019ef11

Ported Xen_Console to 'Cmpilify' interface. Removed corresponding resource files
that are no longer used.

Signed-off-by: Jim Fehlig <jfehlig@novell.com>
author Jim Fehlig <jfehlig@novell.com>
date Thu Jul 19 18:04:38 2007 -0600 (2007-07-19)
parents 3d8f3aba0dd8
children da5a3ccd0c25
files ChangeLog src/Makefile.am src/Xen_Console.c src/Xen_Console_Resource.c src/Xen_Console_Resource.h
line diff
     1.1 --- a/ChangeLog	Thu Jul 19 15:17:54 2007 -0600
     1.2 +++ b/ChangeLog	Thu Jul 19 18:04:38 2007 -0600
     1.3 @@ -1,3 +1,9 @@
     1.4 +-------------------------------------------------------------------
     1.5 +Thu Jul 19 18:02:01 MDT 2007 - jfehlig@novell.com
     1.6 +
     1.7 +         - Ported Xen_Console to 'Cmpilify' interface.  Removed
     1.8 +           corresponding resource files that are no longer used.
     1.9 +
    1.10  -------------------------------------------------------------------
    1.11  Thu Jul 19 11:33:04 MDT 2007 - jfehlig@novell.com
    1.12  
     2.1 --- a/src/Makefile.am	Thu Jul 19 15:17:54 2007 -0600
     2.2 +++ b/src/Makefile.am	Thu Jul 19 18:04:38 2007 -0600
     2.3 @@ -49,7 +49,6 @@ noinst_HEADERS = \
     2.4  	Xen_ComputerSystem_Resource.h \
     2.5  	Xen_VirtualSystemManagementService_Resource.h \
     2.6  	Xen_NetworkPort_Resource.h \
     2.7 -	Xen_Console_Resource.h \
     2.8  	Xen_VirtualizationCapabilities_Resource.h \
     2.9  	Xen_NetworkPortSettingData_Resource.h \
    2.10  	Xen_ConsoleSettingData_Resource.h \
    2.11 @@ -193,7 +192,7 @@ libXen_NetworkPort_la_CFLAGS = -I../ @LI
    2.12  libXen_NetworkPort_la_LIBADD = libXen_ProviderCommon.la
    2.13  libXen_NetworkPort_la_LDFLAGS = -module -avoid-version -no-undefined
    2.14  
    2.15 -libXen_Console_la_SOURCES = Xen_Console.c Xen_Console_Resource.c
    2.16 +libXen_Console_la_SOURCES = Xen_Console.c
    2.17  libXen_Console_la_CFLAGS = -I../ @LIBXEN_CFLAGS@
    2.18  libXen_Console_la_LIBADD = libXen_ProviderCommon.la
    2.19  libXen_Console_la_LDFLAGS = -module -avoid-version -no-undefined
     3.1 --- a/src/Xen_Console.c	Thu Jul 19 15:17:54 2007 -0600
     3.2 +++ b/src/Xen_Console.c	Thu Jul 19 18:04:38 2007 -0600
     3.3 @@ -1,4 +1,4 @@
     3.4 -// Copyright (C) 2006 Unisys Corporation
     3.5 +// Copyright (C) 2007 Novell, Inc.
     3.6  //
     3.7  //    This library is free software; you can redistribute it and/or
     3.8  //    modify it under the terms of the GNU Lesser General Public
     3.9 @@ -15,630 +15,327 @@
    3.10  //    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    3.11  // ============================================================================
    3.12  // Authors:       Rajagopalan Subrahmanian, <raj.subrahmanian@unisys.com>
    3.13 -// Contributors:  
    3.14 -// Description: This file 
    3.15 +// Contributors:  Jim Fehlig, <jfehlig@novell.com>
    3.16 +//
    3.17 +// Description:  Implementation of Console logical device for Xen
    3.18  // ============================================================================
    3.19  
    3.20 -/* Include the required CMPI data types, function headers, and macros */
    3.21 -#include "cmpidt.h"
    3.22 -#include "cmpift.h"
    3.23 -#include "cmpimacs.h"
    3.24 +/* Common declarations for each CMPI "Cimpler" instance provider */
    3.25 +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    3.26 +#include <cmpidt.h>
    3.27 +#include <cmpimacs.h>
    3.28 +
    3.29 +#include "cmpilify.h"
    3.30 +
    3.31 +
    3.32 +static const CMPIInstanceMI* mi;
    3.33 +
    3.34  
    3.35 -/* Include utility functions */
    3.36 -#include "cmpiutil.h"
    3.37 +#define _BROKER (((CMPILIFYInstanceMI*)(mi->hdl))->brkr)
    3.38 +#define _CLASS (((CMPILIFYInstanceMI*)(mi->hdl))->cn)
    3.39 +#define _KEYS (((CMPILIFYInstanceMI*)(mi->hdl))->kys)
    3.40 +
    3.41 +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    3.42  
    3.43 -/* Include _SBLIM_TRACE() logging support */
    3.44 +#include <stdlib.h>
    3.45 +#include <assert.h>
    3.46 +
    3.47 +#include <xen_common.h>
    3.48 +#include <xen_vm.h>
    3.49 +#include <xen_vm_power_state.h>
    3.50 +#include <xen_console.h>
    3.51 +
    3.52  #include "cmpitrace.h"
    3.53 -
    3.54 -/* Include Xen utilities */
    3.55  #include "xen_utils.h"
    3.56  
    3.57 -/* Include the abstract resource access functions and abstracted _RESOURCES and _RESOURCE data types. */
    3.58 -#include "Xen_Console_Resource.h"
    3.59 +
    3.60 +/* C struct to store the data for all resources. */
    3.61 +typedef struct {
    3.62 +   xen_console_set *consoles;
    3.63 +   unsigned int cur_console;
    3.64 +} console_resources;
    3.65  
    3.66  
    3.67 -// ----------------------------------------------------------------------------
    3.68 -// COMMON GLOBAL VARIABLES
    3.69 -// ----------------------------------------------------------------------------
    3.70 +/* Class keys */
    3.71 +static const char *keys[] = {"SystemCreationClassName", "SystemName",
    3.72 +                             "CreationClassName", "DeviceID", NULL};
    3.73  
    3.74 -/* Handle to the CIM broker. Initialized when the provider lib is loaded. */
    3.75 -static const CMPIBroker *_BROKER;
    3.76  
    3.77  /* Xen session object.  Initialize when the provider is loaded, close when
    3.78   * provider unloaded. */
    3.79  static xen_utils_session *session = NULL;
    3.80  
    3.81  
    3.82 -// ============================================================================
    3.83 -// CMPI INSTANCE PROVIDER FUNCTION TABLE
    3.84 -// ============================================================================
    3.85 -
    3.86 -// ----------------------------------------------------------------------------
    3.87 -// Info for the class supported by the instance provider
    3.88 -// ----------------------------------------------------------------------------
    3.89 -
    3.90 -/* Name of the class implemented by this instance provider. */
    3.91 -/*** CUSTOMIZE FOR EACH PROVIDER ***/
    3.92 -static char * _CLASSNAME = "Xen_Console";
    3.93 -
    3.94 -/* NULL terminated list of key properties of this class. */
    3.95 -/*** CUSTOMIZE FOR EACH PROVIDER ***/
    3.96 -const static char * _KEYNAMES[] = {"SystemName", "SystemCreationClassName", "DeviceID", "CreationClassName", NULL};
    3.97 +static CMPIrc load()
    3.98 +{
    3.99 +   /* Initialized Xen session object. */
   3.100 +   if (!session)
   3.101 +      xen_utils_xen_init(&session);
   3.102  
   3.103 -// ----------------------------------------------------------------------------
   3.104 -// Cleanup()
   3.105 -// Perform any necessary cleanup immediately before this provider is unloaded.
   3.106 -// ----------------------------------------------------------------------------
   3.107 -static CMPIStatus Cleanup(
   3.108 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.109 -		const CMPIContext * context,		/* [in] Additional context info, if any. */
   3.110 -        CMPIBoolean terminating)   /* [in] True if MB is terminating */
   3.111 +   return CMPI_RC_OK;
   3.112 +}
   3.113 +
   3.114 +
   3.115 +static CMPIrc unload(const int terminating)
   3.116  {
   3.117 -   CMPIStatus status = { CMPI_RC_OK, NULL };	/* Return status of CIM operations. */
   3.118 -
   3.119 -   _SBLIM_ENTER("Cleanup");
   3.120 -   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   3.121 -   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   3.122 -
   3.123 +   (void)terminating;
   3.124 +   
   3.125 +   /* Close Xen session object. */
   3.126     if (session) {
   3.127        xen_utils_xen_close(session);
   3.128        session = NULL;
   3.129     }
   3.130 -   _SBLIM_RETURNSTATUS(status);
   3.131 +
   3.132 +   return CMPI_RC_OK;
   3.133  }
   3.134  
   3.135 -// ----------------------------------------------------------------------------
   3.136 -// EnumInstanceNames()
   3.137 -// Return a list of all the instances names (return their object paths only).
   3.138 -// ----------------------------------------------------------------------------
   3.139 -static CMPIStatus EnumInstanceNames(
   3.140 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.141 -		const CMPIContext * context,		/* [in] Additional context info, if any. */
   3.142 -		const CMPIResult * results,		/* [out] Results of this operation. */
   3.143 -		const CMPIObjectPath * reference) 	/* [in] Contains target namespace and classname. */
   3.144 +
   3.145 +static CMPIrc begin(void **res_list, const char **properties)
   3.146  {
   3.147 -   CMPIStatus status = {CMPI_RC_OK, NULL};	/* Return status of CIM operations. */
   3.148 -   _RESOURCES * resources;			/* Handle to the list of system resources. */
   3.149 -   _RESOURCE * resource;			/* Handle to each system resource. */
   3.150 -   char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
   3.151 -   int found = 0;				/* Found any instances? */
   3.152 -  
   3.153 -   _SBLIM_ENTER("EnumInstanceNames");
   3.154 -   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   3.155 -   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   3.156 -   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
   3.157 -   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
   3.158 -
   3.159 +   console_resources *resources;
   3.160 +   
   3.161 +   (void)properties;
   3.162 +   
   3.163     if (!xen_utils_validate_session(&session)) {
   3.164 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon");
   3.165 -      goto exit;
   3.166 -   }
   3.167 -
   3.168 -   /* Get a handle to the list of system resources. */
   3.169 -   if (!Xen_Console_getResources(session, &resources)) {
   3.170 -      _SBLIM_TRACE(1,("--- _getResources() failed"));
   3.171 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources");
   3.172 -      goto exit;
   3.173 -   }
   3.174 -
   3.175 -   /* Enumerate thru the list of system resources and return a CMPIInstance for each. */
   3.176 -   while (Xen_Console_getNextResource(session, resources, &resource)) {
   3.177 -      /* Create a new CMPIInstance to store this resource. */
   3.178 -      CMPIInstance * instance = _CMNewInstance(_BROKER, namespace, _CLASSNAME, &status);
   3.179 -      if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instance)) {
   3.180 -         _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status.msg)));
   3.181 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIInstance");
   3.182 -         goto exit;
   3.183 -      }
   3.184 -
   3.185 -      /* Set the instance property values from the resource data. */
   3.186 -      if (!Xen_Console_setInstanceFromResource(session, resource, instance, _BROKER)) {
   3.187 -         _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed"));
   3.188 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data");
   3.189 -         goto exit;
   3.190 -      }
   3.191 -
   3.192 -      /* Free the resource data. */
   3.193 -      if (!Xen_Console_freeResource(resource)) {
   3.194 -         _SBLIM_TRACE(1,("--- _freeResource() failed"));
   3.195 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data");
   3.196 -         goto exit;
   3.197 -      }
   3.198 -
   3.199 -      /* Return the CMPIObjectPath for this instance. */
   3.200 -      CMPIObjectPath * objectpath = CMGetObjectPath(instance, &status);
   3.201 -      if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
   3.202 -         _SBLIM_TRACE(1,("--- CMGetObjectPath() failed - %s", CMGetCharPtr(status.msg)));
   3.203 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot get CMPIObjectPath for instance");
   3.204 -         goto exit;
   3.205 -      }
   3.206 -      CMSetNameSpace(objectpath, namespace); /* Note - CMGetObjectPath() does not preserve the namespace! */
   3.207 -     
   3.208 -      _SBLIM_TRACE(3,("--- objectpath=\"%s\"", CMGetCharPtr(CDToString(_BROKER, objectpath, NULL))));
   3.209 -      CMReturnObjectPath(results, objectpath);
   3.210 -      found++;
   3.211 -   }
   3.212 -
   3.213 -   _SBLIM_TRACE(2,("--- %d object paths found", found));
   3.214 -   CMReturnDone(results);
   3.215 -
   3.216 -exit:
   3.217 -   /* Free the list of system resources. */
   3.218 -   if (!Xen_Console_freeResources(resources)) {
   3.219 -      _SBLIM_TRACE(1,("--- _freeResources() failed"));
   3.220 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources");
   3.221 -   }
   3.222 -  
   3.223 -   _SBLIM_RETURNSTATUS(status);
   3.224 -}
   3.225 -
   3.226 -// ----------------------------------------------------------------------------
   3.227 -// EnumInstances()
   3.228 -// Return a list of all the instances (return all the instance data).
   3.229 -// ----------------------------------------------------------------------------
   3.230 -static CMPIStatus EnumInstances(
   3.231 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.232 -		const CMPIContext * context,		/* [in] Additional context info, if any. */
   3.233 -		const CMPIResult * results,		/* [out] Results of this operation. */
   3.234 -		const CMPIObjectPath * reference,	/* [in] Contains target namespace and classname. */
   3.235 -		const char ** properties)	/* [in] List of desired properties (NULL=all). */
   3.236 -{
   3.237 -   CMPIStatus status = {CMPI_RC_OK, NULL};	/* Return status of CIM operations. */
   3.238 -   _RESOURCES * resources;			/* Handle to the list of system resources. */
   3.239 -   _RESOURCE * resource;			/* Handle to each system resource. */
   3.240 -   char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
   3.241 -   int found = 0;				/* Found any resource instances? */
   3.242 -
   3.243 -   _SBLIM_ENTER("EnumInstances");
   3.244 -   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   3.245 -   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   3.246 -   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
   3.247 -   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
   3.248 -
   3.249 -   if (!xen_utils_validate_session(&session)) {
   3.250 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon");
   3.251 -      goto exit;
   3.252 -   }
   3.253 -
   3.254 -   /* Get a handle to the list of system resources. */
   3.255 -   if (!Xen_Console_getResources(session, &resources)) {
   3.256 -      _SBLIM_TRACE(1,("--- _getResources() failed"));
   3.257 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources");
   3.258 -      goto exit;
   3.259 +      _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   3.260 +                   ("--- Unable to establish connection with Xend"));
   3.261 +      return CMPI_RC_ERR_FAILED;
   3.262     }
   3.263  
   3.264 -   /* Enumerate thru the list of system resources and return a CMPIInstance for each. */
   3.265 -   while (Xen_Console_getNextResource(session, resources, &resource)) {
   3.266 -      /* Create a new CMPIInstance to store this resource. */
   3.267 -      CMPIInstance * instance = _CMNewInstance(_BROKER, namespace, _CLASSNAME, &status);
   3.268 -      if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instance)) {
   3.269 -         _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status.msg)));
   3.270 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIInstance");
   3.271 -         goto exit;
   3.272 -      }
   3.273 -
   3.274 -      /* Setup a filter to only return the desired properties. */
   3.275 -      status = CMSetPropertyFilter(instance, properties, _KEYNAMES);
   3.276 -      if (status.rc != CMPI_RC_OK) {
   3.277 -         _SBLIM_TRACE(1, ("--- CMSetPropertyFilter() failed - %s", CMGetCharPtr(status.msg)));
   3.278 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Cannot set property filter");
   3.279 -         goto exit;
   3.280 -      }
   3.281 -
   3.282 -      /* Set the instance property values from the resource data. */
   3.283 -      if (!Xen_Console_setInstanceFromResource(session, resource, instance, _BROKER)) {
   3.284 -         _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed"));
   3.285 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data");
   3.286 -         goto exit;
   3.287 -      }
   3.288 -
   3.289 -      /* Free the resource data. */
   3.290 -      if (!Xen_Console_freeResource(resource)) {
   3.291 -         _SBLIM_TRACE(1,("--- _freeResource() failed"));
   3.292 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data");
   3.293 -         goto exit;
   3.294 -      }
   3.295 -
   3.296 -      /* Return the CMPIInstance for this instance. */
   3.297 -      _SBLIM_TRACE(3,("--- instance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, instance, NULL))));
   3.298 -      CMReturnInstance(results, instance);
   3.299 -      found++;
   3.300 -   }
   3.301 -
   3.302 -   _SBLIM_TRACE(2,("--- %d instances found", found));
   3.303 -   CMReturnDone(results);
   3.304 -
   3.305 -exit:
   3.306 -   /* Free the list of system resources. */
   3.307 -   if (!Xen_Console_freeResources(resources)) {
   3.308 -      _SBLIM_TRACE(1,("--- _freeResources() failed"));
   3.309 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources");
   3.310 -   }
   3.311 -
   3.312 -   _SBLIM_RETURNSTATUS(status);
   3.313 -}
   3.314 +   /* malloc a new handle for the resources list. */
   3.315 +   resources = (console_resources *)calloc(1, sizeof(console_resources));
   3.316 +   if (resources == NULL)
   3.317 +      return CMPI_RC_ERR_FAILED;
   3.318  
   3.319 -// ----------------------------------------------------------------------------
   3.320 -// GetInstance()
   3.321 -// Return the instance data for the specified instance only.
   3.322 -// ----------------------------------------------------------------------------
   3.323 -static CMPIStatus GetInstance(
   3.324 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.325 -		const CMPIContext * context,		/* [in] Additional context info, if any. */
   3.326 -		const CMPIResult * results,		/* [out] Results of this operation. */
   3.327 -		const CMPIObjectPath * reference,	/* [in] Contains the target namespace, classname and object path. */
   3.328 -		const char ** properties)		/* [in] List of desired properties (NULL=all). */
   3.329 -{
   3.330 -   CMPIStatus status = {CMPI_RC_OK, NULL};	/* Return status of CIM operations. */
   3.331 -   _RESOURCES * resources;			/* Handle to the list of system resources. */
   3.332 -   _RESOURCE * resource;			/* Handle to the system resource. */
   3.333 -   char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
   3.334 -   int found = 0;				/* Found the target instance? */
   3.335 -
   3.336 -   _SBLIM_ENTER("GetInstance");
   3.337 -   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   3.338 -   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   3.339 -   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
   3.340 -   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
   3.341 -
   3.342 -   if (!xen_utils_validate_session(&session)) {
   3.343 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon");
   3.344 -      goto exit;
   3.345 -   }
   3.346 -
   3.347 -   /* Get a handle to the list of system resources. */
   3.348 -   if (!Xen_Console_getResources(session, &resources)) {
   3.349 -      _SBLIM_TRACE(1,("--- _getResources() failed"));
   3.350 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources");
   3.351 -      goto exit;
   3.352 -   }
   3.353 -
   3.354 -   /* Get the target resource. */
   3.355 -   found = Xen_Console_getResourceForObjectPath(session, &resource, reference);
   3.356 -   if (!found || (resource == NULL)) {
   3.357 -      _SBLIM_TRACE(1,("--- Target instance not found"));
   3.358 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_FOUND, "Target instance not found");
   3.359 -      goto exit;
   3.360 -   }
   3.361 -
   3.362 -   /* Create a new CMPIInstance to store this resource. */
   3.363 -   CMPIInstance * instance = _CMNewInstance(_BROKER, namespace, _CLASSNAME, &status);
   3.364 -   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instance)) {
   3.365 -      _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status.msg)));
   3.366 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIInstance");
   3.367 -      goto exit;
   3.368 -   }
   3.369 -
   3.370 -   /* Setup a filter to only return the desired properties. */
   3.371 -   status = CMSetPropertyFilter(instance, properties, _KEYNAMES);
   3.372 -   if (status.rc != CMPI_RC_OK) {
   3.373 -      _SBLIM_TRACE(1, ("--- CMSetPropertyFilter() failed - %s", CMGetCharPtr(status.msg)));
   3.374 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Cannot set property filter");
   3.375 -      goto exit;
   3.376 -   }
   3.377 -
   3.378 -   /* Set the instance property values from the resource data. */
   3.379 -   if (!Xen_Console_setInstanceFromResource(session, resource, instance, _BROKER)) {
   3.380 -      _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed"));
   3.381 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data");
   3.382 -      goto exit;
   3.383 -   }
   3.384 -
   3.385 -   /* Free the resource data. */
   3.386 -   if (!Xen_Console_freeResource(resource)) {
   3.387 -      _SBLIM_TRACE(1,("--- _freeResource() failed"));
   3.388 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data");
   3.389 -      goto exit;
   3.390 +   if(!xen_console_get_all(session->xen, &(resources->consoles))) {
   3.391 +      _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   3.392 +                   ("--- Failed to retrieve list of consoles from xend"));
   3.393 +      _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
   3.394 +                            xen_utils_trace_error(session->xen));
   3.395 +      free(resources);
   3.396 +      return CMPI_RC_ERR_FAILED;
   3.397     }
   3.398  
   3.399 -   /* Return the CMPIInstance for this instance. */
   3.400 -   _SBLIM_TRACE(3,("--- instance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, instance, NULL))));
   3.401 -   CMReturnInstance(results, instance);
   3.402 -
   3.403 -   _SBLIM_TRACE(2,("--- instance found"));
   3.404 -   CMReturnDone(results);
   3.405 -
   3.406 -exit:
   3.407 -   /* Free the list of system resources. */
   3.408 -   if (!Xen_Console_freeResources(resources)) {
   3.409 -      _SBLIM_TRACE(1,("--- _freeResources() failed"));
   3.410 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources");
   3.411 -   }
   3.412 -
   3.413 -   _SBLIM_RETURNSTATUS(status);
   3.414 +   *res_list = (void *)resources;
   3.415 +   return CMPI_RC_OK;
   3.416  }
   3.417  
   3.418 -// ----------------------------------------------------------------------------
   3.419 -// SetInstance()
   3.420 -// Save modified instance data for the specified instance.
   3.421 -// ----------------------------------------------------------------------------
   3.422 -static CMPIStatus SetInstance(
   3.423 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.424 -		const CMPIContext * context,		/* [in] Additional context info, if any. */
   3.425 -		const CMPIResult * results,		/* [out] Results of this operation. */
   3.426 -		const CMPIObjectPath * reference,	/* [in] Contains the target namespace, classname and object path. */
   3.427 -		const CMPIInstance * newinstance,	/* [in] Contains the new instance data. */
   3.428 -        const char **properties)
   3.429 +
   3.430 +static void end(void *res_list)
   3.431  {
   3.432 -   CMPIStatus status = {CMPI_RC_OK, NULL};	/* Return status of CIM operations. */
   3.433 -   _RESOURCES * resources;			/* Handle to the list of system resources. */
   3.434 -   _RESOURCE * resource;	       		/* Handle to the system resource. */
   3.435 -   char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
   3.436 -   int found = 0;				/* Found the target instance? */
   3.437 -
   3.438 -   _SBLIM_ENTER("SetInstance");
   3.439 -   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   3.440 -   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   3.441 -   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
   3.442 -   _SBLIM_TRACE(2, ("--- newinstance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, newinstance, NULL))));
   3.443 -   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
   3.444 -
   3.445 -   if (!xen_utils_validate_session(&session)) {
   3.446 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon");
   3.447 -      goto exit;
   3.448 -   }
   3.449 -
   3.450 -   /* Get a handle to the list of system resources. */
   3.451 -   if (!Xen_Console_getResources(session, &resources)) {
   3.452 -      _SBLIM_TRACE(1,("--- _getResources() failed"));
   3.453 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources");
   3.454 -      goto exit;
   3.455 +   if (res_list) {
   3.456 +      xen_console_set_free(((console_resources *)res_list)->consoles);
   3.457 +      free(res_list);
   3.458     }
   3.459 -
   3.460 -   /* Get the target resource. */
   3.461 -   found = Xen_Console_getResourceForObjectPath(session, &resource, reference);
   3.462 -   if (!found || (resource == NULL)) {
   3.463 -      _SBLIM_TRACE(1,("--- Target instance not found"));
   3.464 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_FOUND, "Target instance not found");
   3.465 -      goto exit;
   3.466 -   }
   3.467 -
   3.468 -   _SBLIM_TRACE(2,("--- instance found", found));
   3.469 -
   3.470 -   /* Update the target resource data with the new instance property values. */
   3.471 -   int rc = Xen_Console_setResourceFromInstance(resource, newinstance, _BROKER);
   3.472 -
   3.473 -   /* Free the resource data. */
   3.474 -   if (!Xen_Console_freeResource(resource)) {
   3.475 -      _SBLIM_TRACE(1,("--- _freeResource() failed"));
   3.476 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data");
   3.477 -      goto exit;
   3.478 -   }
   3.479 -
   3.480 -   if (rc != 1) {
   3.481 -      if (rc == -1) {
   3.482 -         _SBLIM_TRACE(1,("--- _setResourceFromInstance() unsupported"));
   3.483 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL);
   3.484 -      } else {
   3.485 -         _SBLIM_TRACE(1,("--- _setResourceFromInstance() failed"));
   3.486 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set resource data from instance properties");
   3.487 -      }
   3.488 -      goto exit;
   3.489 -   }
   3.490 -
   3.491 -exit:
   3.492 -   /* Free the list of system resources. */
   3.493 -   if (!Xen_Console_freeResources(resources)) {
   3.494 -      _SBLIM_TRACE(1,("--- _freeResources() failed"));
   3.495 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources");
   3.496 -   }
   3.497 -
   3.498 -   _SBLIM_RETURNSTATUS(status);
   3.499  }
   3.500  
   3.501 -// ----------------------------------------------------------------------------
   3.502 -// CreateInstance()
   3.503 -// Create a new instance from the specified instance data.
   3.504 -// ----------------------------------------------------------------------------
   3.505 -static CMPIStatus CreateInstance(
   3.506 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.507 -		const CMPIContext * context,		/* [in] Additional context info, if any. */
   3.508 -		const CMPIResult * results,		/* [out] Results of this operation. */
   3.509 -		const CMPIObjectPath * reference,	/* [in] Contains the target namespace, classname and object path. */
   3.510 -		const CMPIInstance * newinstance)	/* [in] Contains the new instance data. */
   3.511 +
   3.512 +/* Iterator to get the next resource from the resources list. */
   3.513 +static CMPIrc getnext(void *res_list, void **res, const char **properties)
   3.514  {
   3.515 -   CMPIStatus status = {CMPI_RC_OK, NULL};	/* Return status of CIM operations. */
   3.516 -   _RESOURCES * resources;			/* Handle to the list of system resources. */
   3.517 -   _RESOURCE * resource;			/* Handle to the system resource. */
   3.518 -   char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
   3.519 -   int found = 0;				/* Found the target instance? */
   3.520 -
   3.521 -   _SBLIM_ENTER("CreateInstance");
   3.522 -   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   3.523 -   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   3.524 -   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
   3.525 -   _SBLIM_TRACE(2, ("--- newinstance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, newinstance, NULL))));
   3.526 -   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
   3.527 -
   3.528 -   if (!xen_utils_validate_session(&session)) {
   3.529 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon");
   3.530 -      goto exit;
   3.531 -   }
   3.532 -
   3.533 -   /* WORKAROUND FOR PEGASUS BUG?! reference does not contain object path, only namespace & classname. */
   3.534 -   reference = CMGetObjectPath(newinstance, NULL);
   3.535 +   console_resources *resources = (console_resources *)res_list;
   3.536  
   3.537 -   /* Get a handle to the list of system resources. */
   3.538 -   if (!Xen_Console_getResources(session, &resources)) {
   3.539 -      _SBLIM_TRACE(1,("--- _getResources() failed"));
   3.540 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources");
   3.541 -      goto exit;
   3.542 -   }
   3.543 -
   3.544 -   /* Get the target resource. */
   3.545 -   found = Xen_Console_getResourceForObjectPath(session, &resource, reference);
   3.546 -
   3.547 -   /* Free the resource data. */
   3.548 -   if (!Xen_Console_freeResource(resource)) {
   3.549 -      _SBLIM_TRACE(1,("--- _freeResource() failed"));
   3.550 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data");
   3.551 -      goto exit;
   3.552 -   }
   3.553 +   (void)properties;
   3.554 +   
   3.555 +   if (resources == NULL)
   3.556 +      return CMPI_RC_ERR_FAILED;
   3.557  
   3.558 -   if (found) {
   3.559 -      _SBLIM_TRACE(1,("--- Target instance already exists"));
   3.560 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_ALREADY_EXISTS, "Target instance already exists");
   3.561 -      goto exit;
   3.562 -   }
   3.563 -
   3.564 -   /* Create a new resource with the new instance property values. */
   3.565 -   int rc = Xen_Console_createResourceFromInstance(resources, &resource, newinstance, _BROKER);
   3.566 -   if (rc != 1) {
   3.567 -      if (rc == -1) {
   3.568 -         _SBLIM_TRACE(1,("--- _createResourceFromInstance() unsupported"));
   3.569 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL);
   3.570 -      } else {
   3.571 -         _SBLIM_TRACE(1,("--- _createResourceFromInstance() failed"));
   3.572 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to create resource data from instance properties");
   3.573 -      }
   3.574 -      goto exit;
   3.575 -   }
   3.576 -
   3.577 -   /* Return the object path for the newly created instance. */
   3.578 -   CMPIObjectPath * objectpath = CMGetObjectPath(newinstance, NULL);
   3.579 -   CMSetNameSpace(objectpath, namespace);
   3.580 -   CMReturnObjectPath(results, objectpath);
   3.581 -   CMReturnDone(results);
   3.582 +   /* Get next console resource.  Ignore inactive domains. */
   3.583 +   while (resources->cur_console < resources->consoles->size) {
   3.584 +      xen_console_record *con_rec;
   3.585  
   3.586 -exit:
   3.587 -   /* Free the list of system resources. */
   3.588 -   if (!Xen_Console_freeResources(resources)) {
   3.589 -      _SBLIM_TRACE(1,("--- _freeResources() failed"));
   3.590 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources");
   3.591 -   }
   3.592 -
   3.593 -   _SBLIM_RETURNSTATUS(status);
   3.594 -}
   3.595 -
   3.596 -// ----------------------------------------------------------------------------
   3.597 -// DeleteInstance()
   3.598 -// Delete or remove the specified instance from the system.
   3.599 -// ----------------------------------------------------------------------------
   3.600 -static CMPIStatus DeleteInstance(
   3.601 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.602 -		const CMPIContext * context,		/* [in] Additional context info, if any. */
   3.603 -		const CMPIResult * results,		/* [out] Results of this operation. */
   3.604 -		const CMPIObjectPath * reference)	/* [in] Contains the target namespace, classname and object path. */
   3.605 -{
   3.606 -   CMPIStatus status = {CMPI_RC_OK, NULL};	/* Return status of CIM operations. */
   3.607 -   _RESOURCES * resources;			/* Handle to the list of system resources. */
   3.608 -   _RESOURCE * resource;		/* Handle to the system resource. */
   3.609 -   char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
   3.610 -   int found = 0;				/* Found the target instance? */
   3.611 -
   3.612 -   _SBLIM_ENTER("DeleteInstance");
   3.613 -   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   3.614 -   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   3.615 -   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
   3.616 -   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
   3.617 -
   3.618 -   if (!xen_utils_validate_session(&session)) {
   3.619 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon");
   3.620 -      goto exit;
   3.621 -   }
   3.622 +      session->xen->ok = true;
   3.623 +      if (!xen_console_get_record(session->xen, &con_rec,
   3.624 +                                  resources->consoles->contents[resources->cur_console])) {
   3.625 +         _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   3.626 +                      ("--- Failed to retrieve Console record from xend"));
   3.627 +         _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
   3.628 +                               xen_utils_trace_error(session->xen));
   3.629 +         return CMPI_RC_ERR_FAILED;
   3.630 +      }
   3.631 +         
   3.632 +      enum xen_vm_power_state p_state = XEN_VM_POWER_STATE_HALTED;
   3.633 +      xen_vm_get_power_state(session->xen, &p_state, con_rec->vm->u.handle);
   3.634 +      if (p_state == XEN_VM_POWER_STATE_HALTED) {
   3.635 +         xen_console_record_free(con_rec);
   3.636 +         resources->cur_console++;
   3.637 +         continue;
   3.638 +      }
   3.639  
   3.640 -   /* Get a handle to the list of system resources. */
   3.641 -   if (!Xen_Console_getResources(session, &resources)) {
   3.642 -      _SBLIM_TRACE(1,("--- _getResources() failed"));
   3.643 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources");
   3.644 -      goto exit;
   3.645 -   }
   3.646 -
   3.647 -   /* Get the target resource. */
   3.648 -   found = Xen_Console_getResourceForObjectPath(session, &resource, reference);
   3.649 -   if (!found || (resource == NULL)) {
   3.650 -      _SBLIM_TRACE(1,("--- Target instance not found"));
   3.651 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_FOUND, "Target instance not found");
   3.652 -      goto exit;
   3.653 +      resources->cur_console++;
   3.654 +      *res = (void *)con_rec;
   3.655 +      return CMPI_RC_OK;
   3.656     }
   3.657 -
   3.658 -   _SBLIM_TRACE(2,("--- instance found", found));
   3.659 -
   3.660 -   /* Delete the target resource. */
   3.661 -   int rc = Xen_Console_deleteResource(resources, resource);
   3.662 -
   3.663 -   /* Free the resource data. */
   3.664 -   if (!Xen_Console_freeResource(resource)) {
   3.665 -      _SBLIM_TRACE(1,("--- _freeResource() failed"));
   3.666 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data");
   3.667 -      goto exit;
   3.668 -   }
   3.669 -
   3.670 -   if (rc != 1) {
   3.671 -      if (rc == -1) {
   3.672 -         _SBLIM_TRACE(1,("--- __deleteResource() unsupported"));
   3.673 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL);
   3.674 -      } else {
   3.675 -         _SBLIM_TRACE(1,("--- _deleteResource() failed"));
   3.676 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to delete resource");
   3.677 -      }
   3.678 -      goto exit;
   3.679 -   }
   3.680 -
   3.681 -exit:
   3.682 -   /* Free the list of system resources. */
   3.683 -   if (!Xen_Console_freeResources(resources)) {
   3.684 -      _SBLIM_TRACE(1,("--- _freeResources() failed"));
   3.685 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources");
   3.686 -   }
   3.687 -
   3.688 -   _SBLIM_RETURNSTATUS(status);
   3.689 +   
   3.690 +   return CMPI_RC_ERR_NOT_FOUND;
   3.691  }
   3.692  
   3.693  
   3.694 -// ----------------------------------------------------------------------------
   3.695 -// ExecQuery()
   3.696 -// Return a list of all the instances that satisfy the specified query filter.
   3.697 -// ----------------------------------------------------------------------------
   3.698 -static CMPIStatus ExecQuery(
   3.699 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.700 -		const CMPIContext * context,		/* [in] Additional context info, if any. */
   3.701 -		const CMPIResult * results,		/* [out] Results of this operation. */
   3.702 -		const CMPIObjectPath * reference,	/* [in] Contains the target namespace and classname. */
   3.703 -		const char * language,		/* [in] Name of the query language. */
   3.704 -		const char * query)			/* [in] Text of the query written in the query language. */
   3.705 +static CMPIrc get(const void *res_id, void **res, const char **properties)
   3.706  {
   3.707 -   CMPIStatus status = {CMPI_RC_OK, NULL};      /* Return status of CIM operations. */
   3.708 -   char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
   3.709 +   CMPIInstance *inst = (CMPIInstance *)res_id;
   3.710 +   CMPIData data;
   3.711 +   CMPIStatus status = {CMPI_RC_OK, NULL};
   3.712 +   char *prop_val;
   3.713 +
   3.714 +   (void)properties;
   3.715 +   
   3.716 +   if (CMIsNullObject(inst) || res == NULL)
   3.717 +      return CMPI_RC_ERR_FAILED;
   3.718 +
   3.719 +   /* Obtain the target console UUID from instance's "DeviceID" property. */
   3.720 +   data = CMGetProperty(inst, "DeviceID", &status);
   3.721 +   if ((status.rc != CMPI_RC_OK) || CMIsNullValue(data))
   3.722 +      return CMPI_RC_ERR_FAILED;
   3.723 +
   3.724 +   prop_val = CMGetCharPtr(data.value.string);
   3.725 +   if ((prop_val == NULL) || (*prop_val == '\0'))
   3.726 +      return CMPI_RC_ERR_FAILED;
   3.727  
   3.728 -   _SBLIM_ENTER("ExecQuery");
   3.729 -   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   3.730 -   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   3.731 -   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
   3.732 -   _SBLIM_TRACE(2, ("--- language=\"%s\"", language));
   3.733 -   _SBLIM_TRACE(2, ("--- query=\"%s\"", query));
   3.734 -   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
   3.735 +   if (!xen_utils_validate_session(&session)) {
   3.736 +      _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   3.737 +                   ("--- Unable to establish connection with Xend"));
   3.738 +      return CMPI_RC_ERR_FAILED;
   3.739 +   }
   3.740 +   
   3.741 +   xen_console console = NULL;
   3.742 +   xen_console_record *con_rec;
   3.743 +   xen_console_get_by_uuid(session->xen, &console, prop_val);
   3.744 +   xen_console_get_record(session->xen, &con_rec, console);
   3.745 +   xen_console_free(console);
   3.746 +   if (!session->xen->ok) {
   3.747 +      _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   3.748 +                   ("--- Failed to retrieve console record for domain"));
   3.749 +      _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
   3.750 +                            xen_utils_trace_error(session->xen));
   3.751 +      return CMPI_RC_ERR_FAILED;
   3.752 +   }
   3.753 +      
   3.754 +   /* 
   3.755 +    * Xen_Memory instances only exist when domain is not inactive.
   3.756 +    * Incoming object path must be from a previously active domain.
   3.757 +    */
   3.758 +   enum xen_vm_power_state p_state = XEN_VM_POWER_STATE_HALTED;
   3.759 +   xen_vm_get_power_state(session->xen, &p_state, con_rec->vm->u.handle);
   3.760 +   if (p_state == XEN_VM_POWER_STATE_HALTED) {
   3.761 +      xen_console_record_free(con_rec);
   3.762 +      return CMPI_RC_ERR_NOT_FOUND;
   3.763 +   }
   3.764 +   
   3.765 +   *res = (void *)con_rec;
   3.766 +   return CMPI_RC_OK;
   3.767 +}
   3.768  
   3.769 -   /* EXECQUERY() IS NOT YET SUPPORTED FOR THIS CLASS */
   3.770 -   CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL);
   3.771 +
   3.772 +static void release(void *res)
   3.773 +{
   3.774 +   if (res)
   3.775 +      xen_console_record_free((xen_console_record *)res);
   3.776 +}
   3.777 +
   3.778  
   3.779 -   CMReturnDone(results);
   3.780 +static CMPIrc add(const void *res_id, const void *res)
   3.781 +{
   3.782 +   (void)res_id;
   3.783 +   (void)res;
   3.784 +   
   3.785 +   return CMPI_RC_ERR_NOT_SUPPORTED; /* unsupported */
   3.786 +}
   3.787  
   3.788 -exit:
   3.789 -   _SBLIM_RETURNSTATUS(status);
   3.790 +
   3.791 +static CMPIrc delete(const void *res_id)
   3.792 +{
   3.793 +   (void)res_id;
   3.794 +   
   3.795 +   return  CMPI_RC_ERR_NOT_SUPPORTED; /* unsupported */
   3.796  }
   3.797  
   3.798 -// ----------------------------------------------------------------------------
   3.799 -// Initialize()
   3.800 -// Perform any necessary initialization immediately after this provider is
   3.801 -// first loaded.
   3.802 -// ----------------------------------------------------------------------------
   3.803 -static void Initialize(
   3.804 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.805 -		const CMPIContext * context)		/* [in] Additional context info, if any. */
   3.806 +
   3.807 +static CMPIrc modify(const void *res_id, const void *modified_res,
   3.808 +                     const char **properties)
   3.809  {
   3.810 -   _SBLIM_ENTER("Initialize");
   3.811 -   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   3.812 -   //   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   3.813 -
   3.814 -   /* Initialized Xen session object. */
   3.815 -   if (session == NULL)
   3.816 -      xen_utils_xen_init(&session);
   3.817 +   (void)res_id;
   3.818 +   (void)modified_res;
   3.819 +   (void)properties;
   3.820     
   3.821 -   _SBLIM_RETURN();
   3.822 +   return CMPI_RC_ERR_NOT_SUPPORTED; /* unsupported */
   3.823  }
   3.824  
   3.825 -// ============================================================================
   3.826 -// CMPI INSTANCE PROVIDER FUNCTION TABLE SETUP
   3.827 -// ============================================================================
   3.828 -CMInstanceMIStub( , Xen_Console, _BROKER, Initialize(&mi, ctx));
   3.829 +
   3.830 +/* Set CMPIInstance properties from the resource data. */
   3.831 +static CMPIrc setproperties(CMPIInstance *inst, const void *res,
   3.832 +                            const char **properties)
   3.833 +{
   3.834 +   xen_console_record *con_rec = (xen_console_record *)res;
   3.835 +
   3.836 +   if (con_rec == NULL)
   3.837 +      return CMPI_RC_ERR_FAILED;
   3.838 +
   3.839 +   if (CMIsNullObject(inst))
   3.840 +      return CMPI_RC_ERR_FAILED;
   3.841 +
   3.842 +   char *dom_name;
   3.843 +   if (!xen_vm_get_name_label(session->xen, &dom_name, con_rec->vm->u.handle)) {
   3.844 +      _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   3.845 +                   ("--- Failed to retrieve domain name associated with console"));
   3.846 +      _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
   3.847 +                            xen_utils_trace_error(session->xen));
   3.848 +      return CMPI_RC_ERR_FAILED;
   3.849 +   }
   3.850 +      
   3.851 +   /* Setup a filter to only return the desired properties. */
   3.852 +   CMSetPropertyFilter(inst, properties, keys);
   3.853 +
   3.854 +   /* Set the CMPIInstance properties from the resource data. */
   3.855 +   CMSetProperty(inst, "SystemCreationClassName",
   3.856 +                 (CMPIValue *)"Xen_ComputerSystem", CMPI_chars);
   3.857 +   CMSetProperty(inst, "SystemName", (CMPIValue *)dom_name, CMPI_chars);
   3.858 +   CMSetProperty(inst, "CreationClassName",
   3.859 +                 (CMPIValue *)"Xen_Console", CMPI_chars);
   3.860 +   CMSetProperty(inst, "DeviceID",(CMPIValue *)con_rec->uuid, CMPI_chars);
   3.861 +   CMSetProperty(inst, "Caption",(CMPIValue *)"Xen Console", CMPI_chars);
   3.862 +   CMSetProperty(inst, "Description", (CMPIValue *)"Xen Console", CMPI_chars);
   3.863 +   CMSetProperty(inst, "Status", (CMPIValue *)"OK", CMPI_chars);
   3.864 +   CMSetProperty(inst, "Protocol", (CMPIValue *)&(con_rec->protocol), CMPI_uint16);
   3.865 +
   3.866 +   if (con_rec->location && con_rec->location[0] != '\0')
   3.867 +      CMSetProperty(inst, "URI", (CMPIValue *)con_rec->location, CMPI_chars);
   3.868 +
   3.869 +   free(dom_name);
   3.870 +   return CMPI_RC_OK;
   3.871 +}
   3.872 +
   3.873 +
   3.874 +/*
   3.875 + * Set resource data from the CMPIInstance properties.  Only needs to
   3.876 + * be implemented if add() and/or modify() are supported.
   3.877 + */
   3.878 +static CMPIrc extract(void **res, const CMPIInstance *inst,
   3.879 +                      const char **properties)
   3.880 +{
   3.881 +   (void)res;
   3.882 +   (void)inst;
   3.883 +   (void)properties;
   3.884 +   
   3.885 +   return CMPI_RC_ERR_NOT_SUPPORTED;  /* unsupported */
   3.886 +}
   3.887 +
   3.888 +
   3.889 +/* Get resource id from CMPIInstance properties. */
   3.890 +static CMPIrc extractid(void **res_id, const CMPIInstance* inst)
   3.891 +{
   3.892 +   *res_id = (void *)inst;
   3.893 +   return CMPI_RC_OK;
   3.894 +}
   3.895 +
   3.896 +
   3.897 +/* Release resource id created in resId4inst(). */
   3.898 +static void releaseid(void* res_id)
   3.899 +{
   3.900 +   (void)res_id;
   3.901 +}
   3.902 +
   3.903 +
   3.904 +/* Setup CMPILIFY function tables and instance provider entry point.*/
   3.905 +/* CMPILIFYInstanceMIStub(<CLASS>,<PROVIDER_NAME>,<keys>,<CMPIInstanceMI_HANDLE>) */
   3.906 +CMPILIFYInstanceMIStub(Xen_Console, Xen_Console, keys, mi)
     4.1 --- a/src/Xen_Console_Resource.c	Thu Jul 19 15:17:54 2007 -0600
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,296 +0,0 @@
     4.4 -// Copyright (C) 2006 Unisys 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:       Rajagopalan Subrahmanian, <raj.subrahmanian@unisys.com>
    4.21 -//
    4.22 -// Contributors:
    4.23 -//
    4.24 -// Description:
    4.25 -// ============================================================================
    4.26 -
    4.27 -#include <stdlib.h>
    4.28 -#include <string.h>
    4.29 -#include <assert.h>
    4.30 -
    4.31 -#include <xen_common.h>
    4.32 -#include <xen_vm.h>
    4.33 -#include <xen_console.h>
    4.34 -
    4.35 -#include "Xen_Console_Resource.h"
    4.36 -
    4.37 -/* Include the required CMPI data types, function headers, and macros. */
    4.38 -#include "cmpidt.h"
    4.39 -#include "cmpift.h"
    4.40 -#include "cmpimacs.h"
    4.41 -
    4.42 -#include "xen_utils.h"
    4.43 -
    4.44 -/* Include _SBLIM_TRACE() logging support */
    4.45 -#include "cmpitrace.h"
    4.46 -
    4.47 -// ----------------------------------------------------------------------------
    4.48 -
    4.49 -static int concat_console_lists(xen_console_set **target, xen_console_set *source)
    4.50 -{
    4.51 -
    4.52 -   int total_size;
    4.53 -   int i, j;
    4.54 -   
    4.55 -   /* Nothing to concatenate if source is empty */
    4.56 -   if (source == NULL || source->size == 0)
    4.57 -      return 1;
    4.58 -   
    4.59 -   /* If targe is empty, assign source to target */
    4.60 -   if (*target == NULL) {
    4.61 -      *target = source;
    4.62 -      return 1;
    4.63 -   }
    4.64 -   
    4.65 -   /* realloc memory and append source to target */
    4.66 -   total_size = (*target)->size + source->size;
    4.67 -   *target = realloc(*target, sizeof(xen_console_set) + (total_size * sizeof(xen_console)));
    4.68 -   if (*target == NULL)
    4.69 -      return 0;
    4.70 -   
    4.71 -   for (j = (*target)->size, i = 0; i < source->size; i++) {
    4.72 -      (*target)->contents[j + i] = source->contents[i];
    4.73 -      source->contents[i] = NULL;
    4.74 -   }
    4.75 -   (*target)->size = total_size;
    4.76 -   
    4.77 -   /* Free source list - it has been copied to target */
    4.78 -   xen_console_set_free(source);
    4.79 -   return 1;
    4.80 -}
    4.81 -
    4.82 -
    4.83 -/* Get a handle to the list of all system resources for this class. */
    4.84 -int Xen_Console_getResources(xen_utils_session *session,
    4.85 -                                 _RESOURCES ** resources)
    4.86 -{
    4.87 -   xen_domain_resources *res;
    4.88 -   xen_console_set *all_consoles = NULL;
    4.89 -   xen_vm_record *vm_rec = NULL;
    4.90 -   
    4.91 -   /* malloc a new handle for the resources list. */
    4.92 -   *resources = (_RESOURCES *)calloc(1, sizeof(_RESOURCES));
    4.93 -   if (*resources == NULL)
    4.94 -      return 0;
    4.95 -
    4.96 -   /* Get a list of domain resources. */
    4.97 -   if (!xen_utils_get_domain_resources(session, &res)) {
    4.98 -      *resources = NULL;
    4.99 -      return 0;
   4.100 -   }
   4.101 -
   4.102 -   /* Create list of console resources from consoles found in each domain. */
   4.103 -   while (xen_utils_get_next_domain_resource(session, res, &vm_rec)) {
   4.104 -      /* Ignore halted vms */
   4.105 -      if (vm_rec->power_state == XEN_VM_POWER_STATE_HALTED) {
   4.106 -         xen_vm_record_free(vm_rec);
   4.107 -         continue;
   4.108 -      }
   4.109 -      
   4.110 -      xen_console_set *console_set;
   4.111 -      if (!xen_vm_get_consoles(session->xen, &console_set, vm_rec->handle))
   4.112 -         goto Error;
   4.113 -      
   4.114 -      if (!concat_console_lists(&all_consoles, console_set))
   4.115 -         goto Error;
   4.116 -      
   4.117 -      xen_vm_record_free(vm_rec);
   4.118 -   }
   4.119 -   
   4.120 -   (*resources)->consoles = all_consoles;
   4.121 -   (*resources)->currentconsolenum = 0;
   4.122 -   
   4.123 -   return 1;
   4.124 -   
   4.125 - Error:
   4.126 -   xen_vm_record_free(vm_rec);
   4.127 -   xen_utils_free_domain_resources(res);
   4.128 -   free(*resources);
   4.129 -   *resources = NULL;
   4.130 -   return 0;
   4.131 -}
   4.132 -
   4.133 -// ----------------------------------------------------------------------------
   4.134 -
   4.135 -/* Free/deallocate/cleanup the resources list after use. */
   4.136 -int Xen_Console_freeResources(_RESOURCES * resources)
   4.137 -{
   4.138 -   if (resources != NULL) {
   4.139 -       if (resources->consoles != NULL)
   4.140 -          xen_console_set_free(resources->consoles);
   4.141 -       free(resources);
   4.142 -       resources = NULL;
   4.143 -   }
   4.144 -   
   4.145 -   return 1;
   4.146 -}
   4.147 -
   4.148 -// ----------------------------------------------------------------------------
   4.149 -
   4.150 -/* Iterator to get the next resource from the resources list. */
   4.151 -int Xen_Console_getNextResource(xen_utils_session *session,
   4.152 -                                    _RESOURCES * resources,
   4.153 -                                    _RESOURCE ** resource)
   4.154 -{
   4.155 -   if (resources == NULL || resources->consoles == NULL)
   4.156 -      return 0;
   4.157 -
   4.158 -   /* Check if reached the end of the list of consoles. */
   4.159 -   if (resources->currentconsolenum == resources->consoles->size)
   4.160 -      return 0;
   4.161 -
   4.162 -   /* Get the current console record. */
   4.163 -   if (!xen_console_get_record(session->xen, resource, resources->consoles->contents[resources->currentconsolenum]))
   4.164 -      return 0;
   4.165 -   
   4.166 -   resources->currentconsolenum++;
   4.167 -   return 1;
   4.168 -}
   4.169 -
   4.170 -// ----------------------------------------------------------------------------
   4.171 -
   4.172 -/* Get the specific resource that matches the CMPI object path. */
   4.173 -int Xen_Console_getResourceForObjectPath(xen_utils_session *session,
   4.174 -                                             _RESOURCE ** resource,
   4.175 -                                             const CMPIObjectPath * objectpath)
   4.176 -{
   4.177 -   CMPIData namedata;
   4.178 -   char *keyvalue;
   4.179 -   int ccode;
   4.180 -   CMPIStatus status = {CMPI_RC_OK, NULL};	/* Return status of CIM operations. */
   4.181 -
   4.182 -   if (CMIsNullObject(objectpath)) return 0;
   4.183 -
   4.184 -   /* Get the console resource based on DeviceID (console uuid) */
   4.185 -   namedata = CMGetKey(objectpath, "DeviceID", &status);
   4.186 -   if ((status.rc != CMPI_RC_OK) || CMIsNullValue(namedata))
   4.187 -      return 0;
   4.188 -
   4.189 -   keyvalue = CMGetCharPtr(namedata.value.string);
   4.190 -   if ((keyvalue == NULL) || (*keyvalue == '\0'))
   4.191 -      return 0;
   4.192 -
   4.193 -   xen_console console;
   4.194 -   if (!xen_console_get_by_uuid(session->xen, &console, keyvalue))
   4.195 -      return 0;
   4.196 -
   4.197 -   ccode = xen_console_get_record(session->xen, resource, console);
   4.198 -   xen_console_free(console);
   4.199 -   return ccode;
   4.200 -}
   4.201 -
   4.202 -// ----------------------------------------------------------------------------
   4.203 -
   4.204 -/* Free/deallocate/cleanup the resource after use. */
   4.205 -int Xen_Console_freeResource(_RESOURCE * resource)
   4.206 -{
   4.207 -   xen_console_record_free(resource);
   4.208 -   return 1;
   4.209 -}
   4.210 -
   4.211 -// ---------------------------------------------------------------------------- 
   4.212 -
   4.213 -/* Set the property values of a CMPI instance from a specific resource. */
   4.214 -int Xen_Console_setInstanceFromResource(xen_utils_session *session,
   4.215 -                                            _RESOURCE * resource,
   4.216 -                                            const CMPIInstance * instance,
   4.217 -                                            const CMPIBroker * broker)
   4.218 -{
   4.219 -   xen_vm_record *alloced_vm_rec = NULL;
   4.220 -   xen_vm_record *vm_rec;
   4.221 -   
   4.222 -   if (resource == NULL) return 0;
   4.223 -   if (CMIsNullObject(instance)) return 0;
   4.224 -
   4.225 -   xen_vm_record_opt *vm_rec_opt = resource->vm;
   4.226 -   if (vm_rec_opt->is_record) {
   4.227 -      vm_rec = vm_rec_opt->u.record;
   4.228 -   }
   4.229 -   else {
   4.230 -      if (!xen_vm_get_record(session->xen, &vm_rec, vm_rec_opt->u.handle)) {
   4.231 -      /* Error description in session object! */
   4.232 -         return 0;
   4.233 -      }
   4.234 -      alloced_vm_rec = vm_rec;
   4.235 -   }
   4.236 -
   4.237 -   /* Set the CMPIInstance properties from the resource data. */
   4.238 -   CMSetProperty(instance, "SystemCreationClassName",(CMPIValue *)"Xen_ComputerSystem", CMPI_chars);
   4.239 -   CMSetProperty(instance, "SystemName",(CMPIValue *)vm_rec->name_label, CMPI_chars);
   4.240 -   CMSetProperty(instance, "CreationClassName",(CMPIValue *)"Xen_Console", CMPI_chars);
   4.241 -   
   4.242 -   CMSetProperty(instance, "DeviceID",(CMPIValue *)resource->uuid, CMPI_chars);
   4.243 -
   4.244 -   CMSetProperty(instance, "Caption",(CMPIValue *)"Console", CMPI_chars);
   4.245 -   CMSetProperty(instance, "Description",(CMPIValue *)"Console", CMPI_chars);
   4.246 -
   4.247 -   if (resource->location)
   4.248 -      CMSetProperty(instance, "URI", (CMPIValue *)resource->location, CMPI_chars);
   4.249 -
   4.250 -   int protocol = -1;
   4.251 -   if (resource->protocol == XEN_CONSOLE_PROTOCOL_VT100)
   4.252 -      protocol = 0; /* 0 == VT100 */
   4.253 -   else if (resource->protocol == XEN_CONSOLE_PROTOCOL_RFB)
   4.254 -      protocol = 1; /* 1 == VNC */
   4.255 -   else if (resource->protocol == XEN_CONSOLE_PROTOCOL_RDP)
   4.256 -      protocol = 2; /* 2 == SDL */
   4.257 -
   4.258 -   if (protocol != -1)
   4.259 -      CMSetProperty(instance, "Protocol",(CMPIValue *)&protocol, CMPI_uint16);
   4.260 -
   4.261 -   if (alloced_vm_rec)
   4.262 -      xen_vm_record_free(alloced_vm_rec);
   4.263 -
   4.264 -   return 1;
   4.265 -}
   4.266 -
   4.267 -// ----------------------------------------------------------------------------
   4.268 -
   4.269 -/* Delete the specified resource from the system. */
   4.270 -int Xen_Console_deleteResource(_RESOURCES * resources,
   4.271 -                                   _RESOURCE * resource)
   4.272 -{
   4.273 -   /* Unsupported. */
   4.274 -   return -1;
   4.275 -}
   4.276 -
   4.277 -// ----------------------------------------------------------------------------
   4.278 -
   4.279 -/* Modify the specified resource using the property values of a CMPI instance. */
   4.280 -int Xen_Console_setResourceFromInstance(_RESOURCE * resource,
   4.281 -                                            const CMPIInstance * instance,
   4.282 -                                            const CMPIBroker * broker)
   4.283 -{
   4.284 -   /* Unsupported. */
   4.285 -   return -1;
   4.286 -}
   4.287 -
   4.288 -// ----------------------------------------------------------------------------
   4.289 -
   4.290 -/* Create a new resource using the property values of a CMPI instance. */
   4.291 -int Xen_Console_createResourceFromInstance(_RESOURCES * resources,
   4.292 -                                               _RESOURCE ** resource,
   4.293 -                                               const CMPIInstance * instance,
   4.294 -                                               const CMPIBroker * broker)
   4.295 -{
   4.296 -   /* Unsupported. */
   4.297 -   return -1;
   4.298 -}
   4.299 -
     5.1 --- a/src/Xen_Console_Resource.h	Thu Jul 19 15:17:54 2007 -0600
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,104 +0,0 @@
     5.4 -// Copyright (C) 2006 Unisys 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:       Rajagopalan Subrahmanian <raj.subrahmanian@unisys.com>
    5.21 -//
    5.22 -// Contributors:
    5.23 -//
    5.24 -// Description:
    5.25 -// ============================================================================
    5.26 -
    5.27 -/* Include required libxen headers. */
    5.28 -#include <xen_common.h>
    5.29 -#include <xen_console.h>
    5.30 -
    5.31 -#include "xen_utils.h"
    5.32 -
    5.33 -/*** CUSTOMIZE FOR EACH PROVIDER ***/
    5.34 -/* DEFINE A HANDLE TO REPRESENT THE 'LIST' OF ALL SYSTEM RESOURCES.
    5.35 -   THE MAIN PROVIDER CODE DOES NOT NEED TO KNOW THE PARTICULARS OF HOW THIS
    5.36 -   LIST IS IMPLEMENTED - IT MAY BE AN ARRAY, LINKED LIST, FILE, ETC.
    5.37 -   THIS HANDLE IS PASSED INTO THE APPROPRIATE RESOURCE ACCESS METHODS WHEN
    5.38 -   ACCESSING/ITERATING/ADDING/REMOVING RESOURCES INSTANCES. */
    5.39 -typedef struct {
    5.40 -   xen_console_set *consoles;
    5.41 -   unsigned int currentconsolenum;
    5.42 -} _RESOURCES;
    5.43 -
    5.44 -/*** CUSTOMIZE FOR EACH PROVIDER ***/
    5.45 -/* DEFINE A HANDLE TO BE USED FOR EACH INSTANCE OF A SYSTEM RESOURCE.
    5.46 -   THE MAIN PROVIDER CODE DOES NOT NEED TO KNOW THE PARTICULARS OF HOW EACH
    5.47 -   RESOURCE IS REPRESENTED, BUT TYPICALLY IT IS A STRUCTURE MIRRORING THE
    5.48 -   PROPERTIES IN THE CIM CLASS. THIS HANDLE IS PASSED BETWEEN THE RESOURCE
    5.49 -   ACCESS METHODS WHEN MANIPULATING SPECIFIC RESOURCE INSTANCES. */
    5.50 -typedef xen_console_record  _RESOURCE;
    5.51 -
    5.52 -/* NOTHING BELOW THIS LINE SHOULD NEED TO BE CHANGED. */
    5.53 -
    5.54 -/* Include the required CMPI data types. */
    5.55 -#include "cmpidt.h"
    5.56 -
    5.57 -// ----------------------------------------------------------------------------
    5.58 -// Generic resource access methods for CMPI providers.
    5.59 -// Return value:
    5.60 -//	-1 = Unsupported
    5.61 -//	 0 = Failed
    5.62 -//	 1 = OK
    5.63 -// ----------------------------------------------------------------------------
    5.64 -
    5.65 -/* Get a handle to the list of all system resources for this class. */
    5.66 -int Xen_Console_getResources(xen_utils_session *session,
    5.67 -                                 _RESOURCES ** resources);
    5.68 -
    5.69 -/* Free/deallocate/cleanup the resources list after use. */
    5.70 -int Xen_Console_freeResources(_RESOURCES * resources);
    5.71 -
    5.72 -/* Iterator to get the next resource from the resources list. */
    5.73 -int Xen_Console_getNextResource(xen_utils_session *session,
    5.74 -                                    _RESOURCES * resources,
    5.75 -                                    _RESOURCE ** resource);
    5.76 -
    5.77 -/* Get the specific resource that matches the CMPI object path. */
    5.78 -int Xen_Console_getResourceForObjectPath(xen_utils_session *session,
    5.79 -                                             _RESOURCE ** resource,
    5.80 -                                             const CMPIObjectPath * objectpath);
    5.81 -
    5.82 -/* Free/deallocate/cleanup a resource after use. */
    5.83 -int Xen_Console_freeResource(_RESOURCE * resource);
    5.84 -
    5.85 -/* Set the property values of a CMPI instance from a specific resource. */
    5.86 -int Xen_Console_setInstanceFromResource(xen_utils_session *session,
    5.87 -                                            _RESOURCE * resource,
    5.88 -                                            const CMPIInstance * instance,
    5.89 -                                            const CMPIBroker * broker);
    5.90 -
    5.91 -// THE FOLLOWING METHODS MAY/NOT BE SUPPORTED BY THE SYSTEM FOR THIS CLASS
    5.92 -
    5.93 -/* Delete the specified resource from the system. */
    5.94 -int Xen_Console_deleteResource(_RESOURCES * resources,
    5.95 -                                   _RESOURCE * resource);
    5.96 -
    5.97 -/* Modify the specified resource using the property values of a CMPI instance. */
    5.98 -int Xen_Console_setResourceFromInstance(_RESOURCE * resource,
    5.99 -                                            const CMPIInstance * instance,
   5.100 -                                            const CMPIBroker * broker);
   5.101 -
   5.102 -/* Create a new resource using the property values of a CMPI instance. */
   5.103 -int Xen_Console_createResourceFromInstance(_RESOURCES * resources,
   5.104 -                                               _RESOURCE ** resource,
   5.105 -                                               const CMPIInstance * instance,
   5.106 -                                               const CMPIBroker * broker);
   5.107 -