os-cmpi-xen
changeset 140:93e1e1824ab0
Slight modifications to patch provided by Raj Subrahmanian.
This patch moves the XenNetworkPort and XenNetworkportSettingData providers to the new CMPIlify provider model.
Signed-off-by: Raj Subrahmanian <raj.subrahmanian@unisys.com>
Signed-off-by: Jim Fehlig <jfehlig@novell.com>
This patch moves the XenNetworkPort and XenNetworkportSettingData providers to the new CMPIlify provider model.
Signed-off-by: Raj Subrahmanian <raj.subrahmanian@unisys.com>
Signed-off-by: Jim Fehlig <jfehlig@novell.com>
author | Jim Fehlig <jfehlig@novell.com> |
---|---|
date | Fri Aug 10 15:32:54 2007 -0600 (2007-08-10) |
parents | 3ccb96bfe206 |
children | be22f410b2a3 |
files | ChangeLog src/Makefile.am src/Xen_DiskSettingData.c src/Xen_NetworkPort.c src/Xen_NetworkPortSettingData.c src/Xen_NetworkPortSettingData_Resource.c src/Xen_NetworkPortSettingData_Resource.h src/Xen_NetworkPort_Resource.c src/Xen_NetworkPort_Resource.h |
line diff
1.1 --- a/ChangeLog Thu Aug 02 17:54:59 2007 -0600 1.2 +++ b/ChangeLog Fri Aug 10 15:32:54 2007 -0600 1.3 @@ -1,3 +1,9 @@ 1.4 +------------------------------------------------------------------- 1.5 +Fri Aug 10 15:30:22 MDT 2007 - jfehlig@novell.com 1.6 + 1.7 + - Ported Xen_Network and Xen_NetworkPortSettingData to 1.8 + new 'Cmpilify' interface. Provided by Raj Subrahmanian. 1.9 + 1.10 ------------------------------------------------------------------- 1.11 Thu Aug 2 17:52:15 MDT 2007 - jfehlig@novell.com 1.12
2.1 --- a/src/Makefile.am Thu Aug 02 17:54:59 2007 -0600 2.2 +++ b/src/Makefile.am Fri Aug 10 15:32:54 2007 -0600 2.3 @@ -48,9 +48,7 @@ noinst_HEADERS = \ 2.4 xen_utils.h \ 2.5 Xen_ComputerSystem_Resource.h \ 2.6 Xen_VirtualSystemManagementService_Resource.h \ 2.7 - Xen_NetworkPort_Resource.h \ 2.8 Xen_VirtualizationCapabilities_Resource.h \ 2.9 - Xen_NetworkPortSettingData_Resource.h \ 2.10 Xen_ProcessorCapabilitiesSettingData_Resource.h \ 2.11 Xen_MemoryCapabilitiesSettingData_Resource.h 2.12 2.13 @@ -185,7 +183,7 @@ libXen_ComputerSystemDisk_la_SOURCES = X 2.14 libXen_ComputerSystemDisk_la_LIBADD = libXen_ProviderCommon.la 2.15 libXen_ComputerSystemDisk_la_LDFLAGS = -module -avoid-version -no-undefined 2.16 2.17 -libXen_NetworkPort_la_SOURCES = Xen_NetworkPort.c Xen_NetworkPort_Resource.c 2.18 +libXen_NetworkPort_la_SOURCES = Xen_NetworkPort.c 2.19 libXen_NetworkPort_la_CFLAGS = -I../ @LIBXEN_CFLAGS@ 2.20 libXen_NetworkPort_la_LIBADD = libXen_ProviderCommon.la 2.21 libXen_NetworkPort_la_LDFLAGS = -module -avoid-version -no-undefined 2.22 @@ -260,7 +258,7 @@ libXen_MemoryElementSettingData_la_CFLAG 2.23 libXen_MemoryElementSettingData_la_LIBADD = libXen_ProviderCommon.la 2.24 libXen_MemoryElementSettingData_la_LDFLAGS = -module -avoid-version -no-undefined 2.25 2.26 -libXen_NetworkPortSettingData_la_SOURCES = Xen_NetworkPortSettingData.c Xen_NetworkPortSettingData_Resource.c 2.27 +libXen_NetworkPortSettingData_la_SOURCES = Xen_NetworkPortSettingData.c 2.28 libXen_NetworkPortSettingData_la_CFLAGS = -I../ @LIBXEN_CFLAGS@ 2.29 libXen_NetworkPortSettingData_la_LIBADD = libXen_ProviderCommon.la 2.30 libXen_NetworkPortSettingData_la_LDFLAGS = -module -avoid-version -no-undefined
3.1 --- a/src/Xen_DiskSettingData.c Thu Aug 02 17:54:59 2007 -0600 3.2 +++ b/src/Xen_DiskSettingData.c Fri Aug 10 15:32:54 2007 -0600 3.3 @@ -105,7 +105,7 @@ static CMPIrc begin(void **res_list, con 3.4 { 3.5 vbd_resources *disk_resources; 3.6 xen_domain_resources *domain_resources = NULL; 3.7 - xen_vbd_set *all_disks = NULL; 3.8 + xen_vif_set *all_disks = NULL; 3.9 xen_vm_record *vm_rec = NULL; 3.10 3.11 (void)properties; 3.12 @@ -213,6 +213,7 @@ static CMPIrc getnext(void *res_list, vo 3.13 } 3.14 3.15 3.16 + 3.17 static CMPIrc get(const void *res_id, void **res, const char **properties) 3.18 { 3.19 CMPIInstance *inst = (CMPIInstance *)res_id; 3.20 @@ -266,6 +267,7 @@ static CMPIrc get(const void *res_id, vo 3.21 } 3.22 3.23 3.24 + 3.25 static void release(void *res) 3.26 { 3.27 if (res) {
4.1 --- a/src/Xen_NetworkPort.c Thu Aug 02 17:54:59 2007 -0600 4.2 +++ b/src/Xen_NetworkPort.c Fri Aug 10 15:32:54 2007 -0600 4.3 @@ -17,607 +17,389 @@ 4.4 // Authors: Dr. Gareth S. Bestor, <bestor@us.ibm.com> 4.5 // Tokunbo Adeshiyan, <tokunbo@us.ibm.com> 4.6 // Contributors: Jim Fehlig, <jfehlig@novell.com> 4.7 +// Raj Subrahmanian, <raj.subrahmanian@unisys.com> 4.8 // Description: 4.9 // ============================================================================ 4.10 4.11 -/* Include the required CMPI data types, function headers, and macros */ 4.12 -#include "cmpidt.h" 4.13 -#include "cmpift.h" 4.14 -#include "cmpimacs.h" 4.15 - 4.16 -/* Include utility functions */ 4.17 -#include "cmpiutil.h" 4.18 +/* Common declarations for each CMPI "cmpilify" instance provider */ 4.19 +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 4.20 +#include <cmpidt.h> 4.21 +#include <cmpimacs.h> 4.22 4.23 -/* Include _SBLIM_TRACE() logging support */ 4.24 -#include "cmpitrace.h" 4.25 - 4.26 -/* Include Xen utilities */ 4.27 -#include "xen_utils.h" 4.28 - 4.29 -/* Include the abstract resource access functions and abstracted _RESOURCES and _RESOURCE data types. */ 4.30 -#include "Xen_NetworkPort_Resource.h" 4.31 +#include "cmpilify.h" 4.32 4.33 4.34 -// ---------------------------------------------------------------------------- 4.35 -// COMMON GLOBAL VARIABLES 4.36 -// ---------------------------------------------------------------------------- 4.37 +static const CMPIInstanceMI* mi; 4.38 + 4.39 +#define _BROKER (((CMPILIFYInstanceMI*)(mi->hdl))->brkr) 4.40 +#define _CLASS (((CMPILIFYInstanceMI*)(mi->hdl))->cn) 4.41 +#define _KEYS (((CMPILIFYInstanceMI*)(mi->hdl))->kys) 4.42 + 4.43 +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 4.44 4.45 -/* Handle to the CIM broker. Initialized when the provider lib is loaded. */ 4.46 -static const CMPIBroker *_BROKER; 4.47 +#include <stdlib.h> 4.48 +#include <xen_common.h> 4.49 +#include <xen_vm.h> 4.50 +#include <xen_vif.h> 4.51 +#include <xen_vm_power_state.h> 4.52 + 4.53 +#include "cmpitrace.h" 4.54 +#include "xen_utils.h" 4.55 +#include "provider_common.h" 4.56 + 4.57 4.58 /* Xen session object. Initialize when the provider is loaded, close when 4.59 * provider unloaded. */ 4.60 static xen_utils_session *session = NULL; 4.61 4.62 4.63 -// ============================================================================ 4.64 -// CMPI INSTANCE PROVIDER FUNCTION TABLE 4.65 -// ============================================================================ 4.66 +typedef struct { 4.67 + xen_vif_set *vifs; 4.68 + unsigned int currentvifnum; 4.69 +} vif_resource_list; 4.70 4.71 -// ---------------------------------------------------------------------------- 4.72 -// Info for the class supported by the instance provider 4.73 -// ---------------------------------------------------------------------------- 4.74 4.75 -/* Name of the class implemented by this instance provider. */ 4.76 -/*** CUSTOMIZE FOR EACH PROVIDER ***/ 4.77 static char * _CLASSNAME = "Xen_NetworkPort"; 4.78 4.79 -/* NULL terminated list of key properties of this class. */ 4.80 -/*** CUSTOMIZE FOR EACH PROVIDER ***/ 4.81 -const static char * _KEYNAMES[] = {"SystemName", "SystemCreationClassName", "DeviceID", "CreationClassName", NULL}; 4.82 +/* Class keys */ 4.83 +const static char * keys[] = {"SystemName", "SystemCreationClassName", 4.84 + "DeviceID", "CreationClassName", NULL}; 4.85 + 4.86 4.87 -// ---------------------------------------------------------------------------- 4.88 -// Cleanup() 4.89 -// Perform any necessary cleanup immediately before this provider is unloaded. 4.90 -// ---------------------------------------------------------------------------- 4.91 -static CMPIStatus Cleanup( 4.92 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 4.93 - const CMPIContext * context, /* [in] Additional context info, if any. */ 4.94 - CMPIBoolean terminating) /* [in] True if MB is terminating */ 4.95 +static CMPIrc load() 4.96 { 4.97 - CMPIStatus status = { CMPI_RC_OK, NULL }; /* Return status of CIM operations. */ 4.98 + /* Initialized Xen session object. */ 4.99 + if (!session) 4.100 + xen_utils_xen_init(&session); 4.101 + return CMPI_RC_OK; 4.102 +} 4.103 4.104 - _SBLIM_ENTER("Cleanup"); 4.105 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 4.106 - _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 4.107 4.108 +static CMPIrc unload(const int terminating) 4.109 +{ 4.110 + (void)terminating; 4.111 + /* Close Xen session object. */ 4.112 if (session) { 4.113 xen_utils_xen_close(session); 4.114 session = NULL; 4.115 } 4.116 - _SBLIM_RETURNSTATUS(status); 4.117 + return CMPI_RC_OK; 4.118 } 4.119 4.120 -// ---------------------------------------------------------------------------- 4.121 -// EnumInstanceNames() 4.122 -// Return a list of all the instances names (return their object paths only). 4.123 -// ---------------------------------------------------------------------------- 4.124 -static CMPIStatus EnumInstanceNames( 4.125 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 4.126 - const CMPIContext * context, /* [in] Additional context info, if any. */ 4.127 - const CMPIResult * results, /* [out] Results of this operation. */ 4.128 - const CMPIObjectPath * reference) /* [in] Contains target namespace and classname. */ 4.129 + 4.130 +static CMPIrc begin(void **res_list, const char **properties) 4.131 { 4.132 - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ 4.133 - _RESOURCES * resources = NULL; /* Handle to the list of system resources. */ 4.134 - _RESOURCE * resource; /* Handle to each system resource. */ 4.135 - char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */ 4.136 - int found = 0; /* Found any instances? */ 4.137 - 4.138 - _SBLIM_ENTER("EnumInstanceNames"); 4.139 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 4.140 - _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 4.141 - _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL)))); 4.142 - _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace)); 4.143 - 4.144 + vif_resource_list *vif_resources; 4.145 + xen_domain_resources *domain_resources = NULL; 4.146 + xen_vif_set *all_vifs = NULL; 4.147 + xen_vm_record *vm_rec = NULL; 4.148 + 4.149 + (void)properties; 4.150 + 4.151 + if (res_list == NULL) 4.152 + return CMPI_RC_ERR_FAILED; 4.153 + 4.154 if (!xen_utils_validate_session(&session)) { 4.155 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon"); 4.156 - goto exit; 4.157 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 4.158 + ("--- Unable to establish connection with Xend")); 4.159 + return CMPI_RC_ERR_FAILED; 4.160 } 4.161 4.162 - /* Get a handle to the list of system resources. */ 4.163 - if (!Xen_NetworkPort_getResources(session, &resources)) { 4.164 - _SBLIM_TRACE(1,("--- _getResources() failed")); 4.165 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources"); 4.166 - goto exit; 4.167 + vif_resources = (vif_resource_list *)calloc(1, sizeof(vif_resource_list)); 4.168 + if (vif_resources == NULL) 4.169 + return CMPI_RC_ERR_FAILED; 4.170 + 4.171 + if(!xen_vif_get_all(session->xen, &(vif_resources->vifs))) { 4.172 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 4.173 + ("--- Failed to retrieve list of vifs from xend")); 4.174 + _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR, 4.175 + xen_utils_trace_error(session->xen)); 4.176 + free(vif_resources); 4.177 + return CMPI_RC_ERR_FAILED; 4.178 } 4.179 + 4.180 + *res_list = (void *)vif_resources; 4.181 + return CMPI_RC_OK; 4.182 + 4.183 + Error: 4.184 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 4.185 + ("--- failed to retrieve vbd resources from Xend:")); 4.186 + if (session && session->xen) 4.187 + _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR, 4.188 + xen_utils_trace_error(session->xen)); 4.189 + 4.190 + xen_vif_set_free(all_vifs); 4.191 + xen_vm_record_free(vm_rec); 4.192 + xen_utils_free_domain_resources(domain_resources); 4.193 + free(vif_resources); 4.194 + return CMPI_RC_ERR_FAILED; 4.195 +} 4.196 4.197 - /* Enumerate thru the list of system resources and return a CMPIInstance for each. */ 4.198 - while (Xen_NetworkPort_getNextResource(session, resources, &resource)) { 4.199 - /* Create a new CMPIInstance to store this resource. */ 4.200 - CMPIInstance * instance = _CMNewInstance(_BROKER, namespace, _CLASSNAME, &status); 4.201 - if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instance)) { 4.202 - _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status.msg))); 4.203 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIInstance"); 4.204 - goto exit; 4.205 +static void end(void *res_list) 4.206 +{ 4.207 + vif_resource_list *vif_resources = (vif_resource_list *)res_list; 4.208 + 4.209 + if (vif_resources) { 4.210 + if (vif_resources->vifs) 4.211 + xen_vif_set_free(vif_resources->vifs); 4.212 + free(vif_resources); 4.213 + } 4.214 +} 4.215 + 4.216 +static CMPIrc getnext(void *res_list, void **res, const char **properties) 4.217 +{ 4.218 + vif_resource_list *vif_resources = (vif_resource_list *)res_list; 4.219 + xen_vif_record *vif_rec; 4.220 + 4.221 + (void)properties; 4.222 + 4.223 + if (vif_resources == NULL || res == NULL) 4.224 + return CMPI_RC_ERR_FAILED; 4.225 + 4.226 + /* Get next console resource. Ignore inactive domains. */ 4.227 + while (vif_resources->currentvifnum < vif_resources->vifs->size) { 4.228 + session->xen->ok = true; 4.229 + if (!xen_vif_get_record(session->xen, &vif_rec, 4.230 + vif_resources->vifs->contents[vif_resources->currentvifnum])) { 4.231 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 4.232 + ("--- Failed to retrieve vif record from xend")); 4.233 + _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR, 4.234 + xen_utils_trace_error(session->xen)); 4.235 + return CMPI_RC_ERR_FAILED; 4.236 } 4.237 - 4.238 - /* Set the instance property values from the resource data. */ 4.239 - if (!Xen_NetworkPort_setInstanceFromResource(session, resource, instance, _BROKER)) { 4.240 - _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed")); 4.241 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data"); 4.242 - goto exit; 4.243 + 4.244 + enum xen_vm_power_state p_state = XEN_VM_POWER_STATE_HALTED; 4.245 + xen_vm_get_power_state(session->xen, &p_state, vif_rec->vm->u.handle); 4.246 + if (p_state == XEN_VM_POWER_STATE_HALTED) { 4.247 + xen_vif_record_free(vif_rec); 4.248 + vif_resources->currentvifnum++; 4.249 + continue; 4.250 } 4.251 4.252 - /* Free the resource data. */ 4.253 - if (!Xen_NetworkPort_freeResource(resource)) { 4.254 - _SBLIM_TRACE(1,("--- _freeResource() failed")); 4.255 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data"); 4.256 - goto exit; 4.257 - } 4.258 - 4.259 - /* Return the CMPIObjectPath for this instance. */ 4.260 - CMPIObjectPath * objectpath = CMGetObjectPath(instance, &status); 4.261 - if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) { 4.262 - _SBLIM_TRACE(1,("--- CMGetObjectPath() failed - %s", CMGetCharPtr(status.msg))); 4.263 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot get CMPIObjectPath for instance"); 4.264 - goto exit; 4.265 - } 4.266 - CMSetNameSpace(objectpath, namespace); /* Note - CMGetObjectPath() does not preserve the namespace! */ 4.267 - 4.268 - _SBLIM_TRACE(3,("--- objectpath=\"%s\"", CMGetCharPtr(CDToString(_BROKER, objectpath, NULL)))); 4.269 - CMReturnObjectPath(results, objectpath); 4.270 - found++; 4.271 + vif_resources->currentvifnum++; 4.272 + *res = (void *)vif_rec; 4.273 + return CMPI_RC_OK; 4.274 } 4.275 - 4.276 - _SBLIM_TRACE(2,("--- %d object paths found", found)); 4.277 - CMReturnDone(results); 4.278 - 4.279 -exit: 4.280 - /* Free the list of system resources. */ 4.281 - if (!Xen_NetworkPort_freeResources(resources)) { 4.282 - _SBLIM_TRACE(1,("--- _freeResources() failed")); 4.283 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources"); 4.284 - } 4.285 - 4.286 - _SBLIM_RETURNSTATUS(status); 4.287 + 4.288 + return CMPI_RC_ERR_NOT_FOUND; 4.289 } 4.290 4.291 -// ---------------------------------------------------------------------------- 4.292 -// EnumInstances() 4.293 -// Return a list of all the instances (return all the instance data). 4.294 -// ---------------------------------------------------------------------------- 4.295 -static CMPIStatus EnumInstances( 4.296 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 4.297 - const CMPIContext * context, /* [in] Additional context info, if any. */ 4.298 - const CMPIResult * results, /* [out] Results of this operation. */ 4.299 - const CMPIObjectPath * reference, /* [in] Contains target namespace and classname. */ 4.300 - const char ** properties) /* [in] List of desired properties (NULL=all). */ 4.301 + 4.302 +static CMPIrc get(const void *res_id, void **res, const char **properties) 4.303 { 4.304 - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ 4.305 - _RESOURCES * resources = NULL; /* Handle to the list of system resources. */ 4.306 - _RESOURCE * resource; /* Handle to each system resource. */ 4.307 - char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */ 4.308 - int found = 0; /* Found any resource instances? */ 4.309 + CMPIInstance *inst = (CMPIInstance *)res_id; 4.310 + CMPIData data; 4.311 + CMPIStatus status = {CMPI_RC_OK, NULL}; 4.312 + char *dev_uuid; 4.313 4.314 - _SBLIM_ENTER("EnumInstances"); 4.315 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 4.316 - _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 4.317 - _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL)))); 4.318 - _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace)); 4.319 + (void)properties; 4.320 + 4.321 + if (CMIsNullObject(inst) || res == NULL) 4.322 + return CMPI_RC_ERR_FAILED; 4.323 + 4.324 + data = CMGetProperty(inst, "DeviceID", &status); 4.325 + if ((status.rc != CMPI_RC_OK) || CMIsNullValue(data)) 4.326 + return CMPI_RC_ERR_FAILED; 4.327 + 4.328 + /* Extract the domain name string from the CMPIString. */ 4.329 + dev_uuid = CMGetCharPtr(data.value.string); 4.330 + if ((dev_uuid == NULL) || (*dev_uuid == '\0')) 4.331 + return CMPI_RC_ERR_FAILED; 4.332 4.333 if (!xen_utils_validate_session(&session)) { 4.334 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon"); 4.335 - goto exit; 4.336 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 4.337 + ("--- Unable to establish connection with Xend")); 4.338 + return CMPI_RC_ERR_FAILED; 4.339 } 4.340 - 4.341 - /* Get a handle to the list of system resources. */ 4.342 - if (!Xen_NetworkPort_getResources(session, &resources)) { 4.343 - _SBLIM_TRACE(1,("--- _getResources() failed")); 4.344 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources"); 4.345 - goto exit; 4.346 + 4.347 + xen_vif_record *vif_rec; 4.348 + if (!xen_vif_get_record(session->xen, &vif_rec, (xen_vif)dev_uuid)) { 4.349 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 4.350 + ("--- xen_vif_get_record failed:")); 4.351 + _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR, 4.352 + xen_utils_trace_error(session->xen)); 4.353 + return CMPI_RC_ERR_FAILED; 4.354 } 4.355 4.356 - /* Enumerate thru the list of system resources and return a CMPIInstance for each. */ 4.357 - while (Xen_NetworkPort_getNextResource(session, resources, &resource)) { 4.358 - /* Create a new CMPIInstance to store this resource. */ 4.359 - CMPIInstance * instance = _CMNewInstance(_BROKER, namespace, _CLASSNAME, &status); 4.360 - if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instance)) { 4.361 - _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status.msg))); 4.362 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIInstance"); 4.363 - goto exit; 4.364 - } 4.365 - 4.366 - /* Setup a filter to only return the desired properties. */ 4.367 - status = CMSetPropertyFilter(instance, properties, _KEYNAMES); 4.368 - if (status.rc != CMPI_RC_OK) { 4.369 - _SBLIM_TRACE(1, ("--- CMSetPropertyFilter() failed - %s", CMGetCharPtr(status.msg))); 4.370 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Cannot set property filter"); 4.371 - goto exit; 4.372 - } 4.373 - 4.374 - /* Set the instance property values from the resource data. */ 4.375 - if (!Xen_NetworkPort_setInstanceFromResource(session, resource, instance, _BROKER)) { 4.376 - _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed")); 4.377 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data"); 4.378 - goto exit; 4.379 - } 4.380 - 4.381 - /* Free the resource data. */ 4.382 - if (!Xen_NetworkPort_freeResource(resource)) { 4.383 - _SBLIM_TRACE(1,("--- _freeResource() failed")); 4.384 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data"); 4.385 - goto exit; 4.386 - } 4.387 - 4.388 - /* Return the CMPIInstance for this instance. */ 4.389 - _SBLIM_TRACE(3,("--- instance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, instance, NULL)))); 4.390 - CMReturnInstance(results, instance); 4.391 - found++; 4.392 + enum xen_vm_power_state pstate; 4.393 + if (!xen_vm_get_power_state(session->xen, &pstate, vif_rec->vm->u.handle)) { 4.394 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 4.395 + ("--- xen_vm_get_power_state failed:")); 4.396 + _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR, 4.397 + xen_utils_trace_error(session->xen)); 4.398 + xen_vif_record_free(vif_rec); 4.399 + 4.400 + return CMPI_RC_ERR_FAILED; 4.401 } 4.402 4.403 - _SBLIM_TRACE(2,("--- %d instances found", found)); 4.404 - CMReturnDone(results); 4.405 + if (pstate == XEN_VM_POWER_STATE_HALTED) { 4.406 + xen_vif_record_free(vif_rec); 4.407 + return CMPI_RC_ERR_NOT_FOUND; 4.408 + } 4.409 + 4.410 + *res = (void *)vif_rec; 4.411 + return CMPI_RC_OK; 4.412 +} 4.413 + 4.414 4.415 -exit: 4.416 - /* Free the list of system resources. */ 4.417 - if (!Xen_NetworkPort_freeResources(resources)) { 4.418 - _SBLIM_TRACE(1,("--- _freeResources() failed")); 4.419 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources"); 4.420 - } 4.421 +static void release(void *res) 4.422 +{ 4.423 + xen_vif_record_free((xen_vif_record *)res); 4.424 +} 4.425 + 4.426 4.427 - _SBLIM_RETURNSTATUS(status); 4.428 +static CMPIrc add(const void *res_id, const void *res) 4.429 +{ 4.430 + (void)res_id; 4.431 + (void)res; 4.432 + 4.433 + return CMPI_RC_ERR_NOT_SUPPORTED; /* unsupported*/ 4.434 } 4.435 4.436 -// ---------------------------------------------------------------------------- 4.437 -// GetInstance() 4.438 -// Return the instance data for the specified instance only. 4.439 -// ---------------------------------------------------------------------------- 4.440 -static CMPIStatus GetInstance( 4.441 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 4.442 - const CMPIContext * context, /* [in] Additional context info, if any. */ 4.443 - const CMPIResult * results, /* [out] Results of this operation. */ 4.444 - const CMPIObjectPath * reference, /* [in] Contains the target namespace, classname and object path. */ 4.445 - const char ** properties) /* [in] List of desired properties (NULL=all). */ 4.446 + 4.447 +static CMPIrc delete(const void *res_id) 4.448 { 4.449 - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ 4.450 - _RESOURCES * resources = NULL; /* Handle to the list of system resources. */ 4.451 - _RESOURCE * resource; /* Handle to the system resource. */ 4.452 - char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */ 4.453 - int found = 0; /* Found the target instance? */ 4.454 + CMPIInstance *inst = (CMPIInstance *)res_id; 4.455 + CMPIData data; 4.456 + CMPIStatus status = {CMPI_RC_OK, NULL}; 4.457 + char *dev_uuid; 4.458 + 4.459 + if (CMIsNullObject(inst)) 4.460 + return CMPI_RC_ERR_FAILED; 4.461 4.462 - _SBLIM_ENTER("GetInstance"); 4.463 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 4.464 - _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 4.465 - _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL)))); 4.466 - _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace)); 4.467 + data = CMGetProperty(inst, "DeviceID", &status); 4.468 + if ((status.rc != CMPI_RC_OK) || CMIsNullValue(data)) 4.469 + return CMPI_RC_ERR_FAILED; 4.470 4.471 - if (!xen_utils_validate_session(&session)) { 4.472 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon"); 4.473 - goto exit; 4.474 + /* Extract the domain name string from the CMPIString. */ 4.475 + dev_uuid = CMGetCharPtr(data.value.string); 4.476 + if ((dev_uuid == NULL) || (*dev_uuid == '\0')) 4.477 + return CMPI_RC_ERR_FAILED; 4.478 + 4.479 + if (!xen_utils_validate_session(&session)) { 4.480 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 4.481 + ("--- Unable to establish connection with Xend")); 4.482 + return CMPI_RC_ERR_FAILED; 4.483 } 4.484 4.485 - /* Get a handle to the list of system resources. */ 4.486 - if (!Xen_NetworkPort_getResources(session, &resources)) { 4.487 - _SBLIM_TRACE(1,("--- _getResources() failed")); 4.488 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources"); 4.489 - goto exit; 4.490 + if (!xen_vif_destroy(session->xen, (xen_vif)dev_uuid)) { 4.491 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 4.492 + ("--- xen_vif_destroy failed:")); 4.493 + _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR, 4.494 + xen_utils_trace_error(session->xen)); 4.495 + return CMPI_RC_ERR_FAILED; 4.496 } 4.497 4.498 - /* Get the target resource. */ 4.499 - found = Xen_NetworkPort_getResourceForObjectPath(session, &resource, reference); 4.500 - if (!found || (resource == NULL)) { 4.501 - _SBLIM_TRACE(1,("--- Target instance not found")); 4.502 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_FOUND, "Target instance not found"); 4.503 - goto exit; 4.504 - } 4.505 + return CMPI_RC_OK; 4.506 +} 4.507 + 4.508 + 4.509 +static CMPIrc modify(const void *res_id, const void *modified_res, 4.510 + const char **properties) 4.511 +{ 4.512 + (void)res_id; 4.513 + (void)modified_res; 4.514 + (void)properties; 4.515 + 4.516 + return CMPI_RC_ERR_NOT_SUPPORTED; /* unsupported */ 4.517 +} 4.518 4.519 - /* Create a new CMPIInstance to store this resource. */ 4.520 - CMPIInstance * instance = _CMNewInstance(_BROKER, namespace, _CLASSNAME, &status); 4.521 - if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instance)) { 4.522 - _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status.msg))); 4.523 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIInstance"); 4.524 - goto exit; 4.525 +/* Set CMPIInstance properties from the resource data. */ 4.526 +static CMPIrc setproperties(CMPIInstance *inst, const void *res, 4.527 + const char **properties) 4.528 +{ 4.529 + xen_vif_record *vif_rec = (xen_vif_record *)res; 4.530 + 4.531 + if (vif_rec == NULL || CMIsNullObject(inst)) 4.532 + return CMPI_RC_ERR_FAILED; 4.533 + 4.534 + session->xen->ok = true; 4.535 + 4.536 + char *dom_name; 4.537 + if (!xen_vm_get_name_label(session->xen, &dom_name, vif_rec->vm->u.handle)) { 4.538 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 4.539 + ("--- Failed to retrieve domain name associated with vif")); 4.540 + _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR, 4.541 + xen_utils_trace_error(session->xen)); 4.542 + return CMPI_RC_ERR_FAILED; 4.543 } 4.544 4.545 /* Setup a filter to only return the desired properties. */ 4.546 - status = CMSetPropertyFilter(instance, properties, _KEYNAMES); 4.547 - if (status.rc != CMPI_RC_OK) { 4.548 - _SBLIM_TRACE(1, ("--- CMSetPropertyFilter() failed - %s", CMGetCharPtr(status.msg))); 4.549 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Cannot set property filter"); 4.550 - goto exit; 4.551 - } 4.552 - 4.553 - /* Set the instance property values from the resource data. */ 4.554 - if (!Xen_NetworkPort_setInstanceFromResource(session, resource, instance, _BROKER)) { 4.555 - _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed")); 4.556 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data"); 4.557 - goto exit; 4.558 - } 4.559 - 4.560 - /* Free the resource data. */ 4.561 - if (!Xen_NetworkPort_freeResource(resource)) { 4.562 - _SBLIM_TRACE(1,("--- _freeResource() failed")); 4.563 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data"); 4.564 - goto exit; 4.565 - } 4.566 - 4.567 - /* Return the CMPIInstance for this instance. */ 4.568 - _SBLIM_TRACE(3,("--- instance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, instance, NULL)))); 4.569 - CMReturnInstance(results, instance); 4.570 - 4.571 - _SBLIM_TRACE(2,("--- instance found")); 4.572 - CMReturnDone(results); 4.573 + CMSetPropertyFilter(inst, properties, keys); 4.574 4.575 -exit: 4.576 - /* Free the list of system resources. */ 4.577 - if (!Xen_NetworkPort_freeResources(resources)) { 4.578 - _SBLIM_TRACE(1,("--- _freeResources() failed")); 4.579 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources"); 4.580 - } 4.581 - 4.582 - _SBLIM_RETURNSTATUS(status); 4.583 -} 4.584 + /* Set the CMPIInstance properties from the resource data. */ 4.585 + CMSetProperty(inst, "SystemCreationClassName",(CMPIValue *)"Xen_ComputerSystem", CMPI_chars); 4.586 + CMSetProperty(inst, "SystemName",(CMPIValue *)dom_name, CMPI_chars); 4.587 + CMSetProperty(inst, "CreationClassName",(CMPIValue *)"Xen_NetworkPort", CMPI_chars); 4.588 + 4.589 + CMSetProperty(inst, "DeviceID",(CMPIValue *)vif_rec->uuid, CMPI_chars); 4.590 4.591 -// ---------------------------------------------------------------------------- 4.592 -// SetInstance() 4.593 -// Save modified instance data for the specified instance. 4.594 -// ---------------------------------------------------------------------------- 4.595 -static CMPIStatus SetInstance( 4.596 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 4.597 - const CMPIContext * context, /* [in] Additional context info, if any. */ 4.598 - const CMPIResult * results, /* [out] Results of this operation. */ 4.599 - const CMPIObjectPath * reference, /* [in] Contains the target namespace, classname and object path. */ 4.600 - const CMPIInstance * newinstance, /* [in] Contains the new instance data. */ 4.601 - const char **properties) 4.602 -{ 4.603 - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ 4.604 - _RESOURCES * resources = NULL; /* Handle to the list of system resources. */ 4.605 - _RESOURCE * resource; /* Handle to the system resource. */ 4.606 - char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */ 4.607 - int found = 0; /* Found the target instance? */ 4.608 + CMSetProperty(inst, "Caption",(CMPIValue *)"Network Port", CMPI_chars); 4.609 + CMSetProperty(inst, "Description",(CMPIValue *)"Network Port", CMPI_chars); 4.610 + CMSetProperty(inst, "Status", (CMPIValue *)"OK", CMPI_chars); 4.611 4.612 - _SBLIM_ENTER("SetInstance"); 4.613 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 4.614 - _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 4.615 - _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL)))); 4.616 - _SBLIM_TRACE(2, ("--- newinstance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, newinstance, NULL)))); 4.617 - _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace)); 4.618 - 4.619 - if (!xen_utils_validate_session(&session)) { 4.620 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon"); 4.621 - goto exit; 4.622 - } 4.623 + //CMSetProperty(inst, "NICConfigInfo",(CMPIValue *)resource->vif[vifnum].params, CMPI_chars); 4.624 4.625 - /* Get a handle to the list of system resources. */ 4.626 - if (!Xen_NetworkPort_getResources(session, &resources)) { 4.627 - _SBLIM_TRACE(1,("--- _getResources() failed")); 4.628 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources"); 4.629 - goto exit; 4.630 - } 4.631 - 4.632 - /* Get the target resource. */ 4.633 - found = Xen_NetworkPort_getResourceForObjectPath(session, &resource, reference); 4.634 - if (!found || (resource == NULL)) { 4.635 - _SBLIM_TRACE(1,("--- Target instance not found")); 4.636 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_FOUND, "Target instance not found"); 4.637 - goto exit; 4.638 - } 4.639 + int link_tech = 2; /* 2 == Ethernet */ 4.640 + CMSetProperty(inst, "LinkTechnology",(CMPIValue *)&link_tech, CMPI_uint16); 4.641 4.642 - _SBLIM_TRACE(2,("--- instance found", found)); 4.643 - 4.644 - /* Update the target resource data with the new instance property values. */ 4.645 - int rc = Xen_NetworkPort_setResourceFromInstance(resource, newinstance, _BROKER); 4.646 - 4.647 - /* Free the resource data. */ 4.648 - if (!Xen_NetworkPort_freeResource(resource)) { 4.649 - _SBLIM_TRACE(1,("--- _freeResource() failed")); 4.650 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data"); 4.651 - goto exit; 4.652 + if (vif_rec->device) { 4.653 + CMSetProperty(inst, "Name",(CMPIValue *)vif_rec->device, CMPI_chars); 4.654 + CMSetProperty(inst, "VIFName",(CMPIValue *)vif_rec->device, CMPI_chars); 4.655 } 4.656 - 4.657 - if (rc != 1) { 4.658 - if (rc == -1) { 4.659 - _SBLIM_TRACE(1,("--- _setResourceFromInstance() unsupported")); 4.660 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL); 4.661 - } else { 4.662 - _SBLIM_TRACE(1,("--- _setResourceFromInstance() failed")); 4.663 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set resource data from instance properties"); 4.664 - } 4.665 - goto exit; 4.666 - } 4.667 - 4.668 -exit: 4.669 - /* Free the list of system resources. */ 4.670 - if (!Xen_NetworkPort_freeResources(resources)) { 4.671 - _SBLIM_TRACE(1,("--- _freeResources() failed")); 4.672 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources"); 4.673 + 4.674 + if (vif_rec->mac) 4.675 + CMSetProperty(inst, "PermanentAddress",(CMPIValue *)vif_rec->mac, CMPI_chars); 4.676 + if (vif_rec->mtu > 0) { 4.677 + CMSetProperty(inst, "SupportedMaximumTransmissionUnit",(CMPIValue *)&(vif_rec->mtu), CMPI_uint64); 4.678 + CMSetProperty(inst, "ActiveMaximumTransmissionUnit",(CMPIValue *)&(vif_rec->mtu), CMPI_uint64); 4.679 } 4.680 4.681 - _SBLIM_RETURNSTATUS(status); 4.682 -} 4.683 - 4.684 -// ---------------------------------------------------------------------------- 4.685 -// CreateInstance() 4.686 -// Create a new instance from the specified instance data. 4.687 -// ---------------------------------------------------------------------------- 4.688 -static CMPIStatus CreateInstance( 4.689 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 4.690 - const CMPIContext * context, /* [in] Additional context info, if any. */ 4.691 - const CMPIResult * results, /* [out] Results of this operation. */ 4.692 - const CMPIObjectPath * reference, /* [in] Contains the target namespace, classname and object path. */ 4.693 - const CMPIInstance * newinstance) /* [in] Contains the new instance data. */ 4.694 -{ 4.695 - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ 4.696 - _RESOURCES * resources = NULL; /* Handle to the list of system resources. */ 4.697 - _RESOURCE * resource; /* Handle to the system resource. */ 4.698 - char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */ 4.699 - int found = 0; /* Found the target instance? */ 4.700 - 4.701 - _SBLIM_ENTER("CreateInstance"); 4.702 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 4.703 - _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 4.704 - _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL)))); 4.705 - _SBLIM_TRACE(2, ("--- newinstance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, newinstance, NULL)))); 4.706 - _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace)); 4.707 - 4.708 - if (!xen_utils_validate_session(&session)) { 4.709 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon"); 4.710 - goto exit; 4.711 - } 4.712 - 4.713 - /* WORKAROUND FOR PEGASUS BUG?! reference does not contain object path, only namespace & classname. */ 4.714 - reference = CMGetObjectPath(newinstance, NULL); 4.715 - 4.716 - /* Get a handle to the list of system resources. */ 4.717 - if (!Xen_NetworkPort_getResources(session, &resources)) { 4.718 - _SBLIM_TRACE(1,("--- _getResources() failed")); 4.719 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources"); 4.720 - goto exit; 4.721 - } 4.722 - 4.723 - /* Get the target resource. */ 4.724 - found = Xen_NetworkPort_getResourceForObjectPath(session, &resource, reference); 4.725 - 4.726 - /* Free the resource data. */ 4.727 - if (!Xen_NetworkPort_freeResource(resource)) { 4.728 - _SBLIM_TRACE(1,("--- _freeResource() failed")); 4.729 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data"); 4.730 - goto exit; 4.731 - } 4.732 - 4.733 - if (found) { 4.734 - _SBLIM_TRACE(1,("--- Target instance already exists")); 4.735 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_ALREADY_EXISTS, "Target instance already exists"); 4.736 - goto exit; 4.737 - } 4.738 + char nic_config_info[512]; 4.739 + nic_config_info[0] = '\0'; 4.740 + if (vif_rec->mac) 4.741 + snprintf(nic_config_info, 512, "mac=%s", vif_rec->mac); 4.742 + /*if (resource->model) { 4.743 + strncat(nic_config_info, ",model=", 512 - strlen(nic_config_info)); 4.744 + strncat(nic_config_info, resource->model, 512 - strlen(nic_config_info)); 4.745 + } NIC config info does not have model*/ 4.746 + if (nic_config_info[0] != '\0') 4.747 + CMSetProperty(inst, "NICConfigInfo" , (CMPIValue *)nic_config_info, CMPI_chars); 4.748 4.749 - /* Create a new resource with the new instance property values. */ 4.750 - int rc = Xen_NetworkPort_createResourceFromInstance(resources, &resource, newinstance, _BROKER); 4.751 - if (rc != 1) { 4.752 - if (rc == -1) { 4.753 - _SBLIM_TRACE(1,("--- _createResourceFromInstance() unsupported")); 4.754 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL); 4.755 - } else { 4.756 - _SBLIM_TRACE(1,("--- _createResourceFromInstance() failed")); 4.757 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to create resource data from instance properties"); 4.758 - } 4.759 - goto exit; 4.760 - } 4.761 - 4.762 - /* Return the object path for the newly created instance. */ 4.763 - CMPIObjectPath * objectpath = CMGetObjectPath(newinstance, NULL); 4.764 - CMSetNameSpace(objectpath, namespace); 4.765 - CMReturnObjectPath(results, objectpath); 4.766 - CMReturnDone(results); 4.767 - 4.768 -exit: 4.769 - /* Free the list of system resources. */ 4.770 - if (!Xen_NetworkPort_freeResources(resources)) { 4.771 - _SBLIM_TRACE(1,("--- _freeResources() failed")); 4.772 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources"); 4.773 - } 4.774 - 4.775 - _SBLIM_RETURNSTATUS(status); 4.776 -} 4.777 - 4.778 -// ---------------------------------------------------------------------------- 4.779 -// DeleteInstance() 4.780 -// Delete or remove the specified instance from the system. 4.781 -// ---------------------------------------------------------------------------- 4.782 -static CMPIStatus DeleteInstance( 4.783 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 4.784 - const CMPIContext * context, /* [in] Additional context info, if any. */ 4.785 - const CMPIResult * results, /* [out] Results of this operation. */ 4.786 - const CMPIObjectPath * reference) /* [in] Contains the target namespace, classname and object path. */ 4.787 -{ 4.788 - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ 4.789 - _RESOURCE * resource = NULL; /* Handle to the system resource. */ 4.790 - char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */ 4.791 - int found = 0; /* Found the target instance? */ 4.792 - char error_msg[XEN_UTILS_ERROR_BUF_LEN]; 4.793 - 4.794 - _SBLIM_ENTER("DeleteInstance"); 4.795 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 4.796 - _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 4.797 - _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL)))); 4.798 - _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace)); 4.799 - 4.800 - if (!xen_utils_validate_session(&session)) { 4.801 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon"); 4.802 - goto exit; 4.803 - } 4.804 - 4.805 - /* Get the target resource. */ 4.806 - found = Xen_NetworkPort_getResourceForObjectPath(session, &resource, reference); 4.807 - if (!found || (resource == NULL)) { 4.808 - _SBLIM_TRACE(1,("--- Target instance not found")); 4.809 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_FOUND, "Target instance not found"); 4.810 - goto exit; 4.811 - } 4.812 - 4.813 - _SBLIM_TRACE(2,("--- instance found", found)); 4.814 - 4.815 - /* Delete the target resource. */ 4.816 - if (!Xen_NetworkPort_deleteResource(session, resource)) { 4.817 - XEN_UTILS_GET_ERROR_STRING(error_msg, session->xen); 4.818 - _SBLIM_TRACE(1,("--- deleteResource failed: %s", error_msg)); 4.819 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, error_msg); 4.820 - goto exit; 4.821 - } 4.822 - 4.823 -exit: 4.824 - /* Free the resource. */ 4.825 - if (resource) 4.826 - Xen_NetworkPort_freeResource(resource); 4.827 - 4.828 - _SBLIM_RETURNSTATUS(status); 4.829 + return CMPI_RC_OK; 4.830 } 4.831 4.832 4.833 -// ---------------------------------------------------------------------------- 4.834 -// ExecQuery() 4.835 -// Return a list of all the instances that satisfy the specified query filter. 4.836 -// ---------------------------------------------------------------------------- 4.837 -static CMPIStatus ExecQuery( 4.838 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 4.839 - const CMPIContext * context, /* [in] Additional context info, if any. */ 4.840 - const CMPIResult * results, /* [out] Results of this operation. */ 4.841 - const CMPIObjectPath * reference, /* [in] Contains the target namespace and classname. */ 4.842 - const char * language, /* [in] Name of the query language. */ 4.843 - const char * query) /* [in] Text of the query written in the query language. */ 4.844 +/* 4.845 + * Set resource data from the CMPIInstance properties. Only needs to 4.846 + * be implemented if add() and/or modify() are supported. 4.847 + */ 4.848 +static CMPIrc extract(void **res, const CMPIInstance *inst, 4.849 + const char **properties) 4.850 { 4.851 - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ 4.852 - char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */ 4.853 - 4.854 - _SBLIM_ENTER("ExecQuery"); 4.855 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 4.856 - _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 4.857 - _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL)))); 4.858 - _SBLIM_TRACE(2, ("--- language=\"%s\"", language)); 4.859 - _SBLIM_TRACE(2, ("--- query=\"%s\"", query)); 4.860 - _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace)); 4.861 - 4.862 - /* EXECQUERY() IS NOT YET SUPPORTED FOR THIS CLASS */ 4.863 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL); 4.864 - 4.865 - CMReturnDone(results); 4.866 - 4.867 -exit: 4.868 - _SBLIM_RETURNSTATUS(status); 4.869 + (void)res; 4.870 + (void)inst; 4.871 + (void)properties; 4.872 + 4.873 + return CMPI_RC_ERR_NOT_SUPPORTED; /* unsupported */ 4.874 } 4.875 4.876 -// ---------------------------------------------------------------------------- 4.877 -// Initialize() 4.878 -// Perform any necessary initialization immediately after this provider is 4.879 -// first loaded. 4.880 -// ---------------------------------------------------------------------------- 4.881 -static void Initialize( 4.882 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 4.883 - const CMPIContext * context) /* [in] Additional context info, if any. */ 4.884 + 4.885 +/* Get resource id from CMPIInstance properties. */ 4.886 +static CMPIrc extractid(void **res_id, const CMPIInstance* inst) 4.887 { 4.888 - _SBLIM_ENTER("Initialize"); 4.889 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 4.890 - // _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 4.891 - 4.892 - /* Initialized Xen session object. */ 4.893 - if (session == NULL) 4.894 - xen_utils_xen_init(&session); 4.895 - 4.896 - _SBLIM_RETURN(); 4.897 + *res_id = (void *)inst; 4.898 + return CMPI_RC_OK; 4.899 } 4.900 4.901 -// ============================================================================ 4.902 -// CMPI INSTANCE PROVIDER FUNCTION TABLE SETUP 4.903 -// ============================================================================ 4.904 -CMInstanceMIStub( , Xen_NetworkPort, _BROKER, Initialize(&mi, ctx)); 4.905 + 4.906 +/* Release resource id created in resId4inst(). */ 4.907 +static void releaseid(void* res_id) 4.908 +{ 4.909 + (void)res_id; 4.910 +} 4.911 + 4.912 + 4.913 +/* Setup CMPILIFY function tables and instance provider entry point.*/ 4.914 +/* CMPILIFYInstanceMIStub(<CLASS>,<PROVIDER_NAME>,<keys>,<CMPIInstanceMI_HANDLE>) */ 4.915 +CMPILIFYInstanceMIStub(Xen_NetworkPort, Xen_NetworkPort, keys, mi)
5.1 --- a/src/Xen_NetworkPortSettingData.c Thu Aug 02 17:54:59 2007 -0600 5.2 +++ b/src/Xen_NetworkPortSettingData.c Fri Aug 10 15:32:54 2007 -0600 5.3 @@ -16,607 +16,401 @@ 5.4 // ============================================================================ 5.5 // Authors: Dr. Gareth S. Bestor, <bestor@us.ibm.com> 5.6 // Contributors: Jim Fehlig, <jfehlig@novell.com> 5.7 +// Contributors: Raj Subrahmanian <raj.subrahmanian@unisys.com> 5.8 // Description: 5.9 // ============================================================================ 5.10 5.11 -/* Include the required CMPI data types, function headers, and macros */ 5.12 -#include "cmpidt.h" 5.13 -#include "cmpift.h" 5.14 -#include "cmpimacs.h" 5.15 5.16 -/* Include utility functions */ 5.17 -#include "cmpiutil.h" 5.18 +/* Common declarations for each CMPI "cmpilify" instance provider */ 5.19 +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 5.20 +#include <cmpidt.h> 5.21 +#include <cmpimacs.h> 5.22 + 5.23 +#include "cmpilify.h" 5.24 5.25 -/* Include _SBLIM_TRACE() logging support */ 5.26 -#include "cmpitrace.h" 5.27 + 5.28 +static const CMPIInstanceMI* mi; 5.29 5.30 -/* Include Xen utilities */ 5.31 -#include "xen_utils.h" 5.32 +#define _BROKER (((CMPILIFYInstanceMI*)(mi->hdl))->brkr) 5.33 +#define _CLASS (((CMPILIFYInstanceMI*)(mi->hdl))->cn) 5.34 +#define _KEYS (((CMPILIFYInstanceMI*)(mi->hdl))->kys) 5.35 5.36 -/* Include the abstract resource access functions and abstracted _RESOURCES and _RESOURCE data types. */ 5.37 -#include "Xen_NetworkPortSettingData_Resource.h" 5.38 +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 5.39 5.40 5.41 -// ---------------------------------------------------------------------------- 5.42 -// COMMON GLOBAL VARIABLES 5.43 -// ---------------------------------------------------------------------------- 5.44 +#include <stdlib.h> 5.45 +#include <xen_common.h> 5.46 +#include <xen_vm.h> 5.47 +#include <xen_vif.h> 5.48 + 5.49 +#include "cmpiutil.h" 5.50 +#include "cmpitrace.h" 5.51 +#include "xen_utils.h" 5.52 +#include "provider_common.h" 5.53 + 5.54 5.55 -/* Handle to the CIM broker. Initialized when the provider lib is loaded. */ 5.56 -static const CMPIBroker *_BROKER; 5.57 +/* C struct to store the data for a single resource. */ 5.58 +typedef struct { 5.59 + int is_vif_record; 5.60 + union 5.61 + { 5.62 + xen_vif_record *vif_rec; 5.63 + CMPIInstance *cmpi_inst; 5.64 + } u; 5.65 +} vif_resource; 5.66 + 5.67 + 5.68 +/* C struct to store the data for all resources. */ 5.69 +typedef struct { 5.70 + xen_vif_set *vifs; 5.71 + unsigned int currentvifnum; 5.72 +} vif_resource_list; 5.73 + 5.74 + 5.75 +/* Class keys */ 5.76 +static const char *keys[] = {"InstanceID", NULL}; 5.77 + 5.78 5.79 /* Xen session object. Initialize when the provider is loaded, close when 5.80 * provider unloaded. */ 5.81 static xen_utils_session *session = NULL; 5.82 5.83 5.84 -// ============================================================================ 5.85 -// CMPI INSTANCE PROVIDER FUNCTION TABLE 5.86 -// ============================================================================ 5.87 - 5.88 -// ---------------------------------------------------------------------------- 5.89 -// Info for the class supported by the instance provider 5.90 -// ---------------------------------------------------------------------------- 5.91 - 5.92 -/* Name of the class implemented by this instance provider. */ 5.93 -/*** CUSTOMIZE FOR EACH PROVIDER ***/ 5.94 -static char * _CLASSNAME = "Xen_NetworkPortSettingData"; 5.95 - 5.96 -/* NULL terminated list of key properties of this class. */ 5.97 -/*** CUSTOMIZE FOR EACH PROVIDER ***/ 5.98 -const static char * _KEYNAMES[] = {"InstanceID", NULL}; 5.99 +static CMPIrc load() 5.100 +{ 5.101 + /* Initialized Xen session object. */ 5.102 + if (!session) 5.103 + xen_utils_xen_init(&session); 5.104 + return CMPI_RC_OK; 5.105 +} 5.106 5.107 -// ---------------------------------------------------------------------------- 5.108 -// Cleanup() 5.109 -// Perform any necessary cleanup immediately before this provider is unloaded. 5.110 -// ---------------------------------------------------------------------------- 5.111 -static CMPIStatus Cleanup( 5.112 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 5.113 - const CMPIContext * context, /* [in] Additional context info, if any. */ 5.114 - CMPIBoolean terminating) /* [in] True if MB is terminating */ 5.115 + 5.116 +static CMPIrc unload(const int terminating) 5.117 { 5.118 - CMPIStatus status = { CMPI_RC_OK, NULL }; /* Return status of CIM operations. */ 5.119 - 5.120 - _SBLIM_ENTER("Cleanup"); 5.121 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 5.122 - _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 5.123 - 5.124 + (void)terminating; 5.125 + /* Close Xen session object. */ 5.126 if (session) { 5.127 xen_utils_xen_close(session); 5.128 session = NULL; 5.129 } 5.130 - _SBLIM_RETURNSTATUS(status); 5.131 + return CMPI_RC_OK; 5.132 } 5.133 5.134 -// ---------------------------------------------------------------------------- 5.135 -// EnumInstanceNames() 5.136 -// Return a list of all the instances names (return their object paths only). 5.137 -// ---------------------------------------------------------------------------- 5.138 -static CMPIStatus EnumInstanceNames( 5.139 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 5.140 - const CMPIContext * context, /* [in] Additional context info, if any. */ 5.141 - const CMPIResult * results, /* [out] Results of this operation. */ 5.142 - const CMPIObjectPath * reference) /* [in] Contains target namespace and classname. */ 5.143 + 5.144 +static CMPIrc begin(void **res_list, const char **properties) 5.145 { 5.146 - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ 5.147 - _RESOURCES * resources = NULL; /* Handle to the list of system resources. */ 5.148 - _RESOURCE * resource; /* Handle to each system resource. */ 5.149 - char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */ 5.150 - int found = 0; /* Found any instances? */ 5.151 - 5.152 - _SBLIM_ENTER("EnumInstanceNames"); 5.153 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 5.154 - _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 5.155 - _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL)))); 5.156 - _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace)); 5.157 - 5.158 + vif_resource_list *vif_resources; 5.159 + 5.160 + (void)properties; 5.161 + 5.162 + if (res_list == NULL) 5.163 + return CMPI_RC_ERR_FAILED; 5.164 + 5.165 if (!xen_utils_validate_session(&session)) { 5.166 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon"); 5.167 - goto exit; 5.168 - } 5.169 - 5.170 - /* Get a handle to the list of system resources. */ 5.171 - if (!Xen_NetworkPortSettingData_getResources(session, &resources)) { 5.172 - _SBLIM_TRACE(1,("--- _getResources() failed")); 5.173 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources"); 5.174 - goto exit; 5.175 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 5.176 + ("--- Unable to establish connection with Xend")); 5.177 + return CMPI_RC_ERR_FAILED; 5.178 } 5.179 5.180 - /* Enumerate thru the list of system resources and return a CMPIInstance for each. */ 5.181 - while (Xen_NetworkPortSettingData_getNextResource(session, resources, &resource)) { 5.182 - /* Create a new CMPIInstance to store this resource. */ 5.183 - CMPIInstance * instance = _CMNewInstance(_BROKER, namespace, _CLASSNAME, &status); 5.184 - if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instance)) { 5.185 - _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status.msg))); 5.186 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIInstance"); 5.187 - goto exit; 5.188 - } 5.189 + vif_resources = (vif_resource_list *)calloc(1, sizeof(vif_resource_list)); 5.190 + if (vif_resources == NULL) 5.191 + return CMPI_RC_ERR_FAILED; 5.192 + 5.193 + if(!xen_vif_get_all(session->xen, &(vif_resources->vifs))) { 5.194 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 5.195 + ("--- Failed to retrieve list of vifs from xend")); 5.196 + _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR, 5.197 + xen_utils_trace_error(session->xen)); 5.198 + free(vif_resources); 5.199 + return CMPI_RC_ERR_FAILED; 5.200 + } 5.201 + 5.202 + *res_list = (void *)vif_resources; 5.203 + return CMPI_RC_OK; 5.204 +} 5.205 + 5.206 5.207 - /* Set the instance property values from the resource data. */ 5.208 - if (!Xen_NetworkPortSettingData_setInstanceFromResource(session, resource, instance, _BROKER)) { 5.209 - _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed")); 5.210 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data"); 5.211 - goto exit; 5.212 - } 5.213 +static void end(void *res_list) 5.214 +{ 5.215 + vif_resource_list *vif_resources = (vif_resource_list *)res_list; 5.216 + 5.217 + if (vif_resources) { 5.218 + if (vif_resources->vifs) 5.219 + xen_vif_set_free(vif_resources->vifs); 5.220 + free(vif_resources); 5.221 + } 5.222 +} 5.223 + 5.224 + 5.225 +static CMPIrc getnext(void *res_list, void **res, const char **properties) 5.226 +{ 5.227 + vif_resource_list *vif_resources = (vif_resource_list *)res_list; 5.228 + vif_resource *vif; 5.229 + 5.230 + (void)properties; 5.231 + 5.232 + if (vif_resources == NULL || res == NULL) 5.233 + return CMPI_RC_ERR_FAILED; 5.234 + 5.235 + /* Are there any vifs or has end of list of vifs been reached? */ 5.236 + if (vif_resources->vifs == NULL || 5.237 + vif_resources->currentvifnum == vif_resources->vifs->size) 5.238 + return CMPI_RC_ERR_NOT_FOUND; 5.239 5.240 - /* Free the resource data. */ 5.241 - if (!Xen_NetworkPortSettingData_freeResource(resource)) { 5.242 - _SBLIM_TRACE(1,("--- _freeResource() failed")); 5.243 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data"); 5.244 - goto exit; 5.245 - } 5.246 + /* Get memory for resource. */ 5.247 + vif = (vif_resource *)calloc(1, sizeof(vif_resource)); 5.248 + if (vif == NULL) 5.249 + return CMPI_RC_ERR_FAILED; 5.250 + 5.251 + vif->is_vif_record = 1; 5.252 + 5.253 + /* Get the current vif record. */ 5.254 + session->xen->ok = true; 5.255 + if (!xen_vif_get_record(session->xen, &(vif->u.vif_rec), 5.256 + vif_resources->vifs->contents[vif_resources->currentvifnum])) { 5.257 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 5.258 + ("--- failed to retrieve vif resources from Xend:")); 5.259 + _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR, 5.260 + xen_utils_trace_error(session->xen)); 5.261 + return CMPI_RC_ERR_FAILED; 5.262 + } 5.263 + 5.264 + vif_resources->currentvifnum++; 5.265 + *res = (void *)vif; 5.266 + return CMPI_RC_OK; 5.267 +} 5.268 + 5.269 5.270 - /* Return the CMPIObjectPath for this instance. */ 5.271 - CMPIObjectPath * objectpath = CMGetObjectPath(instance, &status); 5.272 - if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) { 5.273 - _SBLIM_TRACE(1,("--- CMGetObjectPath() failed - %s", CMGetCharPtr(status.msg))); 5.274 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot get CMPIObjectPath for instance"); 5.275 - goto exit; 5.276 - } 5.277 - CMSetNameSpace(objectpath, namespace); /* Note - CMGetObjectPath() does not preserve the namespace! */ 5.278 - 5.279 - _SBLIM_TRACE(3,("--- objectpath=\"%s\"", CMGetCharPtr(CDToString(_BROKER, objectpath, NULL)))); 5.280 - CMReturnObjectPath(results, objectpath); 5.281 - found++; 5.282 +static CMPIrc delete(const void *res_id) 5.283 +{ 5.284 + CMPIInstance *inst = (CMPIInstance *)res_id; 5.285 + CMPIData data; 5.286 + CMPIStatus status = {CMPI_RC_OK, NULL}; 5.287 + char *inst_id; 5.288 + char uuid[MAX_SYSTEM_NAME_LEN]; 5.289 + 5.290 + if (CMIsNullObject(inst)) 5.291 + return CMPI_RC_ERR_FAILED; 5.292 + 5.293 + data = CMGetProperty(inst, "InstanceID", &status); 5.294 + if ((status.rc != CMPI_RC_OK) || CMIsNullValue(data)) 5.295 + return CMPI_RC_ERR_FAILED; 5.296 + 5.297 + inst_id = CMGetCharPtr(data.value.string); 5.298 + if ((inst_id == NULL) || (*inst_id == '\0')) 5.299 + return CMPI_RC_ERR_FAILED; 5.300 + 5.301 + /* Extract the disk uuid from InstanceID property. */ 5.302 + if (!_CMPIStrncpyDeviceNameFromID(uuid, inst_id, MAX_SYSTEM_NAME_LEN)) 5.303 + return CMPI_RC_ERR_FAILED; 5.304 + 5.305 + if (!xen_utils_validate_session(&session)) { 5.306 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 5.307 + ("--- Unable to establish connection with Xend")); 5.308 + return CMPI_RC_ERR_FAILED; 5.309 } 5.310 5.311 - _SBLIM_TRACE(2,("--- %d object paths found", found)); 5.312 - CMReturnDone(results); 5.313 + if (!xen_vif_destroy(session->xen, (xen_vif)uuid)) { 5.314 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 5.315 + ("--- xen_vif_destroy failed:")); 5.316 + _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR, 5.317 + xen_utils_trace_error(session->xen)); 5.318 + return CMPI_RC_ERR_FAILED; 5.319 + } 5.320 5.321 -exit: 5.322 - /* Free the list of system resources. */ 5.323 - if (!Xen_NetworkPortSettingData_freeResources(resources)) { 5.324 - _SBLIM_TRACE(1,("--- _freeResources() failed")); 5.325 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources"); 5.326 - } 5.327 - 5.328 - _SBLIM_RETURNSTATUS(status); 5.329 + return CMPI_RC_OK; 5.330 } 5.331 5.332 -// ---------------------------------------------------------------------------- 5.333 -// EnumInstances() 5.334 -// Return a list of all the instances (return all the instance data). 5.335 -// ---------------------------------------------------------------------------- 5.336 -static CMPIStatus EnumInstances( 5.337 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 5.338 - const CMPIContext * context, /* [in] Additional context info, if any. */ 5.339 - const CMPIResult * results, /* [out] Results of this operation. */ 5.340 - const CMPIObjectPath * reference, /* [in] Contains target namespace and classname. */ 5.341 - const char ** properties) /* [in] List of desired properties (NULL=all). */ 5.342 + 5.343 +static CMPIrc get(const void *res_id, void **res, const char **properties) 5.344 { 5.345 - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ 5.346 - _RESOURCES * resources = NULL; /* Handle to the list of system resources. */ 5.347 - _RESOURCE * resource; /* Handle to each system resource. */ 5.348 - char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */ 5.349 - int found = 0; /* Found any resource instances? */ 5.350 + CMPIInstance *inst = (CMPIInstance *)res_id; 5.351 + CMPIData data; 5.352 + CMPIStatus status = {CMPI_RC_OK, NULL}; 5.353 + char *inst_id; 5.354 + char uuid[MAX_SYSTEM_NAME_LEN]; 5.355 + vif_resource *vif; 5.356 + 5.357 + (void)properties; 5.358 + 5.359 + if (CMIsNullObject(inst) || res == NULL) 5.360 + return CMPI_RC_ERR_FAILED; 5.361 5.362 - _SBLIM_ENTER("EnumInstances"); 5.363 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 5.364 - _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 5.365 - _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL)))); 5.366 - _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace)); 5.367 + data = CMGetProperty(inst, "InstanceID", &status); 5.368 + if ((status.rc != CMPI_RC_OK) || CMIsNullValue(data)) 5.369 + return CMPI_RC_ERR_FAILED; 5.370 + 5.371 + inst_id = CMGetCharPtr(data.value.string); 5.372 + if ((inst_id == NULL) || (*inst_id == '\0')) 5.373 + return CMPI_RC_ERR_FAILED; 5.374 + 5.375 + /* Extract the disk uuid from InstanceID property. */ 5.376 + if (!_CMPIStrncpyDeviceNameFromID(uuid, inst_id, MAX_SYSTEM_NAME_LEN)) 5.377 + return CMPI_RC_ERR_FAILED; 5.378 5.379 if (!xen_utils_validate_session(&session)) { 5.380 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon"); 5.381 - goto exit; 5.382 - } 5.383 - 5.384 - /* Get a handle to the list of system resources. */ 5.385 - if (!Xen_NetworkPortSettingData_getResources(session, &resources)) { 5.386 - _SBLIM_TRACE(1,("--- _getResources() failed")); 5.387 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources"); 5.388 - goto exit; 5.389 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 5.390 + ("--- Unable to establish connection with Xend")); 5.391 + return CMPI_RC_ERR_FAILED; 5.392 } 5.393 5.394 - /* Enumerate thru the list of system resources and return a CMPIInstance for each. */ 5.395 - while (Xen_NetworkPortSettingData_getNextResource(session, resources, &resource)) { 5.396 - /* Create a new CMPIInstance to store this resource. */ 5.397 - CMPIInstance * instance = _CMNewInstance(_BROKER, namespace, _CLASSNAME, &status); 5.398 - if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instance)) { 5.399 - _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status.msg))); 5.400 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIInstance"); 5.401 - goto exit; 5.402 - } 5.403 + /* Get memory for resource. */ 5.404 + vif = (vif_resource *)calloc(1, sizeof(vif_resource)); 5.405 + if (vif == NULL) 5.406 + return CMPI_RC_ERR_FAILED; 5.407 5.408 - /* Setup a filter to only return the desired properties. */ 5.409 - status = CMSetPropertyFilter(instance, properties, _KEYNAMES); 5.410 - if (status.rc != CMPI_RC_OK) { 5.411 - _SBLIM_TRACE(1, ("--- CMSetPropertyFilter() failed - %s", CMGetCharPtr(status.msg))); 5.412 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Cannot set property filter"); 5.413 - goto exit; 5.414 - } 5.415 + vif->is_vif_record = 1; 5.416 5.417 - /* Set the instance property values from the resource data. */ 5.418 - if (!Xen_NetworkPortSettingData_setInstanceFromResource(session, resource, instance, _BROKER)) { 5.419 - _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed")); 5.420 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data"); 5.421 - goto exit; 5.422 - } 5.423 - 5.424 - /* Free the resource data. */ 5.425 - if (!Xen_NetworkPortSettingData_freeResource(resource)) { 5.426 - _SBLIM_TRACE(1,("--- _freeResource() failed")); 5.427 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data"); 5.428 - goto exit; 5.429 - } 5.430 - 5.431 - /* Return the CMPIInstance for this instance. */ 5.432 - _SBLIM_TRACE(3,("--- instance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, instance, NULL)))); 5.433 - CMReturnInstance(results, instance); 5.434 - found++; 5.435 + if (!xen_vif_get_record(session->xen, &(vif->u.vif_rec), 5.436 + (xen_vif)uuid)) { 5.437 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 5.438 + ("--- xen_vif_get_record failed:")); 5.439 + _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR, 5.440 + xen_utils_trace_error(session->xen)); 5.441 + return CMPI_RC_ERR_FAILED; 5.442 } 5.443 5.444 - _SBLIM_TRACE(2,("--- %d instances found", found)); 5.445 - CMReturnDone(results); 5.446 + *res = (void *)vif; 5.447 + return CMPI_RC_OK; 5.448 +} 5.449 + 5.450 5.451 -exit: 5.452 - /* Free the list of system resources. */ 5.453 - if (!Xen_NetworkPortSettingData_freeResources(resources)) { 5.454 - _SBLIM_TRACE(1,("--- _freeResources() failed")); 5.455 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources"); 5.456 +static void release(void *res) 5.457 +{ 5.458 + if (res) { 5.459 + vif_resource *vif = (vif_resource *)res; 5.460 + if (vif->is_vif_record) 5.461 + xen_vif_record_free(vif->u.vif_rec); 5.462 + free(vif); 5.463 } 5.464 +} 5.465 5.466 - _SBLIM_RETURNSTATUS(status); 5.467 + 5.468 +static CMPIrc add(const void *res_id, const void *res) 5.469 +{ 5.470 + (void)res_id; 5.471 + (void)res; 5.472 + 5.473 + return CMPI_RC_ERR_NOT_SUPPORTED; /* unsupported */ 5.474 } 5.475 5.476 -// ---------------------------------------------------------------------------- 5.477 -// GetInstance() 5.478 -// Return the instance data for the specified instance only. 5.479 -// ---------------------------------------------------------------------------- 5.480 -static CMPIStatus GetInstance( 5.481 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 5.482 - const CMPIContext * context, /* [in] Additional context info, if any. */ 5.483 - const CMPIResult * results, /* [out] Results of this operation. */ 5.484 - const CMPIObjectPath * reference, /* [in] Contains the target namespace, classname and object path. */ 5.485 - const char ** properties) /* [in] List of desired properties (NULL=all). */ 5.486 + 5.487 +//Modifying the network port setting data is not supported 5.488 +static CMPIrc modify(const void *res_id, const void *modified_res, 5.489 + const char **properties) 5.490 { 5.491 - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ 5.492 - _RESOURCES * resources = NULL; /* Handle to the list of system resources. */ 5.493 - _RESOURCE * resource; /* Handle to the system resource. */ 5.494 - char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */ 5.495 - int found = 0; /* Found the target instance? */ 5.496 + return CMPI_RC_ERR_NOT_SUPPORTED; 5.497 +} 5.498 5.499 - _SBLIM_ENTER("GetInstance"); 5.500 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 5.501 - _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 5.502 - _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL)))); 5.503 - _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace)); 5.504 5.505 - if (!xen_utils_validate_session(&session)) { 5.506 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon"); 5.507 - goto exit; 5.508 - } 5.509 +static CMPIrc setproperties(CMPIInstance *inst, const void *res, 5.510 + const char **properties) 5.511 +{ 5.512 + vif_resource *vif= (vif_resource *)res; 5.513 + char buf[MAX_INSTANCEID_LEN]; 5.514 + xen_vif_record *vif_rec; 5.515 + 5.516 + if (CMIsNullObject(inst) || vif == NULL || 5.517 + !vif->is_vif_record) 5.518 + return CMPI_RC_ERR_FAILED; 5.519 5.520 - /* Get a handle to the list of system resources. */ 5.521 - if (!Xen_NetworkPortSettingData_getResources(session, &resources)) { 5.522 - _SBLIM_TRACE(1,("--- _getResources() failed")); 5.523 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources"); 5.524 - goto exit; 5.525 - } 5.526 + vif_rec = vif->u.vif_rec; 5.527 + session->xen->ok = true; 5.528 5.529 - /* Get the target resource. */ 5.530 - found = Xen_NetworkPortSettingData_getResourceForObjectPath(session, &resource, reference); 5.531 - if (!found || (resource == NULL)) { 5.532 - _SBLIM_TRACE(1,("--- Target instance not found")); 5.533 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_FOUND, "Target instance not found"); 5.534 - goto exit; 5.535 + xen_vm_record_opt *vm_rec_opt = vif_rec->vm; 5.536 + if (vm_rec_opt->is_record) { 5.537 + snprintf(buf, MAX_INSTANCEID_LEN, "Xen:%s:%s", 5.538 + vm_rec_opt->u.record->name_label, vif_rec->uuid); 5.539 } 5.540 - 5.541 - /* Create a new CMPIInstance to store this resource. */ 5.542 - CMPIInstance * instance = _CMNewInstance(_BROKER, namespace, _CLASSNAME, &status); 5.543 - if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instance)) { 5.544 - _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status.msg))); 5.545 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIInstance"); 5.546 - goto exit; 5.547 + else { 5.548 + char *name = NULL; 5.549 + 5.550 + if (!xen_vm_get_name_label(session->xen, &name, vm_rec_opt->u.handle)) 5.551 + return CMPI_RC_ERR_FAILED; 5.552 + snprintf(buf, MAX_INSTANCEID_LEN, "Xen:%s:%s", 5.553 + name, vif_rec->uuid); 5.554 + free(name); 5.555 } 5.556 5.557 /* Setup a filter to only return the desired properties. */ 5.558 - status = CMSetPropertyFilter(instance, properties, _KEYNAMES); 5.559 - if (status.rc != CMPI_RC_OK) { 5.560 - _SBLIM_TRACE(1, ("--- CMSetPropertyFilter() failed - %s", CMGetCharPtr(status.msg))); 5.561 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Cannot set property filter"); 5.562 - goto exit; 5.563 - } 5.564 - 5.565 - /* Set the instance property values from the resource data. */ 5.566 - if (!Xen_NetworkPortSettingData_setInstanceFromResource(session, resource, instance, _BROKER)) { 5.567 - _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed")); 5.568 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data"); 5.569 - goto exit; 5.570 - } 5.571 + CMSetPropertyFilter(inst, properties, keys); 5.572 5.573 - /* Free the resource data. */ 5.574 - if (!Xen_NetworkPortSettingData_freeResource(resource)) { 5.575 - _SBLIM_TRACE(1,("--- _freeResource() failed")); 5.576 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data"); 5.577 - goto exit; 5.578 - } 5.579 + CMSetProperty(inst, "InstanceID",(CMPIValue *)buf, CMPI_chars); 5.580 + CMSetProperty(inst, "ElementName",(CMPIValue *)vif_rec->device, CMPI_chars); 5.581 5.582 - /* Return the CMPIInstance for this instance. */ 5.583 - _SBLIM_TRACE(3,("--- instance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, instance, NULL)))); 5.584 - CMReturnInstance(results, instance); 5.585 - 5.586 - _SBLIM_TRACE(2,("--- instance found")); 5.587 - CMReturnDone(results); 5.588 + int type = 10; /* 10 == Ethernet Adapter */ 5.589 + CMSetProperty(inst, "ResourceType",(CMPIValue *)&type, CMPI_uint16); 5.590 5.591 -exit: 5.592 - /* Free the list of system resources. */ 5.593 - if (!Xen_NetworkPortSettingData_freeResources(resources)) { 5.594 - _SBLIM_TRACE(1,("--- _freeResources() failed")); 5.595 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources"); 5.596 - } 5.597 - 5.598 - _SBLIM_RETURNSTATUS(status); 5.599 -} 5.600 + int consumerVisibility = 3; /* 3 == Virtualized */ 5.601 + CMSetProperty(inst, "ConsumerVisibility" , (CMPIValue *)&consumerVisibility, CMPI_uint16); 5.602 5.603 -// ---------------------------------------------------------------------------- 5.604 -// SetInstance() 5.605 -// Save modified instance data for the specified instance. 5.606 -// ---------------------------------------------------------------------------- 5.607 -static CMPIStatus SetInstance( 5.608 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 5.609 - const CMPIContext * context, /* [in] Additional context info, if any. */ 5.610 - const CMPIResult * results, /* [out] Results of this operation. */ 5.611 - const CMPIObjectPath * reference, /* [in] Contains the target namespace, classname and object path. */ 5.612 - const CMPIInstance * newinstance, /* [in] Contains the new instance data. */ 5.613 - const char **properties) 5.614 -{ 5.615 - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ 5.616 - _RESOURCES * resources = NULL; /* Handle to the list of system resources. */ 5.617 - _RESOURCE * resource; /* Handle to the system resource. */ 5.618 - char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */ 5.619 - int found = 0; /* Found the target instance? */ 5.620 + unsigned long long nics = 1; 5.621 + CMSetProperty(inst, "Reservation",(CMPIValue *)&nics, CMPI_uint64); 5.622 + CMSetProperty(inst, "Limit",(CMPIValue *)&nics, CMPI_uint64); 5.623 + CMSetProperty(inst, "AllocationUnits",(CMPIValue *)"Interfaces", CMPI_chars); 5.624 + CMSetProperty(inst, "VirtualQuantity",(CMPIValue *)&nics, CMPI_uint64); 5.625 5.626 - _SBLIM_ENTER("SetInstance"); 5.627 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 5.628 - _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 5.629 - _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL)))); 5.630 - _SBLIM_TRACE(2, ("--- newinstance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, newinstance, NULL)))); 5.631 - _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace)); 5.632 - 5.633 - if (!xen_utils_validate_session(&session)) { 5.634 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon"); 5.635 - goto exit; 5.636 - } 5.637 - 5.638 - /* Get a handle to the list of system resources. */ 5.639 - if (!Xen_NetworkPortSettingData_getResources(session, &resources)) { 5.640 - _SBLIM_TRACE(1,("--- _getResources() failed")); 5.641 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources"); 5.642 - goto exit; 5.643 - } 5.644 - 5.645 - /* Get the target resource. */ 5.646 - found = Xen_NetworkPortSettingData_getResourceForObjectPath(session, &resource, reference); 5.647 - if (!found || (resource == NULL)) { 5.648 - _SBLIM_TRACE(1,("--- Target instance not found")); 5.649 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_FOUND, "Target instance not found"); 5.650 - goto exit; 5.651 - } 5.652 - 5.653 - _SBLIM_TRACE(2,("--- instance found", found)); 5.654 + int alloctype = 1; 5.655 + CMSetProperty(inst, "AutomaticAllocation" , (CMPIValue *)&alloctype, CMPI_boolean); 5.656 + CMSetProperty(inst, "AutomaticDeallocation" , (CMPIValue *)&alloctype, CMPI_boolean); 5.657 5.658 - /* Update the target resource data with the new instance property values. */ 5.659 - int rc = Xen_NetworkPortSettingData_setResourceFromInstance(resource, newinstance, _BROKER); 5.660 - 5.661 - /* Free the resource data. */ 5.662 - if (!Xen_NetworkPortSettingData_freeResource(resource)) { 5.663 - _SBLIM_TRACE(1,("--- _freeResource() failed")); 5.664 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data"); 5.665 - goto exit; 5.666 - } 5.667 + char nic_config_info[512]; 5.668 + nic_config_info[0] = '\0'; 5.669 + if (vif_rec->mac) 5.670 + snprintf(nic_config_info, 512, "mac=%s", vif_rec->mac); 5.671 +/* if (resource->model) { 5.672 + strncat(nic_config_info, ",model=", 512 - strlen(nic_config_info)); 5.673 + strncat(nic_config_info, resource->model, 512 - strlen(nic_config_info)); 5.674 + }Nic config info does have model*/ 5.675 + if (nic_config_info[0] != '\0') 5.676 + CMSetProperty(inst, "NICConfigInfo" , (CMPIValue *)nic_config_info, CMPI_chars); 5.677 + 5.678 + /* 5.679 + * TODO: 5.680 + * PoolID, Weight 5.681 + */ 5.682 5.683 - if (rc != 1) { 5.684 - if (rc == -1) { 5.685 - _SBLIM_TRACE(1,("--- _setResourceFromInstance() unsupported")); 5.686 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL); 5.687 - } else { 5.688 - _SBLIM_TRACE(1,("--- _setResourceFromInstance() failed")); 5.689 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set resource data from instance properties"); 5.690 - } 5.691 - goto exit; 5.692 - } 5.693 - 5.694 -exit: 5.695 - /* Free the list of system resources. */ 5.696 - if (!Xen_NetworkPortSettingData_freeResources(resources)) { 5.697 - _SBLIM_TRACE(1,("--- _freeResources() failed")); 5.698 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources"); 5.699 - } 5.700 - 5.701 - _SBLIM_RETURNSTATUS(status); 5.702 + return CMPI_RC_OK; 5.703 } 5.704 5.705 -// ---------------------------------------------------------------------------- 5.706 -// CreateInstance() 5.707 -// Create a new instance from the specified instance data. 5.708 -// ---------------------------------------------------------------------------- 5.709 -static CMPIStatus CreateInstance( 5.710 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 5.711 - const CMPIContext * context, /* [in] Additional context info, if any. */ 5.712 - const CMPIResult * results, /* [out] Results of this operation. */ 5.713 - const CMPIObjectPath * reference, /* [in] Contains the target namespace, classname and object path. */ 5.714 - const CMPIInstance * newinstance) /* [in] Contains the new instance data. */ 5.715 +/* 5.716 + * Set resource data from the CMPIInstance properties. Only needs to 5.717 + * be implemented if add() and/or modify() are supported. 5.718 + */ 5.719 +static CMPIrc extract(void **res, const CMPIInstance *inst, 5.720 + const char **properties) 5.721 { 5.722 - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ 5.723 - _RESOURCES * resources = NULL; /* Handle to the list of system resources. */ 5.724 - _RESOURCE * resource; /* Handle to the system resource. */ 5.725 - char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */ 5.726 - int found = 0; /* Found the target instance? */ 5.727 - 5.728 - _SBLIM_ENTER("CreateInstance"); 5.729 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 5.730 - _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 5.731 - _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL)))); 5.732 - _SBLIM_TRACE(2, ("--- newinstance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, newinstance, NULL)))); 5.733 - _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace)); 5.734 - 5.735 - if (!xen_utils_validate_session(&session)) { 5.736 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon"); 5.737 - goto exit; 5.738 - } 5.739 - 5.740 - /* WORKAROUND FOR PEGASUS BUG?! reference does not contain object path, only namespace & classname. */ 5.741 - reference = CMGetObjectPath(newinstance, NULL); 5.742 - 5.743 - /* Get a handle to the list of system resources. */ 5.744 - if (!Xen_NetworkPortSettingData_getResources(session, &resources)) { 5.745 - _SBLIM_TRACE(1,("--- _getResources() failed")); 5.746 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources"); 5.747 - goto exit; 5.748 - } 5.749 - 5.750 - /* Get the target resource. */ 5.751 - found = Xen_NetworkPortSettingData_getResourceForObjectPath(session, &resource, reference); 5.752 - 5.753 - /* Free the resource data. */ 5.754 - if (!Xen_NetworkPortSettingData_freeResource(resource)) { 5.755 - _SBLIM_TRACE(1,("--- _freeResource() failed")); 5.756 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data"); 5.757 - goto exit; 5.758 - } 5.759 - 5.760 - if (found) { 5.761 - _SBLIM_TRACE(1,("--- Target instance already exists")); 5.762 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_ALREADY_EXISTS, "Target instance already exists"); 5.763 - goto exit; 5.764 - } 5.765 - 5.766 - /* Create a new resource with the new instance property values. */ 5.767 - int rc = Xen_NetworkPortSettingData_createResourceFromInstance(resources, &resource, newinstance, _BROKER); 5.768 - if (rc != 1) { 5.769 - if (rc == -1) { 5.770 - _SBLIM_TRACE(1,("--- _createResourceFromInstance() unsupported")); 5.771 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL); 5.772 - } else { 5.773 - _SBLIM_TRACE(1,("--- _createResourceFromInstance() failed")); 5.774 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to create resource data from instance properties"); 5.775 - } 5.776 - goto exit; 5.777 - } 5.778 + vif_resource *vif; 5.779 + 5.780 + (void)properties; 5.781 + 5.782 + /* Get memory for resource. */ 5.783 + vif = (vif_resource *)calloc(1, sizeof(vif_resource)); 5.784 + if (vif == NULL) 5.785 + return CMPI_RC_ERR_FAILED; 5.786 5.787 - /* Return the object path for the newly created instance. */ 5.788 - CMPIObjectPath * objectpath = CMGetObjectPath(newinstance, NULL); 5.789 - CMSetNameSpace(objectpath, namespace); 5.790 - CMReturnObjectPath(results, objectpath); 5.791 - CMReturnDone(results); 5.792 - 5.793 -exit: 5.794 - /* Free the list of system resources. */ 5.795 - if (!Xen_NetworkPortSettingData_freeResources(resources)) { 5.796 - _SBLIM_TRACE(1,("--- _freeResources() failed")); 5.797 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources"); 5.798 - } 5.799 - 5.800 - _SBLIM_RETURNSTATUS(status); 5.801 -} 5.802 - 5.803 -// ---------------------------------------------------------------------------- 5.804 -// DeleteInstance() 5.805 -// Delete or remove the specified instance from the system. 5.806 -// ---------------------------------------------------------------------------- 5.807 -static CMPIStatus DeleteInstance( 5.808 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 5.809 - const CMPIContext * context, /* [in] Additional context info, if any. */ 5.810 - const CMPIResult * results, /* [out] Results of this operation. */ 5.811 - const CMPIObjectPath * reference) /* [in] Contains the target namespace, classname and object path. */ 5.812 -{ 5.813 - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ 5.814 - _RESOURCE * resource = NULL; /* Handle to the system resource. */ 5.815 - char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */ 5.816 - int found = 0; /* Found the target instance? */ 5.817 - char error_msg[XEN_UTILS_ERROR_BUF_LEN]; 5.818 - 5.819 - _SBLIM_ENTER("DeleteInstance"); 5.820 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 5.821 - _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 5.822 - _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL)))); 5.823 - _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace)); 5.824 - 5.825 - if (!xen_utils_validate_session(&session)) { 5.826 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon"); 5.827 - goto exit; 5.828 - } 5.829 - 5.830 - /* Get the target resource. */ 5.831 - found = Xen_NetworkPortSettingData_getResourceForObjectPath(session, &resource, reference); 5.832 - if (!found || (resource == NULL)) { 5.833 - _SBLIM_TRACE(1,("--- Target instance not found")); 5.834 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_FOUND, "Target instance not found"); 5.835 - goto exit; 5.836 - } 5.837 - 5.838 - _SBLIM_TRACE(2,("--- instance found", found)); 5.839 - 5.840 - /* Delete the target resource. */ 5.841 - if (!Xen_NetworkPortSettingData_deleteResource(session, resource)) { 5.842 - XEN_UTILS_GET_ERROR_STRING(error_msg, session->xen); 5.843 - _SBLIM_TRACE(1,("--- deleteResource failed: %s", error_msg)); 5.844 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, error_msg); 5.845 - goto exit; 5.846 - } 5.847 - 5.848 -exit: 5.849 - /* Free the resource. */ 5.850 - if (resource) 5.851 - Xen_NetworkPortSettingData_freeResource(resource); 5.852 - 5.853 - _SBLIM_RETURNSTATUS(status); 5.854 + vif->u.cmpi_inst = (CMPIInstance *)inst; 5.855 + *res = (void *)vif; 5.856 + return CMPI_RC_OK; 5.857 } 5.858 5.859 5.860 -// ---------------------------------------------------------------------------- 5.861 -// ExecQuery() 5.862 -// Return a list of all the instances that satisfy the specified query filter. 5.863 -// ---------------------------------------------------------------------------- 5.864 -static CMPIStatus ExecQuery( 5.865 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 5.866 - const CMPIContext * context, /* [in] Additional context info, if any. */ 5.867 - const CMPIResult * results, /* [out] Results of this operation. */ 5.868 - const CMPIObjectPath * reference, /* [in] Contains the target namespace and classname. */ 5.869 - const char * language, /* [in] Name of the query language. */ 5.870 - const char * query) /* [in] Text of the query written in the query language. */ 5.871 +/* Get resource id from CMPIInstance properties. */ 5.872 +static CMPIrc extractid(void **res_id, const CMPIInstance* inst) 5.873 { 5.874 - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ 5.875 - char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */ 5.876 - 5.877 - _SBLIM_ENTER("ExecQuery"); 5.878 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 5.879 - _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 5.880 - _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL)))); 5.881 - _SBLIM_TRACE(2, ("--- language=\"%s\"", language)); 5.882 - _SBLIM_TRACE(2, ("--- query=\"%s\"", query)); 5.883 - _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace)); 5.884 - 5.885 - /* EXECQUERY() IS NOT YET SUPPORTED FOR THIS CLASS */ 5.886 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL); 5.887 - 5.888 - CMReturnDone(results); 5.889 - 5.890 -exit: 5.891 - _SBLIM_RETURNSTATUS(status); 5.892 + *res_id = (void *)inst; 5.893 + return CMPI_RC_OK; 5.894 } 5.895 5.896 -// ---------------------------------------------------------------------------- 5.897 -// Initialize() 5.898 -// Perform any necessary initialization immediately after this provider is 5.899 -// first loaded. 5.900 -// ---------------------------------------------------------------------------- 5.901 -static void Initialize( 5.902 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 5.903 - const CMPIContext * context) /* [in] Additional context info, if any. */ 5.904 + 5.905 +/* Release resource id created in resId4inst(). */ 5.906 +static void releaseid(void* res_id) 5.907 { 5.908 - _SBLIM_ENTER("Initialize"); 5.909 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 5.910 - // _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 5.911 - 5.912 - /* Initialized Xen session object. */ 5.913 - if (session == NULL) 5.914 - xen_utils_xen_init(&session); 5.915 - 5.916 - _SBLIM_RETURN(); 5.917 + (void)res_id; 5.918 } 5.919 5.920 -// ============================================================================ 5.921 -// CMPI INSTANCE PROVIDER FUNCTION TABLE SETUP 5.922 -// ============================================================================ 5.923 -CMInstanceMIStub( , Xen_NetworkPortSettingData, _BROKER, Initialize(&mi, ctx)); 5.924 + 5.925 +/* Setup CMPILIFY function tables and instance provider entry point.*/ 5.926 +/* CMPILIFYInstanceMIStub(<CLASS>,<PROVIDER_NAME>,<keys>,<CMPIInstanceMI_HANDLE>) */ 5.927 +CMPILIFYInstanceMIStub(Xen_NetworkPortSettingData, Xen_NetworkPortSettingData, keys, mi) 5.928 +
6.1 --- a/src/Xen_NetworkPortSettingData_Resource.c Thu Aug 02 17:54:59 2007 -0600 6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 6.3 @@ -1,300 +0,0 @@ 6.4 -// Copyright (C) 2006 IBM Corporation 6.5 -// 6.6 -// This library is free software; you can redistribute it and/or 6.7 -// modify it under the terms of the GNU Lesser General Public 6.8 -// License as published by the Free Software Foundation; either 6.9 -// version 2.1 of the License, or (at your option) any later version. 6.10 -// 6.11 -// This library is distributed in the hope that it will be useful, 6.12 -// but WITHOUT ANY WARRANTY; without even the implied warranty of 6.13 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 6.14 -// Lesser General Public License for more details. 6.15 -// 6.16 -// You should have received a copy of the GNU Lesser General Public 6.17 -// License along with this library; if not, write to the Free Software 6.18 -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 6.19 -// ============================================================================ 6.20 -// Authors: Dr. Gareth S. Bestor, <bestor@us.ibm.com> 6.21 -// Tokunbo Adeshiyan, <tokunbo@us.ibm.com> 6.22 -// Contributors: Jim Fehlig, <jfehlig@novell.com> 6.23 -// Description: 6.24 -// ============================================================================ 6.25 - 6.26 -#include <stdlib.h> 6.27 -#include <string.h> 6.28 -#include <assert.h> 6.29 - 6.30 -#include <xen_common.h> 6.31 -#include <xen_vm.h> 6.32 -#include <xen_vif.h> 6.33 - 6.34 -#include "Xen_NetworkPortSettingData_Resource.h" 6.35 - 6.36 -/* Include the required CMPI data types, function headers, and macros. */ 6.37 -#include "cmpidt.h" 6.38 -#include "cmpift.h" 6.39 -#include "cmpimacs.h" 6.40 - 6.41 -#include "xen_utils.h" 6.42 -#include "provider_common.h" 6.43 - 6.44 - 6.45 -// ---------------------------------------------------------------------------- 6.46 - 6.47 -static int concat_vif_lists(xen_vif_set **target, xen_vif_set *source) 6.48 -{ 6.49 - 6.50 - int total_size; 6.51 - int i, j; 6.52 - 6.53 - /* Nothing to concatenate if source is empty */ 6.54 - if (source == NULL || source->size == 0) 6.55 - return 1; 6.56 - 6.57 - /* If targe is empty, assign source to target */ 6.58 - if (*target == NULL) { 6.59 - *target = source; 6.60 - return 1; 6.61 - } 6.62 - 6.63 - /* realloc memory and append source to target */ 6.64 - total_size = (*target)->size + source->size; 6.65 - *target = realloc(*target, sizeof(xen_vif_set) + (total_size * sizeof(xen_vif))); 6.66 - if (*target == NULL) 6.67 - return 0; 6.68 - 6.69 - for (j = (*target)->size, i = 0; i < source->size; i++) { 6.70 - (*target)->contents[j + i] = source->contents[i]; 6.71 - source->contents[i] = NULL; 6.72 - } 6.73 - (*target)->size = total_size; 6.74 - 6.75 - /* Free source list - it has been copied to target */ 6.76 - xen_vif_set_free(source); 6.77 - return 1; 6.78 -} 6.79 - 6.80 - 6.81 -/* Get a handle to the list of all system resources for this class. */ 6.82 -int Xen_NetworkPortSettingData_getResources(xen_utils_session *session, 6.83 - _RESOURCES ** resources) 6.84 -{ 6.85 - xen_domain_resources *res; 6.86 - xen_vif_set *all_vifs = NULL; 6.87 - xen_vm_record *vm_rec = NULL; 6.88 - 6.89 - /* malloc a new handle for the resources list. */ 6.90 - *resources = (_RESOURCES *)calloc(1, sizeof(_RESOURCES)); 6.91 - if (*resources == NULL) 6.92 - return 0; 6.93 - 6.94 - /* Get a list of domain resources. */ 6.95 - if (!xen_utils_get_domain_resources(session, &res)) { 6.96 - *resources = NULL; 6.97 - return 0; 6.98 - } 6.99 - 6.100 - /* Create list of vif resources from vifs found in each domain. */ 6.101 - while (xen_utils_get_next_domain_resource(session, res, &vm_rec)) { 6.102 - xen_vif_set *vif_set; 6.103 - if (!xen_vm_get_vifs(session->xen, &vif_set, vm_rec->handle)) 6.104 - goto Error; 6.105 - 6.106 - if (!concat_vif_lists(&all_vifs, vif_set)) 6.107 - goto Error; 6.108 - 6.109 - xen_vm_record_free(vm_rec); 6.110 - } 6.111 - 6.112 - (*resources)->vifs = all_vifs; 6.113 - (*resources)->currentvifnum = 0; 6.114 - 6.115 - return 1; 6.116 - 6.117 - Error: 6.118 - xen_vm_record_free(vm_rec); 6.119 - xen_utils_free_domain_resources(res); 6.120 - free(*resources); 6.121 - *resources = NULL; 6.122 - return 0; 6.123 -} 6.124 - 6.125 -// ---------------------------------------------------------------------------- 6.126 - 6.127 -/* Free/deallocate/cleanup the resources list after use. */ 6.128 -int Xen_NetworkPortSettingData_freeResources(_RESOURCES * resources) 6.129 -{ 6.130 - if (resources != NULL) { 6.131 - if (resources->vifs != NULL) 6.132 - xen_vif_set_free(resources->vifs); 6.133 - free(resources); 6.134 - resources = NULL; 6.135 - } 6.136 - 6.137 - return 1; 6.138 -} 6.139 - 6.140 -// ---------------------------------------------------------------------------- 6.141 - 6.142 -/* Iterator to get the next resource from the resources list. */ 6.143 -int Xen_NetworkPortSettingData_getNextResource(xen_utils_session *session, 6.144 - _RESOURCES * resources, 6.145 - _RESOURCE ** resource) 6.146 -{ 6.147 - if (resources == NULL || resources->vifs == NULL) 6.148 - return 0; 6.149 - 6.150 - /* Check if reached the end of the list of vifs. */ 6.151 - if (resources->currentvifnum == resources->vifs->size) 6.152 - return 0; 6.153 - 6.154 - /* Get the current vif record. */ 6.155 - if (!xen_vif_get_record(session->xen, resource, resources->vifs->contents[resources->currentvifnum])) 6.156 - return 0; 6.157 - 6.158 - resources->currentvifnum++; 6.159 - return 1; 6.160 -} 6.161 - 6.162 -// ---------------------------------------------------------------------------- 6.163 - 6.164 -/* Get the specific resource that matches the CMPI object path. */ 6.165 -int Xen_NetworkPortSettingData_getResourceForObjectPath(xen_utils_session *session, 6.166 - _RESOURCE ** resource, 6.167 - const CMPIObjectPath * objectpath) 6.168 -{ 6.169 - char *instId; 6.170 - char uuid[MAX_SYSTEM_NAME_LEN]; 6.171 - int ccode; 6.172 - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ 6.173 - 6.174 - if (CMIsNullObject(objectpath)) return 0; 6.175 - 6.176 - /* Obtain the target resource identifier from the CMPIObjectPath key(s). */ 6.177 - CMPIData iddata = CMGetKey(objectpath, "InstanceID", &status); 6.178 - if ((status.rc != CMPI_RC_OK) || CMIsNullValue(iddata)) return 0; 6.179 - 6.180 - instId = CMGetCharPtr(iddata.value.string); 6.181 - if ((instId == NULL) || (*instId == '\0')) return 0; 6.182 - 6.183 - /* Extract the disk uuid from InstanceID property. */ 6.184 - if (!_CMPIStrncpyDeviceNameFromID(uuid, instId, MAX_SYSTEM_NAME_LEN)) 6.185 - return 0; 6.186 - 6.187 - xen_vif vif; 6.188 - if (!xen_vif_get_by_uuid(session->xen, &vif, uuid)) 6.189 - return 0; 6.190 - 6.191 - ccode = xen_vif_get_record(session->xen, resource, vif); 6.192 - xen_vif_free(vif); 6.193 - return ccode; 6.194 -} 6.195 - 6.196 -// ---------------------------------------------------------------------------- 6.197 - 6.198 -/* Free/deallocate/cleanup the resource after use. */ 6.199 -int Xen_NetworkPortSettingData_freeResource(_RESOURCE * resource) 6.200 -{ 6.201 - xen_vif_record_free(resource); 6.202 - return 1; 6.203 -} 6.204 - 6.205 -// ---------------------------------------------------------------------------- 6.206 - 6.207 -/* Set the property values of a CMPI instance from a specific resource. */ 6.208 -int Xen_NetworkPortSettingData_setInstanceFromResource(xen_utils_session *session, 6.209 - _RESOURCE * resource, 6.210 - const CMPIInstance * instance, 6.211 - const CMPIBroker * broker) 6.212 -{ 6.213 - char buf[MAX_INSTANCEID_LEN]; 6.214 - xen_vm_record *alloced_vm_rec = NULL; 6.215 - xen_vm_record *vm_rec; 6.216 - 6.217 - if (resource == NULL) return 0; 6.218 - if (CMIsNullObject(instance)) return 0; 6.219 - 6.220 - xen_vm_record_opt *vm_rec_opt = resource->vm; 6.221 - if (vm_rec_opt->is_record) { 6.222 - vm_rec = vm_rec_opt->u.record; 6.223 - } 6.224 - else { 6.225 - if (!xen_vm_get_record(session->xen, &vm_rec, vm_rec_opt->u.handle)) { 6.226 - /* Error description in session object! */ 6.227 - return 0; 6.228 - } 6.229 - alloced_vm_rec = vm_rec; 6.230 - } 6.231 - 6.232 - /* Set the CMPIInstance properties from the resource data. */ 6.233 - snprintf(buf, MAX_INSTANCEID_LEN, "Xen:%s:%s", vm_rec->name_label, resource->uuid); 6.234 - CMSetProperty(instance, "InstanceID",(CMPIValue *)buf, CMPI_chars); 6.235 - CMSetProperty(instance, "ElementName",(CMPIValue *)resource->device, CMPI_chars); 6.236 - 6.237 - int type = 10; /* 10 == Ethernet Adapter */ 6.238 - CMSetProperty(instance, "ResourceType",(CMPIValue *)&type, CMPI_uint16); 6.239 - 6.240 - int consumerVisibility = 3; /* 3 == Virtualized */ 6.241 - CMSetProperty(instance, "ConsumerVisibility" , (CMPIValue *)&consumerVisibility, CMPI_uint16); 6.242 - 6.243 - unsigned long long nics = 1; 6.244 - CMSetProperty(instance, "Reservation",(CMPIValue *)&nics, CMPI_uint64); 6.245 - CMSetProperty(instance, "Limit",(CMPIValue *)&nics, CMPI_uint64); 6.246 - CMSetProperty(instance, "AllocationUnits",(CMPIValue *)"Interfaces", CMPI_chars); 6.247 - CMSetProperty(instance, "VirtualQuantity",(CMPIValue *)&nics, CMPI_uint64); 6.248 - 6.249 - int alloctype = 1; 6.250 - CMSetProperty(instance, "AutomaticAllocation" , (CMPIValue *)&alloctype, CMPI_boolean); 6.251 - CMSetProperty(instance, "AutomaticDeallocation" , (CMPIValue *)&alloctype, CMPI_boolean); 6.252 - 6.253 - char nic_config_info[512]; 6.254 - nic_config_info[0] = '\0'; 6.255 - if (resource->mac) 6.256 - snprintf(nic_config_info, 512, "mac=%s", resource->mac); 6.257 -/* if (resource->model) { 6.258 - strncat(nic_config_info, ",model=", 512 - strlen(nic_config_info)); 6.259 - strncat(nic_config_info, resource->model, 512 - strlen(nic_config_info)); 6.260 - }Nic config info does have model*/ 6.261 - if (nic_config_info[0] != '\0') 6.262 - CMSetProperty(instance, "NICConfigInfo" , (CMPIValue *)nic_config_info, CMPI_chars); 6.263 - 6.264 - /* 6.265 - * TODO: 6.266 - * PoolID, Weight 6.267 - */ 6.268 - 6.269 - return 1; 6.270 -} 6.271 - 6.272 -// ---------------------------------------------------------------------------- 6.273 - 6.274 -/* Delete the specified resource from the system. */ 6.275 -int Xen_NetworkPortSettingData_deleteResource(xen_utils_session *session, 6.276 - _RESOURCE * resource) 6.277 -{ 6.278 - return xen_vif_destroy(session->xen, resource->handle); 6.279 -} 6.280 - 6.281 -// ---------------------------------------------------------------------------- 6.282 - 6.283 -/* Modify the specified resource using the property values of a CMPI instance. */ 6.284 -int Xen_NetworkPortSettingData_setResourceFromInstance(_RESOURCE * resource, 6.285 - const CMPIInstance * instance, 6.286 - const CMPIBroker * broker) 6.287 -{ 6.288 - /* Unsupported. */ 6.289 - return -1; 6.290 -} 6.291 - 6.292 -// ---------------------------------------------------------------------------- 6.293 - 6.294 -/* Create a new resource using the property values of a CMPI instance. */ 6.295 -int Xen_NetworkPortSettingData_createResourceFromInstance(_RESOURCES * resources, 6.296 - _RESOURCE ** resource, 6.297 - const CMPIInstance * instance, 6.298 - const CMPIBroker * broker) 6.299 -{ 6.300 - /* Unsupported. */ 6.301 - return -1; 6.302 -} 6.303 -
7.1 --- a/src/Xen_NetworkPortSettingData_Resource.h Thu Aug 02 17:54:59 2007 -0600 7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 7.3 @@ -1,105 +0,0 @@ 7.4 -// Copyright (C) 2006 IBM Corporation 7.5 -// 7.6 -// This library is free software; you can redistribute it and/or 7.7 -// modify it under the terms of the GNU Lesser General Public 7.8 -// License as published by the Free Software Foundation; either 7.9 -// version 2.1 of the License, or (at your option) any later version. 7.10 -// 7.11 -// This library is distributed in the hope that it will be useful, 7.12 -// but WITHOUT ANY WARRANTY; without even the implied warranty of 7.13 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 7.14 -// Lesser General Public License for more details. 7.15 -// 7.16 -// You should have received a copy of the GNU Lesser General Public 7.17 -// License along with this library; if not, write to the Free Software 7.18 -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 7.19 -// ============================================================================ 7.20 -// Authors: Dr. Gareth S. Bestor, <bestor@us.ibm.com> 7.21 -// Tokunbo Adeshiyan, <tokunbo@us.ibm.com> 7.22 -// Contributors: Jim Fehlig, <jfehlig@novell.com> 7.23 -// Description: 7.24 -// ============================================================================ 7.25 - 7.26 -/* Include required libxen headers. */ 7.27 -#include <xen_common.h> 7.28 -#include <xen_vif.h> 7.29 - 7.30 -#include "xen_utils.h" 7.31 - 7.32 -/* Include the required CMPI data types. */ 7.33 -#include "cmpidt.h" 7.34 - 7.35 - 7.36 -/*** CUSTOMIZE FOR EACH PROVIDER ***/ 7.37 -/* DEFINE A HANDLE TO REPRESENT THE 'LIST' OF ALL SYSTEM RESOURCES. 7.38 - THE MAIN PROVIDER CODE DOES NOT NEED TO KNOW THE PARTICULARS OF HOW THIS 7.39 - LIST IS IMPLEMENTED - IT MAY BE AN ARRAY, LINKED LIST, FILE, ETC. 7.40 - THIS HANDLE IS PASSED INTO THE APPROPRIATE RESOURCE ACCESS METHODS WHEN 7.41 - ACCESSING/ITERATING/ADDING/REMOVING RESOURCES INSTANCES. */ 7.42 -typedef struct { 7.43 - xen_vif_set *vifs; 7.44 - unsigned int currentvifnum; 7.45 -} _RESOURCES; 7.46 - 7.47 -/*** CUSTOMIZE FOR EACH PROVIDER ***/ 7.48 -/* DEFINE A HANDLE TO BE USED FOR EACH INSTANCE OF A SYSTEM RESOURCE. 7.49 - THE MAIN PROVIDER CODE DOES NOT NEED TO KNOW THE PARTICULARS OF HOW EACH 7.50 - RESOURCE IS REPRESENTED, BUT TYPICALLY IT IS A STRUCTURE MIRRORING THE 7.51 - PROPERTIES IN THE CIM CLASS. THIS HANDLE IS PASSED BETWEEN THE RESOURCE 7.52 - ACCESS METHODS WHEN MANIPULATING SPECIFIC RESOURCE INSTANCES. */ 7.53 -typedef xen_vif_record _RESOURCE; 7.54 - 7.55 - 7.56 -/* NOTHING BELOW THIS LINE SHOULD NEED TO BE CHANGED. */ 7.57 - 7.58 -// ---------------------------------------------------------------------------- 7.59 -// Generic resource access methods for CMPI providers. 7.60 -// Return value: 7.61 -// -1 = Unsupported 7.62 -// 0 = Failed 7.63 -// 1 = OK 7.64 -// ---------------------------------------------------------------------------- 7.65 - 7.66 -/* Get a handle to the list of all system resources for this class. */ 7.67 -int Xen_NetworkPortSettingData_getResources(xen_utils_session *session, 7.68 - _RESOURCES ** resources); 7.69 - 7.70 -/* Free/deallocate/cleanup the resources list after use. */ 7.71 -int Xen_NetworkPortSettingData_freeResources(_RESOURCES * resources); 7.72 - 7.73 -/* Iterator to get the next resource from the resources list. */ 7.74 -int Xen_NetworkPortSettingData_getNextResource(xen_utils_session *session, 7.75 - _RESOURCES * resources, 7.76 - _RESOURCE ** resource); 7.77 - 7.78 -/* Get the specific resource that matches the CMPI object path. */ 7.79 -int Xen_NetworkPortSettingData_getResourceForObjectPath(xen_utils_session *session, 7.80 - _RESOURCE ** resource, 7.81 - const CMPIObjectPath * objectpath); 7.82 - 7.83 -/* Free/deallocate/cleanup a resource after use. */ 7.84 -int Xen_NetworkPortSettingData_freeResource(_RESOURCE * resource); 7.85 - 7.86 -/* Set the property values of a CMPI instance from a specific resource. */ 7.87 -int Xen_NetworkPortSettingData_setInstanceFromResource(xen_utils_session *session, 7.88 - _RESOURCE * resource, 7.89 - const CMPIInstance * instance, 7.90 - const CMPIBroker * broker); 7.91 - 7.92 -// THE FOLLOWING METHODS MAY/NOT BE SUPPORTED BY THE SYSTEM FOR THIS CLASS 7.93 - 7.94 -/* Delete the specified resource from the system. */ 7.95 -int Xen_NetworkPortSettingData_deleteResource(xen_utils_session *session, 7.96 - _RESOURCE * resource); 7.97 - 7.98 -/* Modify the specified resource using the property values of a CMPI instance. */ 7.99 -int Xen_NetworkPortSettingData_setResourceFromInstance(_RESOURCE * resource, 7.100 - const CMPIInstance * instance, 7.101 - const CMPIBroker * broker); 7.102 - 7.103 -/* Create a new resource using the property values of a CMPI instance. */ 7.104 -int Xen_NetworkPortSettingData_createResourceFromInstance(_RESOURCES * resources, 7.105 - _RESOURCE ** resource, 7.106 - const CMPIInstance * instance, 7.107 - const CMPIBroker * broker); 7.108 -
8.1 --- a/src/Xen_NetworkPort_Resource.c Thu Aug 02 17:54:59 2007 -0600 8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 8.3 @@ -1,315 +0,0 @@ 8.4 -// Copyright (C) 2006 IBM Corporation 8.5 -// 8.6 -// This library is free software; you can redistribute it and/or 8.7 -// modify it under the terms of the GNU Lesser General Public 8.8 -// License as published by the Free Software Foundation; either 8.9 -// version 2.1 of the License, or (at your option) any later version. 8.10 -// 8.11 -// This library is distributed in the hope that it will be useful, 8.12 -// but WITHOUT ANY WARRANTY; without even the implied warranty of 8.13 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 8.14 -// Lesser General Public License for more details. 8.15 -// 8.16 -// You should have received a copy of the GNU Lesser General Public 8.17 -// License along with this library; if not, write to the Free Software 8.18 -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 8.19 -// ============================================================================ 8.20 -// Authors: Dr. Gareth S. Bestor, <bestor@us.ibm.com> 8.21 -// Tokunbo Adeshiyan, <tokunbo@us.ibm.com> 8.22 -// Contributors: Jim Fehlig, <jfehlig@novell.com> 8.23 -// Rajagopalan Subrahmanian, <raj.subrahmanian@unisys.com> 8.24 -// Description: 8.25 -// ============================================================================ 8.26 - 8.27 -#include <stdlib.h> 8.28 -#include <string.h> 8.29 -#include <assert.h> 8.30 - 8.31 -#include <xen_common.h> 8.32 -#include <xen_vm.h> 8.33 -#include <xen_vif.h> 8.34 - 8.35 -#include "Xen_NetworkPort_Resource.h" 8.36 - 8.37 -/* Include the required CMPI data types, function headers, and macros. */ 8.38 -#include "cmpidt.h" 8.39 -#include "cmpift.h" 8.40 -#include "cmpimacs.h" 8.41 - 8.42 -#include "xen_utils.h" 8.43 - 8.44 -/* Include _SBLIM_TRACE() logging support */ 8.45 -#include "cmpitrace.h" 8.46 - 8.47 -// ---------------------------------------------------------------------------- 8.48 - 8.49 -static int concat_vif_lists(xen_vif_set **target, xen_vif_set *source) 8.50 -{ 8.51 - 8.52 - int total_size; 8.53 - int i, j; 8.54 - 8.55 - /* Nothing to concatenate if source is empty */ 8.56 - if (source == NULL || source->size == 0) 8.57 - return 1; 8.58 - 8.59 - /* If targe is empty, assign source to target */ 8.60 - if (*target == NULL) { 8.61 - *target = source; 8.62 - return 1; 8.63 - } 8.64 - 8.65 - /* realloc memory and append source to target */ 8.66 - total_size = (*target)->size + source->size; 8.67 - *target = realloc(*target, sizeof(xen_vif_set) + (total_size * sizeof(xen_vif))); 8.68 - if (*target == NULL) 8.69 - return 0; 8.70 - 8.71 - for (j = (*target)->size, i = 0; i < source->size; i++) { 8.72 - (*target)->contents[j + i] = source->contents[i]; 8.73 - source->contents[i] = NULL; 8.74 - } 8.75 - (*target)->size = total_size; 8.76 - 8.77 - /* Free source list - it has been copied to target */ 8.78 - xen_vif_set_free(source); 8.79 - return 1; 8.80 -} 8.81 - 8.82 - 8.83 -/* Get a handle to the list of all system resources for this class. */ 8.84 -int Xen_NetworkPort_getResources(xen_utils_session *session, 8.85 - _RESOURCES ** resources) 8.86 -{ 8.87 - xen_domain_resources *res; 8.88 - xen_vif_set *all_vifs = NULL; 8.89 - xen_vm_record *vm_rec = NULL; 8.90 - 8.91 - /* malloc a new handle for the resources list. */ 8.92 - *resources = (_RESOURCES *)calloc(1, sizeof(_RESOURCES)); 8.93 - if (*resources == NULL) 8.94 - return 0; 8.95 - 8.96 - /* Get a list of domain resources. */ 8.97 - if (!xen_utils_get_domain_resources(session, &res)) { 8.98 - *resources = NULL; 8.99 - return 0; 8.100 - } 8.101 - 8.102 - /* Create list of vif resources from vifs found in each domain. */ 8.103 - while (xen_utils_get_next_domain_resource(session, res, &vm_rec)) { 8.104 - /* Ignore halted vms */ 8.105 - if (vm_rec->power_state == XEN_VM_POWER_STATE_HALTED) { 8.106 - xen_vm_record_free(vm_rec); 8.107 - continue; 8.108 - } 8.109 - 8.110 - xen_vif_set *vif_set; 8.111 - if (!xen_vm_get_vifs(session->xen, &vif_set, vm_rec->handle)) 8.112 - goto Error; 8.113 - 8.114 - if (!concat_vif_lists(&all_vifs, vif_set)) 8.115 - goto Error; 8.116 - 8.117 - xen_vm_record_free(vm_rec); 8.118 - } 8.119 - 8.120 - (*resources)->vifs = all_vifs; 8.121 - (*resources)->currentvifnum = 0; 8.122 - 8.123 - return 1; 8.124 - 8.125 - Error: 8.126 - xen_vm_record_free(vm_rec); 8.127 - xen_utils_free_domain_resources(res); 8.128 - free(*resources); 8.129 - *resources = NULL; 8.130 - return 0; 8.131 -} 8.132 - 8.133 -// ---------------------------------------------------------------------------- 8.134 - 8.135 -/* Free/deallocate/cleanup the resources list after use. */ 8.136 -int Xen_NetworkPort_freeResources(_RESOURCES * resources) 8.137 -{ 8.138 - if (resources != NULL) { 8.139 - if (resources->vifs != NULL) 8.140 - xen_vif_set_free(resources->vifs); 8.141 - free(resources); 8.142 - resources = NULL; 8.143 - } 8.144 - 8.145 - return 1; 8.146 -} 8.147 - 8.148 -// ---------------------------------------------------------------------------- 8.149 - 8.150 -/* Iterator to get the next resource from the resources list. */ 8.151 -int Xen_NetworkPort_getNextResource(xen_utils_session *session, 8.152 - _RESOURCES * resources, 8.153 - _RESOURCE ** resource) 8.154 -{ 8.155 - if (resources == NULL || resources->vifs == NULL) 8.156 - return 0; 8.157 - 8.158 - /* Check if reached the end of the list of vifs. */ 8.159 - if (resources->currentvifnum == resources->vifs->size) 8.160 - return 0; 8.161 - 8.162 - /* Get the current vif record. */ 8.163 - if (!xen_vif_get_record(session->xen, resource, resources->vifs->contents[resources->currentvifnum])) 8.164 - return 0; 8.165 - 8.166 - resources->currentvifnum++; 8.167 - return 1; 8.168 -} 8.169 - 8.170 -// ---------------------------------------------------------------------------- 8.171 - 8.172 -/* Get the specific resource that matches the CMPI object path. */ 8.173 -int Xen_NetworkPort_getResourceForObjectPath(xen_utils_session *session, 8.174 - _RESOURCE ** resource, 8.175 - const CMPIObjectPath * objectpath) 8.176 -{ 8.177 - CMPIData namedata; 8.178 - char *keyvalue; 8.179 - int ccode; 8.180 - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ 8.181 - 8.182 - if (CMIsNullObject(objectpath)) return 0; 8.183 - 8.184 - /* Get the vif resource based on DeviceID (vif uuid) */ 8.185 - namedata = CMGetKey(objectpath, "DeviceID", &status); 8.186 - if ((status.rc != CMPI_RC_OK) || CMIsNullValue(namedata)) 8.187 - return 0; 8.188 - 8.189 - keyvalue = CMGetCharPtr(namedata.value.string); 8.190 - if ((keyvalue == NULL) || (*keyvalue == '\0')) 8.191 - return 0; 8.192 - 8.193 - xen_vif vif; 8.194 - if (!xen_vif_get_by_uuid(session->xen, &vif, keyvalue)) 8.195 - return 0; 8.196 - 8.197 - ccode = xen_vif_get_record(session->xen, resource, vif); 8.198 - xen_vif_free(vif); 8.199 - return ccode; 8.200 -} 8.201 - 8.202 -// ---------------------------------------------------------------------------- 8.203 - 8.204 -/* Free/deallocate/cleanup the resource after use. */ 8.205 -int Xen_NetworkPort_freeResource(_RESOURCE * resource) 8.206 -{ 8.207 - xen_vif_record_free(resource); 8.208 - return 1; 8.209 -} 8.210 - 8.211 -// ---------------------------------------------------------------------------- 8.212 - 8.213 -/* Set the property values of a CMPI instance from a specific resource. */ 8.214 -int Xen_NetworkPort_setInstanceFromResource(xen_utils_session *session, 8.215 - _RESOURCE * resource, 8.216 - const CMPIInstance * instance, 8.217 - const CMPIBroker * broker) 8.218 -{ 8.219 - xen_vm_record *alloced_vm_rec = NULL; 8.220 - xen_vm_record *vm_rec; 8.221 - 8.222 - if (resource == NULL) return 0; 8.223 - if (CMIsNullObject(instance)) return 0; 8.224 - 8.225 - xen_vm_record_opt *vm_rec_opt = resource->vm; 8.226 - if (vm_rec_opt->is_record) { 8.227 - vm_rec = vm_rec_opt->u.record; 8.228 - } 8.229 - else { 8.230 - if (!xen_vm_get_record(session->xen, &vm_rec, vm_rec_opt->u.handle)) { 8.231 - /* Error description in session object! */ 8.232 - return 0; 8.233 - } 8.234 - alloced_vm_rec = vm_rec; 8.235 - } 8.236 - 8.237 - /* Set the CMPIInstance properties from the resource data. */ 8.238 - CMSetProperty(instance, "SystemCreationClassName",(CMPIValue *)"Xen_ComputerSystem", CMPI_chars); 8.239 - CMSetProperty(instance, "SystemName",(CMPIValue *)vm_rec->name_label, CMPI_chars); 8.240 - CMSetProperty(instance, "CreationClassName",(CMPIValue *)"Xen_NetworkPort", CMPI_chars); 8.241 - 8.242 - CMSetProperty(instance, "DeviceID",(CMPIValue *)resource->uuid, CMPI_chars); 8.243 - 8.244 - CMSetProperty(instance, "Caption",(CMPIValue *)"Network Port", CMPI_chars); 8.245 - CMSetProperty(instance, "Description",(CMPIValue *)"Network Port", CMPI_chars); 8.246 - 8.247 - //CMSetProperty(instance, "NICConfigInfo",(CMPIValue *)resource->vif[vifnum].params, CMPI_chars); 8.248 - 8.249 - int link_tech = 2; /* 2 == Ethernet */ 8.250 - CMSetProperty(instance, "LinkTechnology",(CMPIValue *)&link_tech, CMPI_uint16); 8.251 - 8.252 - if (resource->device) { 8.253 - CMSetProperty(instance, "Name",(CMPIValue *)resource->device, CMPI_chars); 8.254 - CMSetProperty(instance, "VIFName",(CMPIValue *)resource->device, CMPI_chars); 8.255 - } 8.256 - 8.257 - if (resource->mac) 8.258 - CMSetProperty(instance, "PermanentAddress",(CMPIValue *)resource->mac, CMPI_chars); 8.259 - if (resource->mtu > 0) { 8.260 - CMSetProperty(instance, "SupportedMaximumTransmissionUnit",(CMPIValue *)&(resource->mtu), CMPI_uint64); 8.261 - CMSetProperty(instance, "ActiveMaximumTransmissionUnit",(CMPIValue *)&(resource->mtu), CMPI_uint64); 8.262 - } 8.263 - 8.264 - char nic_config_info[512]; 8.265 - nic_config_info[0] = '\0'; 8.266 - if (resource->mac) 8.267 - snprintf(nic_config_info, 512, "mac=%s", resource->mac); 8.268 - /*if (resource->model) { 8.269 - strncat(nic_config_info, ",model=", 512 - strlen(nic_config_info)); 8.270 - strncat(nic_config_info, resource->model, 512 - strlen(nic_config_info)); 8.271 - } NIC config info does not have model*/ 8.272 - if (nic_config_info[0] != '\0') 8.273 - CMSetProperty(instance, "NICConfigInfo" , (CMPIValue *)nic_config_info, CMPI_chars); 8.274 - 8.275 - if (vm_rec->power_state != XEN_VM_POWER_STATE_HALTED) { 8.276 - CMSetProperty(instance, "Status", (CMPIValue *)"OK", CMPI_chars); 8.277 - } else { 8.278 - CMSetProperty(instance, "Status", (CMPIValue *)"No Contact", CMPI_chars); 8.279 - } 8.280 - 8.281 - if (alloced_vm_rec) 8.282 - xen_vm_record_free(alloced_vm_rec); 8.283 - 8.284 - return 1; 8.285 -} 8.286 - 8.287 -// ---------------------------------------------------------------------------- 8.288 - 8.289 -/* Delete the specified resource from the system. */ 8.290 -int Xen_NetworkPort_deleteResource(xen_utils_session *session, 8.291 - _RESOURCE * resource) 8.292 -{ 8.293 - return xen_vif_destroy(session->xen, resource->handle); 8.294 -} 8.295 - 8.296 -// ---------------------------------------------------------------------------- 8.297 - 8.298 -/* Modify the specified resource using the property values of a CMPI instance. */ 8.299 -int Xen_NetworkPort_setResourceFromInstance(_RESOURCE * resource, 8.300 - const CMPIInstance * instance, 8.301 - const CMPIBroker * broker) 8.302 -{ 8.303 - /* Unsupported. */ 8.304 - return -1; 8.305 -} 8.306 - 8.307 -// ---------------------------------------------------------------------------- 8.308 - 8.309 -/* Create a new resource using the property values of a CMPI instance. */ 8.310 -int Xen_NetworkPort_createResourceFromInstance(_RESOURCES * resources, 8.311 - _RESOURCE ** resource, 8.312 - const CMPIInstance * instance, 8.313 - const CMPIBroker * broker) 8.314 -{ 8.315 - /* Unsupported. */ 8.316 - return -1; 8.317 -} 8.318 -
9.1 --- a/src/Xen_NetworkPort_Resource.h Thu Aug 02 17:54:59 2007 -0600 9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 9.3 @@ -1,104 +0,0 @@ 9.4 -// Copyright (C) 2006 IBM Corporation 9.5 -// 9.6 -// This library is free software; you can redistribute it and/or 9.7 -// modify it under the terms of the GNU Lesser General Public 9.8 -// License as published by the Free Software Foundation; either 9.9 -// version 2.1 of the License, or (at your option) any later version. 9.10 -// 9.11 -// This library is distributed in the hope that it will be useful, 9.12 -// but WITHOUT ANY WARRANTY; without even the implied warranty of 9.13 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 9.14 -// Lesser General Public License for more details. 9.15 -// 9.16 -// You should have received a copy of the GNU Lesser General Public 9.17 -// License along with this library; if not, write to the Free Software 9.18 -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 9.19 -// ============================================================================ 9.20 -// Authors: Dr. Gareth S. Bestor, <bestor@us.ibm.com> 9.21 -// Tokunbo Adeshiyan, <tokunbo@us.ibm.com> 9.22 -// Contributors: Jim Fehlig, <jfehlig@novell.com> 9.23 -// Rajagopalan Subrahmanian <raj.subrahmanian@unisys.com> 9.24 -// Description: 9.25 -// ============================================================================ 9.26 - 9.27 -/* Include required libxen headers. */ 9.28 -#include <xen_common.h> 9.29 -#include <xen_vif.h> 9.30 - 9.31 -#include "xen_utils.h" 9.32 - 9.33 -/*** CUSTOMIZE FOR EACH PROVIDER ***/ 9.34 -/* DEFINE A HANDLE TO REPRESENT THE 'LIST' OF ALL SYSTEM RESOURCES. 9.35 - THE MAIN PROVIDER CODE DOES NOT NEED TO KNOW THE PARTICULARS OF HOW THIS 9.36 - LIST IS IMPLEMENTED - IT MAY BE AN ARRAY, LINKED LIST, FILE, ETC. 9.37 - THIS HANDLE IS PASSED INTO THE APPROPRIATE RESOURCE ACCESS METHODS WHEN 9.38 - ACCESSING/ITERATING/ADDING/REMOVING RESOURCES INSTANCES. */ 9.39 -typedef struct { 9.40 - xen_vif_set *vifs; 9.41 - unsigned int currentvifnum; 9.42 -} _RESOURCES; 9.43 - 9.44 -/*** CUSTOMIZE FOR EACH PROVIDER ***/ 9.45 -/* DEFINE A HANDLE TO BE USED FOR EACH INSTANCE OF A SYSTEM RESOURCE. 9.46 - THE MAIN PROVIDER CODE DOES NOT NEED TO KNOW THE PARTICULARS OF HOW EACH 9.47 - RESOURCE IS REPRESENTED, BUT TYPICALLY IT IS A STRUCTURE MIRRORING THE 9.48 - PROPERTIES IN THE CIM CLASS. THIS HANDLE IS PASSED BETWEEN THE RESOURCE 9.49 - ACCESS METHODS WHEN MANIPULATING SPECIFIC RESOURCE INSTANCES. */ 9.50 -typedef xen_vif_record _RESOURCE; 9.51 - 9.52 -/* NOTHING BELOW THIS LINE SHOULD NEED TO BE CHANGED. */ 9.53 - 9.54 -/* Include the required CMPI data types. */ 9.55 -#include "cmpidt.h" 9.56 - 9.57 -// ---------------------------------------------------------------------------- 9.58 -// Generic resource access methods for CMPI providers. 9.59 -// Return value: 9.60 -// -1 = Unsupported 9.61 -// 0 = Failed 9.62 -// 1 = OK 9.63 -// ---------------------------------------------------------------------------- 9.64 - 9.65 -/* Get a handle to the list of all system resources for this class. */ 9.66 -int Xen_NetworkPort_getResources(xen_utils_session *session, 9.67 - _RESOURCES ** resources); 9.68 - 9.69 -/* Free/deallocate/cleanup the resources list after use. */ 9.70 -int Xen_NetworkPort_freeResources(_RESOURCES * resources); 9.71 - 9.72 -/* Iterator to get the next resource from the resources list. */ 9.73 -int Xen_NetworkPort_getNextResource(xen_utils_session *session, 9.74 - _RESOURCES * resources, 9.75 - _RESOURCE ** resource); 9.76 - 9.77 -/* Get the specific resource that matches the CMPI object path. */ 9.78 -int Xen_NetworkPort_getResourceForObjectPath(xen_utils_session *session, 9.79 - _RESOURCE ** resource, 9.80 - const CMPIObjectPath * objectpath); 9.81 - 9.82 -/* Free/deallocate/cleanup a resource after use. */ 9.83 -int Xen_NetworkPort_freeResource(_RESOURCE * resource); 9.84 - 9.85 -/* Set the property values of a CMPI instance from a specific resource. */ 9.86 -int Xen_NetworkPort_setInstanceFromResource(xen_utils_session *session, 9.87 - _RESOURCE * resource, 9.88 - const CMPIInstance * instance, 9.89 - const CMPIBroker * broker); 9.90 - 9.91 -// THE FOLLOWING METHODS MAY/NOT BE SUPPORTED BY THE SYSTEM FOR THIS CLASS 9.92 - 9.93 -/* Delete the specified resource from the system. */ 9.94 -int Xen_NetworkPort_deleteResource(xen_utils_session *session, 9.95 - _RESOURCE * resource); 9.96 - 9.97 -/* Modify the specified resource using the property values of a CMPI instance. */ 9.98 -int Xen_NetworkPort_setResourceFromInstance(_RESOURCE * resource, 9.99 - const CMPIInstance * instance, 9.100 - const CMPIBroker * broker); 9.101 - 9.102 -/* Create a new resource using the property values of a CMPI instance. */ 9.103 -int Xen_NetworkPort_createResourceFromInstance(_RESOURCES * resources, 9.104 - _RESOURCE ** resource, 9.105 - const CMPIInstance * instance, 9.106 - const CMPIBroker * broker); 9.107 -