os-cmpi-xen
changeset 131:dc1be661c5ee
Ported Xen_ComputerSystemSettingData to 'Cmpilify' interface.
Removed corresponding resource files that are no longer used.
Added support for modifying adjustable settings in Xen_ComputerSystemSettingData.
Signed-off-by: Jim Fehlig <jfehlig@novell.com>
Removed corresponding resource files that are no longer used.
Added support for modifying adjustable settings in Xen_ComputerSystemSettingData.
Signed-off-by: Jim Fehlig <jfehlig@novell.com>
author | Jim Fehlig <jfehlig@novell.com> |
---|---|
date | Wed Jul 18 16:05:48 2007 -0600 (2007-07-18) |
parents | e82eeb0764d6 |
children | 1b777fd695b9 |
files | ChangeLog schema/Xen_ComputerSystemSettingData.mof src/Makefile.am src/Xen_ComputerSystemSettingData.c src/Xen_ComputerSystemSettingData_Resource.c src/Xen_ComputerSystemSettingData_Resource.h |
line diff
1.1 --- a/ChangeLog Tue Jul 17 16:10:55 2007 -0600 1.2 +++ b/ChangeLog Wed Jul 18 16:05:48 2007 -0600 1.3 @@ -1,3 +1,12 @@ 1.4 +------------------------------------------------------------------- 1.5 +Wed Jul 18 16:01:11 MDT 2007 - jfehlig@novell.com 1.6 + 1.7 + - Ported Xen_ComputerSystemSettingData to 'Cmpilify' 1.8 + interface. Removed corresponding resource files that 1.9 + are no longer used. 1.10 + - Added support for modifying adjustable settings in 1.11 + Xen_ComputerSystemSettingData. 1.12 + 1.13 ------------------------------------------------------------------- 1.14 Tue Jul 17 16:07:53 MDT 2007 - jfehlig@novell.com 1.15
2.1 --- a/schema/Xen_ComputerSystemSettingData.mof Tue Jul 17 16:10:55 2007 -0600 2.2 +++ b/schema/Xen_ComputerSystemSettingData.mof Wed Jul 18 16:05:48 2007 -0600 2.3 @@ -85,7 +85,7 @@ class Xen_ComputerSystemSettingData : CI 2.4 2.5 [Description ("Specify behavior when domain crashes"), 2.6 ValueMap { "0", "1", "2", "3", "4", "5", ".." }, 2.7 - Values { "Destroy", "Restart", "Core Dump and Destroy", 2.8 + Values { "Destroy", "Core Dump and Destroy", "Restart", 2.9 "Core Dump and Restart", "Preserve", "Rename and Restart", 2.10 "Reserved"}] 2.11 uint16 OnCrash;
3.1 --- a/src/Makefile.am Tue Jul 17 16:10:55 2007 -0600 3.2 +++ b/src/Makefile.am Wed Jul 18 16:05:48 2007 -0600 3.3 @@ -51,7 +51,6 @@ noinst_HEADERS = \ 3.4 Xen_NetworkPort_Resource.h \ 3.5 Xen_Console_Resource.h \ 3.6 Xen_VirtualizationCapabilities_Resource.h \ 3.7 - Xen_ComputerSystemSettingData_Resource.h \ 3.8 Xen_NetworkPortSettingData_Resource.h \ 3.9 Xen_ConsoleSettingData_Resource.h \ 3.10 Xen_MemoryPool_Resource.h \ 3.11 @@ -223,7 +222,7 @@ libXen_HasVirtualizationCapabilities_la_ 3.12 libXen_HasVirtualizationCapabilities_la_LIBADD = libXen_ProviderCommon.la 3.13 libXen_HasVirtualizationCapabilities_la_LDFLAGS = -module -avoid-version -no-undefined 3.14 3.15 -libXen_ComputerSystemSettingData_la_SOURCES = Xen_ComputerSystemSettingData.c Xen_ComputerSystemSettingData_Resource.c 3.16 +libXen_ComputerSystemSettingData_la_SOURCES = Xen_ComputerSystemSettingData.c 3.17 libXen_ComputerSystemSettingData_la_CFLAGS = -I../ @LIBXEN_CFLAGS@ 3.18 libXen_ComputerSystemSettingData_la_LIBADD = libXen_ProviderCommon.la 3.19 libXen_ComputerSystemSettingData_la_LDFLAGS = -module -avoid-version -no-undefined
4.1 --- a/src/Xen_ComputerSystemSettingData.c Tue Jul 17 16:10:55 2007 -0600 4.2 +++ b/src/Xen_ComputerSystemSettingData.c Wed Jul 18 16:05:48 2007 -0600 4.3 @@ -16,634 +16,779 @@ 4.4 // ============================================================================ 4.5 // Authors: Dr. Gareth S. Bestor, <bestor@us.ibm.com> 4.6 // Contributors: Jim Fehlig, <jfehlig@novell.com> 4.7 -// Description: 4.8 +// Description: Implementation of CIM_VirtualSystemSettingData for Xen 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 "Cimpler" 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 +#include "cmpilify.h" 4.26 4.27 -/* Include Xen utilities */ 4.28 -#include "xen_utils.h" 4.29 4.30 -/* Include the abstract resource access functions and abstracted _RESOURCES and _RESOURCE data types. */ 4.31 -#include "Xen_ComputerSystemSettingData_Resource.h" 4.32 +static const CMPIInstanceMI* mi; 4.33 4.34 4.35 -// ---------------------------------------------------------------------------- 4.36 -// COMMON GLOBAL VARIABLES 4.37 -// ---------------------------------------------------------------------------- 4.38 +#define _BROKER (((CMPILIFYInstanceMI*)(mi->hdl))->brkr) 4.39 +#define _CLASS (((CMPILIFYInstanceMI*)(mi->hdl))->cn) 4.40 +#define _KEYS (((CMPILIFYInstanceMI*)(mi->hdl))->kys) 4.41 + 4.42 +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 4.43 + 4.44 +#include <stdlib.h> 4.45 +#include <assert.h> 4.46 + 4.47 +#include <xen_common.h> 4.48 +#include <xen_host.h> 4.49 +#include <xen_vm.h> 4.50 + 4.51 +#include "cmpitrace.h" 4.52 +#include "xen_utils.h" 4.53 +#include "provider_common.h" 4.54 + 4.55 4.56 -/* Handle to the CIM broker. Initialized when the provider lib is loaded. */ 4.57 -static const CMPIBroker *_BROKER; 4.58 +/* C struct to store data for a single resource. */ 4.59 +typedef struct { 4.60 + int is_vm_record; 4.61 + union 4.62 + { 4.63 + xen_vm_record *vm_rec; 4.64 + CMPIInstance *cmpi_inst; 4.65 + } u; 4.66 +} cs_resource; 4.67 + 4.68 + 4.69 +/* C struct to store the data for all resources. */ 4.70 +typedef struct { 4.71 + xen_vm_set *domains; 4.72 + size_t cur_domain; 4.73 +} cs_resources; 4.74 + 4.75 4.76 /* Xen session object. Initialize when the provider is loaded, close when 4.77 * provider unloaded. */ 4.78 static xen_utils_session *session = NULL; 4.79 4.80 4.81 -// ============================================================================ 4.82 -// CMPI INSTANCE PROVIDER FUNCTION TABLE 4.83 -// ============================================================================ 4.84 - 4.85 -// ---------------------------------------------------------------------------- 4.86 -// Info for the class supported by the instance provider 4.87 -// ---------------------------------------------------------------------------- 4.88 +/* Support modifying the following settings ... 4.89 + * PV Specific: Kernel, RAMDisk, KernelOptions, BootLoader, BootLoaderOptions 4.90 + * HVM Specific: BootOrder, apic, acpi, pae, usb, usbdevice, stdvga 4.91 + * Common: localtime, OnPoweroff, OnReboot, OnCrash 4.92 + */ 4.93 +static int modify_vm_setting(xen_vm_record *vm_rec, 4.94 + const char *name, CMPIData data) 4.95 +{ 4.96 + char *prop_val; 4.97 + 4.98 + if (strcmp(name, "Kernel") == 0) { 4.99 + prop_val = CMGetCharPtr(data.value.string); 4.100 + xen_vm_set_pv_kernel(session->xen, vm_rec->handle, prop_val); 4.101 + } 4.102 + else if (strcmp(name, "RAMDisk") == 0) { 4.103 + prop_val = CMGetCharPtr(data.value.string); 4.104 + xen_vm_set_pv_ramdisk(session->xen, vm_rec->handle, prop_val); 4.105 + } 4.106 + else if (strcmp(name, "KernelOptions") == 0) { 4.107 + prop_val = CMGetCharPtr(data.value.string); 4.108 + xen_vm_set_pv_args(session->xen, vm_rec->handle, prop_val); 4.109 + } 4.110 + else if (strcmp(name, "Bootloader") == 0) { 4.111 + prop_val = CMGetCharPtr(data.value.string); 4.112 + xen_vm_set_pv_bootloader(session->xen, vm_rec->handle, prop_val); 4.113 + } 4.114 + else if (strcmp(name, "BootloaderOptions") == 0) { 4.115 + prop_val = CMGetCharPtr(data.value.string); 4.116 + xen_vm_set_pv_bootloader_args(session->xen, vm_rec->handle, prop_val); 4.117 + } 4.118 + else if (strcmp(name, "BootOrder") == 0) { 4.119 + prop_val = CMGetCharPtr(data.value.string); 4.120 + xen_utils_add_to_string_string_map("order", prop_val, 4.121 + &(vm_rec->hvm_boot_params )); 4.122 + xen_vm_set_hvm_boot_params(session->xen, vm_rec->handle, 4.123 + vm_rec->hvm_boot_params); 4.124 + } 4.125 + else if (strcmp(name, "apic") == 0) { 4.126 + if (data.value.boolean) 4.127 + prop_val = "1"; 4.128 + else 4.129 + prop_val = "0"; 4.130 + xen_utils_add_to_string_string_map("apic", prop_val, 4.131 + &(vm_rec->platform )); 4.132 + xen_vm_set_platform(session->xen, vm_rec->handle, vm_rec->platform); 4.133 + } 4.134 + else if (strcmp(name, "acpi") == 0) { 4.135 + if (data.value.boolean) 4.136 + prop_val = "1"; 4.137 + else 4.138 + prop_val = "0"; 4.139 + xen_utils_add_to_string_string_map("acpi", prop_val, 4.140 + &(vm_rec->platform )); 4.141 + xen_vm_set_platform(session->xen, vm_rec->handle, vm_rec->platform); 4.142 + } 4.143 + else if (strcmp(name, "pae") == 0) { 4.144 + if (data.value.boolean) 4.145 + prop_val = "1"; 4.146 + else 4.147 + prop_val = "0"; 4.148 + xen_utils_add_to_string_string_map("pae", prop_val, 4.149 + &(vm_rec->platform )); 4.150 + xen_vm_set_platform(session->xen, vm_rec->handle, vm_rec->platform); 4.151 + } 4.152 + else if (strcmp(name, "stdvga") == 0) { 4.153 + if (data.value.boolean) 4.154 + prop_val = "1"; 4.155 + else 4.156 + prop_val = "0"; 4.157 + xen_utils_add_to_string_string_map("stdvga", prop_val, 4.158 + &(vm_rec->platform )); 4.159 + xen_vm_set_platform(session->xen, vm_rec->handle, vm_rec->platform); 4.160 + } 4.161 + else if (strcmp(name, "usb") == 0) { 4.162 + if (data.value.boolean) 4.163 + prop_val = "1"; 4.164 + else 4.165 + prop_val = "0"; 4.166 + xen_utils_add_to_string_string_map("usb", prop_val, 4.167 + &(vm_rec->platform )); 4.168 + xen_vm_set_platform(session->xen, vm_rec->handle, vm_rec->platform); 4.169 + } 4.170 + else if (strcmp(name, "usbdevice") == 0) { 4.171 + prop_val = CMGetCharPtr(data.value.string); 4.172 + xen_utils_add_to_string_string_map("usbdevice", prop_val, 4.173 + &(vm_rec->platform )); 4.174 + xen_vm_set_platform(session->xen, vm_rec->handle, vm_rec->platform); 4.175 + } 4.176 + else if (strcmp(name, "localtime") == 0) { 4.177 + if (data.value.boolean) 4.178 + prop_val = "1"; 4.179 + else 4.180 + prop_val = "0"; 4.181 + xen_utils_add_to_string_string_map("localtime", prop_val, 4.182 + &(vm_rec->platform )); 4.183 + xen_vm_set_platform(session->xen, vm_rec->handle, vm_rec->platform); 4.184 + } 4.185 + else if (strcmp(name, "OnPoweroff") == 0) { 4.186 + xen_vm_set_actions_after_shutdown(session->xen, 4.187 + vm_rec->handle, data.value.uint16); 4.188 + } 4.189 + else if (strcmp(name, "OnReboot") == 0) { 4.190 + xen_vm_set_actions_after_reboot(session->xen, 4.191 + vm_rec->handle, data.value.uint16); 4.192 + } 4.193 + else if (strcmp(name, "OnCrash") == 0) { 4.194 + xen_vm_set_actions_after_crash(session->xen, 4.195 + vm_rec->handle, data.value.uint16); 4.196 + } 4.197 + 4.198 + if (!session->xen->ok) { 4.199 + _SBLIM_TRACE(1,("--- Failed to modify domain %s setting", name)); 4.200 + _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR, 4.201 + xen_utils_trace_error(session->xen)); 4.202 + return 0; 4.203 + } 4.204 4.205 -/* Name of the class implemented by this instance provider. */ 4.206 -/*** CUSTOMIZE FOR EACH PROVIDER ***/ 4.207 -static char * _CLASSNAME = "Xen_ComputerSystemSettingData"; 4.208 + return 1; 4.209 +} 4.210 + 4.211 4.212 -/* NULL terminated list of key properties of this class. */ 4.213 -/*** CUSTOMIZE FOR EACH PROVIDER ***/ 4.214 -const static char * _KEYNAMES[] = {"InstanceID", NULL}; 4.215 +static int modify_vm_settings(xen_vm_record *vm_rec, 4.216 + CMPIInstance *modified_inst, 4.217 + const char **properties) 4.218 +{ 4.219 + int i; 4.220 + CMPIStatus status = {CMPI_RC_OK, NULL}; 4.221 + CMPIData data; 4.222 + char *prop_val; 4.223 + char *map_val; 4.224 + 4.225 + if (properties) { 4.226 + for (i = 0; properties[i] != NULL; i++) { 4.227 + data = CMGetProperty(modified_inst, properties[i], &status); 4.228 + if ((status.rc != CMPI_RC_OK) || CMIsNullValue(data)) { 4.229 + _SBLIM_TRACE(1,("--- Unable to retrieve property %s from VSSD", 4.230 + properties[i])); 4.231 + return 0; 4.232 + } 4.233 + 4.234 + if (!modify_vm_setting(vm_rec, properties[i], data)) 4.235 + return 0; 4.236 + } 4.237 + return 1; 4.238 + } 4.239 4.240 -// ---------------------------------------------------------------------------- 4.241 -// Cleanup() 4.242 -// Perform any necessary cleanup immediately before this provider is unloaded. 4.243 -// ---------------------------------------------------------------------------- 4.244 -static CMPIStatus Cleanup( 4.245 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 4.246 - const CMPIContext * context, /* [in] Additional context info, if any. */ 4.247 - CMPIBoolean terminating) /* [in] True if MB is terminating */ 4.248 + /* 4.249 + * Bummer - property list not specified. Go through properties we 4.250 + * support changing. 4.251 + */ 4.252 + data = CMGetProperty(modified_inst, "Kernel", &status); 4.253 + if (status.rc == CMPI_RC_OK && !CMIsNullValue(data)) 4.254 + if (vm_rec->pv_kernel == NULL || 4.255 + strcmp(vm_rec->pv_kernel, CMGetCharPtr(data.value.string))) 4.256 + if (!modify_vm_setting(vm_rec, "Kernel", data)) 4.257 + return 0; 4.258 + 4.259 + data = CMGetProperty(modified_inst, "RAMDisk", &status); 4.260 + if (status.rc == CMPI_RC_OK && !CMIsNullValue(data)) 4.261 + if (vm_rec->pv_ramdisk == NULL || 4.262 + strcmp(vm_rec->pv_ramdisk, CMGetCharPtr(data.value.string))) 4.263 + if (!modify_vm_setting(vm_rec, "RAMDisk", data)) 4.264 + return 0; 4.265 + 4.266 + data = CMGetProperty(modified_inst, "KernelOptions", &status); 4.267 + if (status.rc == CMPI_RC_OK && !CMIsNullValue(data)) 4.268 + if (vm_rec->pv_args == NULL || 4.269 + strcmp(vm_rec->pv_args, CMGetCharPtr(data.value.string))) 4.270 + if (!modify_vm_setting(vm_rec, "KernelOptions", data)) 4.271 + return 0; 4.272 + 4.273 + data = CMGetProperty(modified_inst, "Bootloader", &status); 4.274 + if (status.rc == CMPI_RC_OK && !CMIsNullValue(data)) 4.275 + if (vm_rec->pv_bootloader == NULL || 4.276 + strcmp(vm_rec->pv_bootloader, CMGetCharPtr(data.value.string))) 4.277 + if (!modify_vm_setting(vm_rec, "Bootloader", data)) 4.278 + return 0; 4.279 + 4.280 + data = CMGetProperty(modified_inst, "BootloaderOptions", &status); 4.281 + if (status.rc == CMPI_RC_OK && !CMIsNullValue(data)) 4.282 + if (vm_rec->pv_bootloader_args == NULL || 4.283 + strcmp(vm_rec->pv_bootloader_args, CMGetCharPtr(data.value.string))) 4.284 + if (!modify_vm_setting(vm_rec, "BootloaderOptions", data)) 4.285 + return 0; 4.286 + 4.287 + data = CMGetProperty(modified_inst, "BootOrder", &status); 4.288 + if (status.rc == CMPI_RC_OK && !CMIsNullValue(data)) { 4.289 + map_val = xen_utils_get_from_string_string_map(vm_rec->hvm_boot_params, "order"); 4.290 + if (map_val == NULL || strcmp(map_val, CMGetCharPtr(data.value.string))) 4.291 + if (!modify_vm_setting(vm_rec, "BootOrder", data)) 4.292 + return 0; 4.293 + } 4.294 + 4.295 + data = CMGetProperty(modified_inst, "apic", &status); 4.296 + if (status.rc == CMPI_RC_OK && !CMIsNullValue(data)) { 4.297 + if (data.value.boolean) 4.298 + prop_val = "1"; 4.299 + else 4.300 + prop_val = "0"; 4.301 + map_val = xen_utils_get_from_string_string_map(vm_rec->platform, "apic"); 4.302 + if (map_val == NULL || strcmp(map_val, prop_val)) 4.303 + if (!modify_vm_setting(vm_rec, "apic", data)) 4.304 + return 0; 4.305 + } 4.306 + 4.307 + data = CMGetProperty(modified_inst, "acpi", &status); 4.308 + if (status.rc == CMPI_RC_OK && !CMIsNullValue(data)) { 4.309 + if (data.value.boolean) 4.310 + prop_val = "1"; 4.311 + else 4.312 + prop_val = "0"; 4.313 + map_val = xen_utils_get_from_string_string_map(vm_rec->platform, "acpi"); 4.314 + if (map_val == NULL || strcmp(map_val, prop_val)) 4.315 + if (!modify_vm_setting(vm_rec, "acpi", data)) 4.316 + return 0; 4.317 + } 4.318 + 4.319 + data = CMGetProperty(modified_inst, "pea", &status); 4.320 + if (status.rc == CMPI_RC_OK && !CMIsNullValue(data)) { 4.321 + if (data.value.boolean) 4.322 + prop_val = "1"; 4.323 + else 4.324 + prop_val = "0"; 4.325 + map_val = xen_utils_get_from_string_string_map(vm_rec->platform, "pae"); 4.326 + if (map_val == NULL || strcmp(map_val, prop_val)) 4.327 + if (!modify_vm_setting(vm_rec, "pae", data)) 4.328 + return 0; 4.329 + } 4.330 + 4.331 + data = CMGetProperty(modified_inst, "stdvga", &status); 4.332 + if (status.rc == CMPI_RC_OK && !CMIsNullValue(data)) { 4.333 + if (data.value.boolean) 4.334 + prop_val = "1"; 4.335 + else 4.336 + prop_val = "0"; 4.337 + map_val = xen_utils_get_from_string_string_map(vm_rec->platform, "stdvga"); 4.338 + if (map_val == NULL || strcmp(map_val, prop_val)) 4.339 + if (!modify_vm_setting(vm_rec, "stdvga", data)) 4.340 + return 0; 4.341 + } 4.342 + 4.343 + data = CMGetProperty(modified_inst, "usb", &status); 4.344 + if (status.rc == CMPI_RC_OK && !CMIsNullValue(data)) { 4.345 + if (data.value.boolean) 4.346 + prop_val = "1"; 4.347 + else 4.348 + prop_val = "0"; 4.349 + map_val = xen_utils_get_from_string_string_map(vm_rec->platform, "usb"); 4.350 + if (map_val == NULL || strcmp(map_val, prop_val)) 4.351 + if (!modify_vm_setting(vm_rec, "usb", data)) 4.352 + return 0; 4.353 + } 4.354 + 4.355 + data = CMGetProperty(modified_inst, "usbdevice", &status); 4.356 + if (status.rc == CMPI_RC_OK && !CMIsNullValue(data)) { 4.357 + map_val = xen_utils_get_from_string_string_map(vm_rec->platform, "usbdevice"); 4.358 + if (map_val == NULL || strcmp(map_val, CMGetCharPtr(data.value.string))) 4.359 + if (!modify_vm_setting(vm_rec, "usbdevice", data)) 4.360 + return 0; 4.361 + } 4.362 + 4.363 + data = CMGetProperty(modified_inst, "localtime", &status); 4.364 + if (status.rc == CMPI_RC_OK && !CMIsNullValue(data)) { 4.365 + if (data.value.boolean) 4.366 + prop_val = "1"; 4.367 + else 4.368 + prop_val = "0"; 4.369 + map_val = xen_utils_get_from_string_string_map(vm_rec->platform, "localtime"); 4.370 + if (map_val == NULL || strcmp(map_val, prop_val)) 4.371 + if (!modify_vm_setting(vm_rec, "localtime", data)) 4.372 + return 0; 4.373 + } 4.374 + 4.375 + data = CMGetProperty(modified_inst, "OnPoweroff", &status); 4.376 + if (status.rc == CMPI_RC_OK && !CMIsNullValue(data)) 4.377 + if (vm_rec->actions_after_shutdown != data.value.uint16) 4.378 + if (!modify_vm_setting(vm_rec, "OnPoweroff", data)) 4.379 + return 0; 4.380 + 4.381 + data = CMGetProperty(modified_inst, "OnReboot", &status); 4.382 + if (status.rc == CMPI_RC_OK && !CMIsNullValue(data)) 4.383 + if (vm_rec->actions_after_reboot != data.value.uint16) 4.384 + if (!modify_vm_setting(vm_rec, "OnReboot", data)) 4.385 + return 0; 4.386 + 4.387 + data = CMGetProperty(modified_inst, "OnCrash", &status); 4.388 + if (status.rc == CMPI_RC_OK && !CMIsNullValue(data)) 4.389 + if (vm_rec->actions_after_crash != data.value.uint16) 4.390 + if (!modify_vm_setting(vm_rec, "OnCrash", data)) 4.391 + return 0; 4.392 + 4.393 + return 1; 4.394 +} 4.395 + 4.396 + 4.397 +static CMPIrc load() 4.398 { 4.399 - CMPIStatus status = { CMPI_RC_OK, NULL }; /* Return status of CIM operations. */ 4.400 + /* Initialized Xen session object. */ 4.401 + if (!session) 4.402 + xen_utils_xen_init(&session); 4.403 4.404 - _SBLIM_ENTER("Cleanup"); 4.405 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 4.406 - _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 4.407 + return CMPI_RC_OK; 4.408 +} 4.409 4.410 - if (terminating) 4.411 - fprintf(stderr, "#### cimom terminating\n"); 4.412 - else 4.413 - fprintf(stderr, "#### cimom NOT terminating\n"); 4.414 + 4.415 +static CMPIrc unload(const int terminating) 4.416 +{ 4.417 + (void)terminating; 4.418 4.419 + /* Close Xen session object. */ 4.420 if (session) { 4.421 xen_utils_xen_close(session); 4.422 session = NULL; 4.423 } 4.424 - _SBLIM_RETURNSTATUS(status); 4.425 + 4.426 + return CMPI_RC_OK; 4.427 } 4.428 4.429 -// ---------------------------------------------------------------------------- 4.430 -// EnumInstanceNames() 4.431 -// Return a list of all the instances names (return their object paths only). 4.432 -// ---------------------------------------------------------------------------- 4.433 -static CMPIStatus EnumInstanceNames( 4.434 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 4.435 - const CMPIContext * context, /* [in] Additional context info, if any. */ 4.436 - const CMPIResult * results, /* [out] Results of this operation. */ 4.437 - const CMPIObjectPath * reference) /* [in] Contains target namespace and classname. */ 4.438 + 4.439 +static CMPIrc begin(void **res_list, const char **properties) 4.440 { 4.441 - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ 4.442 - _RESOURCES * resources = NULL; /* Handle to the list of system resources. */ 4.443 - _RESOURCE * resource; /* Handle to each system resource. */ 4.444 - char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */ 4.445 - int found = 0; /* Found any instances? */ 4.446 - 4.447 - _SBLIM_ENTER("EnumInstanceNames"); 4.448 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 4.449 - _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 4.450 - _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL)))); 4.451 - _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace)); 4.452 - 4.453 + cs_resources *resources; 4.454 + 4.455 + (void)properties; 4.456 + 4.457 if (!xen_utils_validate_session(&session)) { 4.458 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon"); 4.459 - goto exit; 4.460 - } 4.461 - 4.462 - /* Get a handle to the list of system resources. */ 4.463 - if (!Xen_ComputerSystemSettingData_getResources(session, &resources)) { 4.464 - _SBLIM_TRACE(1,("--- _getResources() failed")); 4.465 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources"); 4.466 - goto exit; 4.467 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 4.468 + ("--- Unable to establish connection with Xend")); 4.469 + return CMPI_RC_ERR_FAILED; 4.470 } 4.471 4.472 - /* Enumerate thru the list of system resources and return a CMPIInstance for each. */ 4.473 - while (Xen_ComputerSystemSettingData_getNextResource(session, resources, &resource)) { 4.474 - /* Create a new CMPIInstance to store this resource. */ 4.475 - CMPIInstance * instance = _CMNewInstance(_BROKER, namespace, _CLASSNAME, &status); 4.476 - if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instance)) { 4.477 - _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status.msg))); 4.478 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIInstance"); 4.479 - goto exit; 4.480 - } 4.481 - 4.482 - /* Set the instance property values from the resource data. */ 4.483 - if (!Xen_ComputerSystemSettingData_setInstanceFromResource(resource, instance, _BROKER)) { 4.484 - _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed")); 4.485 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data"); 4.486 - goto exit; 4.487 - } 4.488 - 4.489 - /* Free the resource data. */ 4.490 - if (!Xen_ComputerSystemSettingData_freeResource(resource)) { 4.491 - _SBLIM_TRACE(1,("--- _freeResource() failed")); 4.492 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data"); 4.493 - goto exit; 4.494 - } 4.495 - 4.496 - /* Return the CMPIObjectPath for this instance. */ 4.497 - CMPIObjectPath * objectpath = CMGetObjectPath(instance, &status); 4.498 - if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) { 4.499 - _SBLIM_TRACE(1,("--- CMGetObjectPath() failed - %s", CMGetCharPtr(status.msg))); 4.500 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot get CMPIObjectPath for instance"); 4.501 - goto exit; 4.502 - } 4.503 - CMSetNameSpace(objectpath, namespace); /* Note - CMGetObjectPath() does not preserve the namespace! */ 4.504 - 4.505 - _SBLIM_TRACE(3,("--- objectpath=\"%s\"", CMGetCharPtr(CDToString(_BROKER, objectpath, NULL)))); 4.506 - CMReturnObjectPath(results, objectpath); 4.507 - found++; 4.508 - } 4.509 - 4.510 - _SBLIM_TRACE(2,("--- %d object paths found", found)); 4.511 - CMReturnDone(results); 4.512 + /* malloc a new handle for the resources list. */ 4.513 + resources = (cs_resources *)calloc(1, sizeof(cs_resources)); 4.514 + if (resources == NULL) 4.515 + return CMPI_RC_ERR_FAILED; 4.516 4.517 -exit: 4.518 - /* Free the list of system resources. */ 4.519 - if (!Xen_ComputerSystemSettingData_freeResources(resources)) { 4.520 - _SBLIM_TRACE(1,("--- _freeResources() failed")); 4.521 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources"); 4.522 - } 4.523 - 4.524 - _SBLIM_RETURNSTATUS(status); 4.525 -} 4.526 - 4.527 -// ---------------------------------------------------------------------------- 4.528 -// EnumInstances() 4.529 -// Return a list of all the instances (return all the instance data). 4.530 -// ---------------------------------------------------------------------------- 4.531 -static CMPIStatus EnumInstances( 4.532 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 4.533 - const CMPIContext * context, /* [in] Additional context info, if any. */ 4.534 - const CMPIResult * results, /* [out] Results of this operation. */ 4.535 - const CMPIObjectPath * reference, /* [in] Contains target namespace and classname. */ 4.536 - const char ** properties) /* [in] List of desired properties (NULL=all). */ 4.537 -{ 4.538 - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ 4.539 - _RESOURCES * resources = NULL; /* Handle to the list of system resources. */ 4.540 - _RESOURCE * resource; /* Handle to each system resource. */ 4.541 - char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */ 4.542 - int found = 0; /* Found any resource instances? */ 4.543 - 4.544 - _SBLIM_ENTER("EnumInstances"); 4.545 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 4.546 - _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 4.547 - _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL)))); 4.548 - _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace)); 4.549 - 4.550 - if (!xen_utils_validate_session(&session)) { 4.551 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon"); 4.552 - goto exit; 4.553 - } 4.554 - 4.555 - /* Get a handle to the list of system resources. */ 4.556 - if (!Xen_ComputerSystemSettingData_getResources(session, &resources)) { 4.557 - _SBLIM_TRACE(1,("--- _getResources() failed")); 4.558 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources"); 4.559 - goto exit; 4.560 + if(!xen_host_get_resident_vms(session->xen, &(resources->domains), 4.561 + session->host)) { 4.562 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 4.563 + ("--- Failed to retrieve list of domains from host")); 4.564 + _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR, 4.565 + xen_utils_trace_error(session->xen)); 4.566 + free(resources); 4.567 + return CMPI_RC_ERR_FAILED; 4.568 } 4.569 4.570 - /* Enumerate thru the list of system resources and return a CMPIInstance for each. */ 4.571 - while (Xen_ComputerSystemSettingData_getNextResource(session, resources, &resource)) { 4.572 - /* Create a new CMPIInstance to store this resource. */ 4.573 - CMPIInstance * instance = _CMNewInstance(_BROKER, namespace, _CLASSNAME, &status); 4.574 - if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instance)) { 4.575 - _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status.msg))); 4.576 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIInstance"); 4.577 - goto exit; 4.578 - } 4.579 + *res_list = (void *)resources; 4.580 + return CMPI_RC_OK; 4.581 +} 4.582 4.583 - /* Setup a filter to only return the desired properties. */ 4.584 - status = CMSetPropertyFilter(instance, properties, _KEYNAMES); 4.585 - if (status.rc != CMPI_RC_OK) { 4.586 - _SBLIM_TRACE(1, ("--- CMSetPropertyFilter() failed - %s", CMGetCharPtr(status.msg))); 4.587 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Cannot set property filter"); 4.588 - goto exit; 4.589 - } 4.590 - 4.591 - /* Set the instance property values from the resource data. */ 4.592 - if (!Xen_ComputerSystemSettingData_setInstanceFromResource(resource, instance, _BROKER)) { 4.593 - _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed")); 4.594 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data"); 4.595 - goto exit; 4.596 - } 4.597 4.598 - /* Free the resource data. */ 4.599 - if (!Xen_ComputerSystemSettingData_freeResource(resource)) { 4.600 - _SBLIM_TRACE(1,("--- _freeResource() failed")); 4.601 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data"); 4.602 - goto exit; 4.603 - } 4.604 - 4.605 - /* Return the CMPIInstance for this instance. */ 4.606 - _SBLIM_TRACE(3,("--- instance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, instance, NULL)))); 4.607 - CMReturnInstance(results, instance); 4.608 - found++; 4.609 +static void end(void *res_list) 4.610 +{ 4.611 + if (res_list) { 4.612 + xen_vm_set_free(((cs_resources *)res_list)->domains); 4.613 + free(res_list); 4.614 } 4.615 - 4.616 - _SBLIM_TRACE(2,("--- %d instances found", found)); 4.617 - CMReturnDone(results); 4.618 - 4.619 -exit: 4.620 - /* Free the list of system resources. */ 4.621 - if (!Xen_ComputerSystemSettingData_freeResources(resources)) { 4.622 - _SBLIM_TRACE(1,("--- _freeResources() failed")); 4.623 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources"); 4.624 - } 4.625 - 4.626 - _SBLIM_RETURNSTATUS(status); 4.627 } 4.628 4.629 -// ---------------------------------------------------------------------------- 4.630 -// GetInstance() 4.631 -// Return the instance data for the specified instance only. 4.632 -// ---------------------------------------------------------------------------- 4.633 -static CMPIStatus GetInstance( 4.634 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 4.635 - const CMPIContext * context, /* [in] Additional context info, if any. */ 4.636 - const CMPIResult * results, /* [out] Results of this operation. */ 4.637 - const CMPIObjectPath * reference, /* [in] Contains the target namespace, classname and object path. */ 4.638 - const char ** properties) /* [in] List of desired properties (NULL=all). */ 4.639 + 4.640 +/* Iterator to get the next resource from the resources list. */ 4.641 +static CMPIrc getnext(void *res_list, void **res, const char **properties) 4.642 { 4.643 - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ 4.644 - _RESOURCES * resources = NULL; /* Handle to the list of system resources. */ 4.645 - _RESOURCE * resource; /* Handle to the system resource. */ 4.646 - char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */ 4.647 - int found = 0; /* Found the target instance? */ 4.648 + cs_resources *resources = (cs_resources *)res_list; 4.649 + cs_resource *resource; 4.650 4.651 - _SBLIM_ENTER("GetInstance"); 4.652 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 4.653 - _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 4.654 - _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL)))); 4.655 - _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace)); 4.656 + (void)properties; 4.657 + 4.658 + if (resources == NULL) 4.659 + return CMPI_RC_ERR_FAILED; 4.660 4.661 - if (!xen_utils_validate_session(&session)) { 4.662 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon"); 4.663 - goto exit; 4.664 - } 4.665 - 4.666 - /* Get a handle to the list of system resources. */ 4.667 - if (!Xen_ComputerSystemSettingData_getResources(session, &resources)) { 4.668 - _SBLIM_TRACE(1,("--- _getResources() failed")); 4.669 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources"); 4.670 - goto exit; 4.671 - } 4.672 + /* Has end of resource list been reached? */ 4.673 + if (resources->cur_domain >= resources->domains->size) 4.674 + return CMPI_RC_ERR_NOT_FOUND; 4.675 4.676 - /* Get the target resource. */ 4.677 - found = Xen_ComputerSystemSettingData_getResourceForObjectPath(session, resources, &resource, reference); 4.678 - if (!found || (resource == NULL)) { 4.679 - _SBLIM_TRACE(1,("--- Target instance not found")); 4.680 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_FOUND, "Target instance not found"); 4.681 - goto exit; 4.682 - } 4.683 + /* Get memory for resource. */ 4.684 + resource = (cs_resource *)malloc(sizeof(cs_resource)); 4.685 + if (resource == NULL) 4.686 + return CMPI_RC_ERR_FAILED; 4.687 4.688 - /* Create a new CMPIInstance to store this resource. */ 4.689 - CMPIInstance * instance = _CMNewInstance(_BROKER, namespace, _CLASSNAME, &status); 4.690 - if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instance)) { 4.691 - _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status.msg))); 4.692 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIInstance"); 4.693 - goto exit; 4.694 - } 4.695 + resource->is_vm_record = 1; 4.696 + 4.697 + session->xen->ok = true; 4.698 4.699 - /* Setup a filter to only return the desired properties. */ 4.700 - status = CMSetPropertyFilter(instance, properties, _KEYNAMES); 4.701 - if (status.rc != CMPI_RC_OK) { 4.702 - _SBLIM_TRACE(1, ("--- CMSetPropertyFilter() failed - %s", CMGetCharPtr(status.msg))); 4.703 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Cannot set property filter"); 4.704 - goto exit; 4.705 - } 4.706 - 4.707 - /* Set the instance property values from the resource data. */ 4.708 - if (!Xen_ComputerSystemSettingData_setInstanceFromResource(resource, instance, _BROKER)) { 4.709 - _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed")); 4.710 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data"); 4.711 - goto exit; 4.712 - } 4.713 - 4.714 - /* Free the resource data. */ 4.715 - if (!Xen_ComputerSystemSettingData_freeResource(resource)) { 4.716 - _SBLIM_TRACE(1,("--- _freeResource() failed")); 4.717 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data"); 4.718 - goto exit; 4.719 + if (!xen_vm_get_record(session->xen, &(resource->u.vm_rec), 4.720 + resources->domains->contents[resources->cur_domain])) { 4.721 + free(resource); 4.722 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 4.723 + ("--- Failed to retrieve VM record from xend")); 4.724 + _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR, 4.725 + xen_utils_trace_error(session->xen)); 4.726 + return CMPI_RC_ERR_FAILED; 4.727 } 4.728 4.729 - /* Return the CMPIInstance for this instance. */ 4.730 - _SBLIM_TRACE(3,("--- instance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, instance, NULL)))); 4.731 - CMReturnInstance(results, instance); 4.732 - 4.733 - _SBLIM_TRACE(2,("--- instance found")); 4.734 - CMReturnDone(results); 4.735 - 4.736 -exit: 4.737 - /* Free the list of system resources. */ 4.738 - if (!Xen_ComputerSystemSettingData_freeResources(resources)) { 4.739 - _SBLIM_TRACE(1,("--- _freeResources() failed")); 4.740 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources"); 4.741 - } 4.742 - 4.743 - _SBLIM_RETURNSTATUS(status); 4.744 + resources->cur_domain++; 4.745 + *res = (void *)resource; 4.746 + return CMPI_RC_OK; 4.747 } 4.748 4.749 -// ---------------------------------------------------------------------------- 4.750 -// SetInstance() 4.751 -// Save modified instance data for the specified instance. 4.752 -// ---------------------------------------------------------------------------- 4.753 -static CMPIStatus SetInstance( 4.754 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 4.755 - const CMPIContext * context, /* [in] Additional context info, if any. */ 4.756 - const CMPIResult * results, /* [out] Results of this operation. */ 4.757 - const CMPIObjectPath * reference, /* [in] Contains the target namespace, classname and object path. */ 4.758 - const CMPIInstance * newinstance, /* [in] Contains the new instance data. */ 4.759 - const char **properties) 4.760 + 4.761 +static CMPIrc get(const void *res_id, void **res, const char **properties) 4.762 { 4.763 - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ 4.764 - _RESOURCES * resources = NULL; /* Handle to the list of system resources. */ 4.765 - _RESOURCE * resource; /* Handle to the system resource. */ 4.766 - char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */ 4.767 - int found = 0; /* Found the target instance? */ 4.768 + CMPIInstance *inst = (CMPIInstance *)res_id; 4.769 + CMPIData data; 4.770 + CMPIStatus status = {CMPI_RC_OK, NULL}; 4.771 + char *prop_val; 4.772 + char sys_name[MAX_SYSTEM_NAME_LEN]; 4.773 + cs_resource *resource; 4.774 + 4.775 + (void)properties; 4.776 + 4.777 + if (CMIsNullObject(inst) || res == NULL) 4.778 + return CMPI_RC_ERR_FAILED; 4.779 4.780 - _SBLIM_ENTER("SetInstance"); 4.781 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 4.782 - _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 4.783 - _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL)))); 4.784 - _SBLIM_TRACE(2, ("--- newinstance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, newinstance, NULL)))); 4.785 - _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace)); 4.786 + /* Obtain the target domain name from instance's "SystemName" property. */ 4.787 + data = CMGetProperty(inst, "InstanceID", &status); 4.788 + if ((status.rc != CMPI_RC_OK) || CMIsNullValue(data)) 4.789 + return CMPI_RC_ERR_FAILED; 4.790 + 4.791 + prop_val = CMGetCharPtr(data.value.string); 4.792 + if ((prop_val == NULL) || (*prop_val == '\0')) 4.793 + return CMPI_RC_ERR_FAILED; 4.794 + 4.795 + /* Extract the system name from InstanceID property. */ 4.796 + if (!_CMPIStrncpySystemNameFromID(sys_name, prop_val, MAX_SYSTEM_NAME_LEN)) 4.797 + return CMPI_RC_ERR_FAILED; 4.798 4.799 if (!xen_utils_validate_session(&session)) { 4.800 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon"); 4.801 - goto exit; 4.802 - } 4.803 - 4.804 - /* Get a handle to the list of system resources. */ 4.805 - if (!Xen_ComputerSystemSettingData_getResources(session, &resources)) { 4.806 - _SBLIM_TRACE(1,("--- _getResources() failed")); 4.807 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources"); 4.808 - goto exit; 4.809 - } 4.810 - 4.811 - /* Get the target resource. */ 4.812 - found = Xen_ComputerSystemSettingData_getResourceForObjectPath(session, resources, &resource, reference); 4.813 - if (!found || (resource == NULL)) { 4.814 - _SBLIM_TRACE(1,("--- Target instance not found")); 4.815 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_FOUND, "Target instance not found"); 4.816 - goto exit; 4.817 - } 4.818 - 4.819 - _SBLIM_TRACE(2,("--- instance found", found)); 4.820 - 4.821 - /* Update the target resource data with the new instance property values. */ 4.822 - int rc = Xen_ComputerSystemSettingData_setResourceFromInstance(resource, newinstance, _BROKER); 4.823 - 4.824 - /* Free the resource data. */ 4.825 - if (!Xen_ComputerSystemSettingData_freeResource(resource)) { 4.826 - _SBLIM_TRACE(1,("--- _freeResource() failed")); 4.827 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data"); 4.828 - goto exit; 4.829 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 4.830 + ("--- Unable to establish connection with Xend")); 4.831 + return CMPI_RC_ERR_FAILED; 4.832 } 4.833 - 4.834 - if (rc != 1) { 4.835 - if (rc == -1) { 4.836 - _SBLIM_TRACE(1,("--- _setResourceFromInstance() unsupported")); 4.837 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL); 4.838 - } else { 4.839 - _SBLIM_TRACE(1,("--- _setResourceFromInstance() failed")); 4.840 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set resource data from instance properties"); 4.841 - } 4.842 - goto exit; 4.843 - } 4.844 - 4.845 -exit: 4.846 - /* Free the list of system resources. */ 4.847 - if (!Xen_ComputerSystemSettingData_freeResources(resources)) { 4.848 - _SBLIM_TRACE(1,("--- _freeResources() failed")); 4.849 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources"); 4.850 - } 4.851 - 4.852 - _SBLIM_RETURNSTATUS(status); 4.853 -} 4.854 - 4.855 -// ---------------------------------------------------------------------------- 4.856 -// CreateInstance() 4.857 -// Create a new instance from the specified instance data. 4.858 -// ---------------------------------------------------------------------------- 4.859 -static CMPIStatus CreateInstance( 4.860 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 4.861 - const CMPIContext * context, /* [in] Additional context info, if any. */ 4.862 - const CMPIResult * results, /* [out] Results of this operation. */ 4.863 - const CMPIObjectPath * reference, /* [in] Contains the target namespace, classname and object path. */ 4.864 - const CMPIInstance * newinstance) /* [in] Contains the new instance data. */ 4.865 -{ 4.866 - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ 4.867 - _RESOURCES * resources = NULL; /* Handle to the list of system resources. */ 4.868 - _RESOURCE * resource; /* Handle to the system resource. */ 4.869 - char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */ 4.870 - int found = 0; /* Found the target instance? */ 4.871 - 4.872 - _SBLIM_ENTER("CreateInstance"); 4.873 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 4.874 - _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 4.875 - _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL)))); 4.876 - _SBLIM_TRACE(2, ("--- newinstance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, newinstance, NULL)))); 4.877 - _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace)); 4.878 - 4.879 - if (!xen_utils_validate_session(&session)) { 4.880 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon"); 4.881 - goto exit; 4.882 + 4.883 + /* Get the domain data for the target domain name. */ 4.884 + xen_vm_set *vms; 4.885 + if (!xen_vm_get_by_name_label(session->xen, &vms, sys_name)) { 4.886 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_WARNING, 4.887 + ("--- Failed to retrieve domain %s", sys_name)); 4.888 + _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR, 4.889 + xen_utils_trace_error(session->xen)); 4.890 + return CMPI_RC_ERR_FAILED; 4.891 } 4.892 4.893 - /* WORKAROUND FOR PEGASUS BUG?! reference does not contain object path, only namespace & classname. */ 4.894 - reference = CMGetObjectPath(newinstance, NULL); 4.895 - 4.896 - /* Get a handle to the list of system resources. */ 4.897 - if (!Xen_ComputerSystemSettingData_getResources(session, &resources)) { 4.898 - _SBLIM_TRACE(1,("--- _getResources() failed")); 4.899 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources"); 4.900 - goto exit; 4.901 - } 4.902 + assert(vms->size == 1); 4.903 4.904 - /* Get the target resource. */ 4.905 - found = Xen_ComputerSystemSettingData_getResourceForObjectPath(session, resources, &resource, reference); 4.906 + /* Get memory for resource. */ 4.907 + resource = (cs_resource *)malloc(sizeof(cs_resource)); 4.908 + if (resource == NULL) { 4.909 + xen_vm_set_free(vms); 4.910 + return CMPI_RC_ERR_FAILED; 4.911 + } 4.912 + 4.913 + resource->is_vm_record = 1; 4.914 4.915 - /* Free the resource data. */ 4.916 - if (!Xen_ComputerSystemSettingData_freeResource(resource)) { 4.917 - _SBLIM_TRACE(1,("--- _freeResource() failed")); 4.918 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data"); 4.919 - goto exit; 4.920 - } 4.921 - 4.922 - if (found) { 4.923 - _SBLIM_TRACE(1,("--- Target instance already exists")); 4.924 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_ALREADY_EXISTS, "Target instance already exists"); 4.925 - goto exit; 4.926 + if (!xen_vm_get_record(session->xen, 4.927 + &(resource->u.vm_rec), vms->contents[0])) { 4.928 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 4.929 + ("--- Failed to retrieve domain record for %s", sys_name)); 4.930 + _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR, 4.931 + xen_utils_trace_error(session->xen)); 4.932 + free(resource); 4.933 + xen_vm_set_free(vms); 4.934 + return CMPI_RC_ERR_FAILED; 4.935 } 4.936 4.937 - /* Create a new resource with the new instance property values. */ 4.938 - int rc = Xen_ComputerSystemSettingData_createResourceFromInstance(resources, &resource, newinstance, _BROKER); 4.939 - if (rc != 1) { 4.940 - if (rc == -1) { 4.941 - _SBLIM_TRACE(1,("--- _createResourceFromInstance() unsupported")); 4.942 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL); 4.943 - } else { 4.944 - _SBLIM_TRACE(1,("--- _createResourceFromInstance() failed")); 4.945 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to create resource data from instance properties"); 4.946 - } 4.947 - goto exit; 4.948 - } 4.949 + xen_vm_set_free(vms); 4.950 4.951 - /* Return the object path for the newly created instance. */ 4.952 - CMPIObjectPath * objectpath = CMGetObjectPath(newinstance, NULL); 4.953 - CMSetNameSpace(objectpath, namespace); 4.954 - CMReturnObjectPath(results, objectpath); 4.955 - CMReturnDone(results); 4.956 - 4.957 -exit: 4.958 - /* Free the list of system resources. */ 4.959 - if (!Xen_ComputerSystemSettingData_freeResources(resources)) { 4.960 - _SBLIM_TRACE(1,("--- _freeResources() failed")); 4.961 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources"); 4.962 - } 4.963 - 4.964 - _SBLIM_RETURNSTATUS(status); 4.965 + *res = (void *)resource; 4.966 + return CMPI_RC_OK; 4.967 } 4.968 4.969 -// ---------------------------------------------------------------------------- 4.970 -// DeleteInstance() 4.971 -// Delete or remove the specified instance from the system. 4.972 -// ---------------------------------------------------------------------------- 4.973 -static CMPIStatus DeleteInstance( 4.974 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 4.975 - const CMPIContext * context, /* [in] Additional context info, if any. */ 4.976 - const CMPIResult * results, /* [out] Results of this operation. */ 4.977 - const CMPIObjectPath * reference) /* [in] Contains the target namespace, classname and object path. */ 4.978 -{ 4.979 - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ 4.980 - _RESOURCES * resources = NULL; /* Handle to the list of system resources. */ 4.981 - _RESOURCE * resource; /* Handle to the system resource. */ 4.982 - char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */ 4.983 - int found = 0; /* Found the target instance? */ 4.984 4.985 - _SBLIM_ENTER("DeleteInstance"); 4.986 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 4.987 - _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 4.988 - _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL)))); 4.989 - _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace)); 4.990 +static void release(void *res) 4.991 +{ 4.992 + if (res) { 4.993 + cs_resource *resource = (cs_resource *)res; 4.994 + if (resource->is_vm_record) 4.995 + xen_vm_record_free(resource->u.vm_rec); 4.996 + free(resource); 4.997 + } 4.998 +} 4.999 4.1000 - if (!xen_utils_validate_session(&session)) { 4.1001 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon"); 4.1002 - goto exit; 4.1003 - } 4.1004 - 4.1005 - /* Get a handle to the list of system resources. */ 4.1006 - if (!Xen_ComputerSystemSettingData_getResources(session, &resources)) { 4.1007 - _SBLIM_TRACE(1,("--- _getResources() failed")); 4.1008 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources"); 4.1009 - goto exit; 4.1010 - } 4.1011 4.1012 - /* Get the target resource. */ 4.1013 - found = Xen_ComputerSystemSettingData_getResourceForObjectPath(session, resources, &resource, reference); 4.1014 - if (!found || (resource == NULL)) { 4.1015 - _SBLIM_TRACE(1,("--- Target instance not found")); 4.1016 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_FOUND, "Target instance not found"); 4.1017 - goto exit; 4.1018 - } 4.1019 - 4.1020 - _SBLIM_TRACE(2,("--- instance found", found)); 4.1021 - 4.1022 - /* Delete the target resource. */ 4.1023 - int rc = Xen_ComputerSystemSettingData_deleteResource(resources, resource); 4.1024 - 4.1025 - /* Free the resource data. */ 4.1026 - if (!Xen_ComputerSystemSettingData_freeResource(resource)) { 4.1027 - _SBLIM_TRACE(1,("--- _freeResource() failed")); 4.1028 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data"); 4.1029 - goto exit; 4.1030 - } 4.1031 +static CMPIrc add(const void *res_id, const void *res) 4.1032 +{ 4.1033 + (void)res_id; 4.1034 + (void)res; 4.1035 + 4.1036 + return CMPI_RC_ERR_NOT_SUPPORTED; /* unsupported */ 4.1037 +} 4.1038 4.1039 - if (rc != 1) { 4.1040 - if (rc == -1) { 4.1041 - _SBLIM_TRACE(1,("--- __deleteResource() unsupported")); 4.1042 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL); 4.1043 - } else { 4.1044 - _SBLIM_TRACE(1,("--- _deleteResource() failed")); 4.1045 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to delete resource"); 4.1046 - } 4.1047 - goto exit; 4.1048 - } 4.1049 4.1050 -exit: 4.1051 - /* Free the list of system resources. */ 4.1052 - if (!Xen_ComputerSystemSettingData_freeResources(resources)) { 4.1053 - _SBLIM_TRACE(1,("--- _freeResources() failed")); 4.1054 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources"); 4.1055 - } 4.1056 - 4.1057 - _SBLIM_RETURNSTATUS(status); 4.1058 +static CMPIrc delete(const void *res_id) 4.1059 +{ 4.1060 + (void)res_id; 4.1061 + 4.1062 + return CMPI_RC_ERR_NOT_SUPPORTED; /* unsupported */ 4.1063 } 4.1064 4.1065 4.1066 -// ---------------------------------------------------------------------------- 4.1067 -// ExecQuery() 4.1068 -// Return a list of all the instances that satisfy the specified query filter. 4.1069 -// ---------------------------------------------------------------------------- 4.1070 -static CMPIStatus ExecQuery( 4.1071 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 4.1072 - const CMPIContext * context, /* [in] Additional context info, if any. */ 4.1073 - const CMPIResult * results, /* [out] Results of this operation. */ 4.1074 - const CMPIObjectPath * reference, /* [in] Contains the target namespace and classname. */ 4.1075 - const char * language, /* [in] Name of the query language. */ 4.1076 - const char * query) /* [in] Text of the query written in the query language. */ 4.1077 +static CMPIrc modify(const void *res_id, const void *modified_res, 4.1078 + const char **properties) 4.1079 { 4.1080 - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ 4.1081 - char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */ 4.1082 + CMPIInstance *target_inst = (CMPIInstance *)res_id; 4.1083 + cs_resource *resource = (cs_resource *)modified_res; 4.1084 + CMPIInstance *modified_inst; 4.1085 + CMPIStatus status = {CMPI_RC_OK, NULL}; 4.1086 + CMPIData data; 4.1087 + char *inst_id; 4.1088 + char sys_name[MAX_SYSTEM_NAME_LEN]; 4.1089 + 4.1090 + if (CMIsNullObject(target_inst) || resource == NULL || 4.1091 + resource->is_vm_record) 4.1092 + return CMPI_RC_ERR_FAILED; 4.1093 + 4.1094 + modified_inst = resource->u.cmpi_inst; 4.1095 + 4.1096 + /* Get target resource */ 4.1097 + data = CMGetProperty(target_inst, "InstanceID", &status); 4.1098 + if ((status.rc != CMPI_RC_OK) || CMIsNullValue(data)) 4.1099 + return CMPI_RC_ERR_FAILED; 4.1100 + 4.1101 + inst_id = CMGetCharPtr(data.value.string); 4.1102 + if ((inst_id == NULL) || (*inst_id == '\0')) 4.1103 + return CMPI_RC_ERR_FAILED; 4.1104 + 4.1105 + /* Extract the system name from InstanceID property. */ 4.1106 + if (!_CMPIStrncpySystemNameFromID(sys_name, inst_id, MAX_SYSTEM_NAME_LEN)) 4.1107 + return CMPI_RC_ERR_FAILED; 4.1108 4.1109 - _SBLIM_ENTER("ExecQuery"); 4.1110 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 4.1111 - _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 4.1112 - _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL)))); 4.1113 - _SBLIM_TRACE(2, ("--- language=\"%s\"", language)); 4.1114 - _SBLIM_TRACE(2, ("--- query=\"%s\"", query)); 4.1115 - _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace)); 4.1116 + if (!xen_utils_validate_session(&session)) { 4.1117 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 4.1118 + ("--- Unable to establish connection with Xend")); 4.1119 + return CMPI_RC_ERR_FAILED; 4.1120 + } 4.1121 + 4.1122 + /* Get the domain data for the target domain name. */ 4.1123 + xen_vm_set *vms; 4.1124 + if (!xen_vm_get_by_name_label(session->xen, &vms, sys_name)) { 4.1125 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_WARNING, 4.1126 + ("--- Failed to retrieve domain %s", sys_name)); 4.1127 + _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR, 4.1128 + xen_utils_trace_error(session->xen)); 4.1129 + return CMPI_RC_ERR_FAILED; 4.1130 + } 4.1131 + 4.1132 + assert(vms->size == 1); 4.1133 4.1134 - /* EXECQUERY() IS NOT YET SUPPORTED FOR THIS CLASS */ 4.1135 - CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL); 4.1136 + xen_vm_record *vm_rec; 4.1137 + if (!xen_vm_get_record(session->xen, &vm_rec, vms->contents[0])) { 4.1138 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 4.1139 + ("--- Failed to retrieve domain record for %s", sys_name)); 4.1140 + _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR, 4.1141 + xen_utils_trace_error(session->xen)); 4.1142 + xen_vm_set_free(vms); 4.1143 + return CMPI_RC_ERR_FAILED; 4.1144 + } 4.1145 + 4.1146 + xen_vm_set_free(vms); 4.1147 4.1148 - CMReturnDone(results); 4.1149 - 4.1150 -exit: 4.1151 - _SBLIM_RETURNSTATUS(status); 4.1152 + /* Support modifying the following settings ... 4.1153 + * PV Specific: Kernel, RAMDisk, KernelOptions, BootLoader, BootLoaderOptions 4.1154 + * HVM Specific: BootOrder, apic, acpi, pae, usb, usbdevice, stdvga 4.1155 + * Common: localtime, OnPoweroff, OnReboot, OnCrash 4.1156 + */ 4.1157 + if (!modify_vm_settings(vm_rec, modified_inst, properties)) { 4.1158 + _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 4.1159 + ("--- Failed to modify settings for domain %s", sys_name)); 4.1160 + xen_vm_record_free(vm_rec); 4.1161 + return CMPI_RC_ERR_FAILED; 4.1162 + } 4.1163 + 4.1164 + xen_vm_record_free(vm_rec); 4.1165 + return CMPI_RC_OK; 4.1166 } 4.1167 4.1168 -// ---------------------------------------------------------------------------- 4.1169 -// Initialize() 4.1170 -// Perform any necessary initialization immediately after this provider is 4.1171 -// first loaded. 4.1172 -// ---------------------------------------------------------------------------- 4.1173 -static void Initialize( 4.1174 - CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ 4.1175 - const CMPIContext * context) /* [in] Additional context info, if any. */ 4.1176 + 4.1177 +/* Set CMPIInstance properties from the resource data. */ 4.1178 +static CMPIrc setproperties(CMPIInstance *inst, const void *res, 4.1179 + const char **properties) 4.1180 { 4.1181 - _SBLIM_ENTER("Initialize"); 4.1182 - _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName)); 4.1183 - // _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL)))); 4.1184 + char buf[1024]; 4.1185 + char *map_val; 4.1186 + int bool_val; 4.1187 + 4.1188 + (void)properties; 4.1189 + 4.1190 + if (res == NULL) 4.1191 + return CMPI_RC_ERR_FAILED; 4.1192 + 4.1193 + if (CMIsNullObject(inst)) 4.1194 + return CMPI_RC_ERR_FAILED; 4.1195 + 4.1196 + if (!((cs_resource *)res)->is_vm_record) 4.1197 + return CMPI_RC_ERR_FAILED; 4.1198 + 4.1199 + xen_vm_record *vm_rec = ((cs_resource *)res)->u.vm_rec; 4.1200 + 4.1201 + /* Set the CMPIInstance properties from the resource data. */ 4.1202 + snprintf(buf, 1024, "Xen:%s", vm_rec->name_label); 4.1203 + CMSetProperty(inst, "InstanceID", (CMPIValue *)buf, CMPI_chars); 4.1204 + 4.1205 + if ((map_val = 4.1206 + xen_utils_get_from_string_string_map(vm_rec->hvm_boot_params, "order"))) { 4.1207 + /* HVM settings */ 4.1208 + CMSetProperty(inst, "VirtualSystemType", 4.1209 + (CMPIValue *)"hvm-3.0-unknown", CMPI_chars); 4.1210 + CMSetProperty(inst, "BootOrder", (CMPIValue *)map_val, CMPI_chars); 4.1211 + 4.1212 + map_val = xen_utils_get_from_string_string_map(vm_rec->platform, "stdvga"); 4.1213 + bool_val = (map_val && !strcmp(map_val, "1")) ? 1 : 0; 4.1214 + CMSetProperty(inst, "stdvga", (CMPIValue *)&bool_val, CMPI_boolean); 4.1215 + 4.1216 + map_val = xen_utils_get_from_string_string_map(vm_rec->platform, "apic"); 4.1217 + bool_val = (map_val && !strcmp(map_val, "1")) ? 1 : 0; 4.1218 + CMSetProperty(inst, "apic", (CMPIValue *)&bool_val, CMPI_boolean); 4.1219 + 4.1220 + map_val = xen_utils_get_from_string_string_map(vm_rec->platform, "acpi"); 4.1221 + bool_val = (map_val && !strcmp(map_val, "1")) ? 1 : 0; 4.1222 + CMSetProperty(inst, "acpi", (CMPIValue *)&bool_val, CMPI_boolean); 4.1223 + 4.1224 + map_val = xen_utils_get_from_string_string_map(vm_rec->platform, "pae"); 4.1225 + bool_val = (map_val && !strcmp(map_val, "1")) ? 1 : 0; 4.1226 + CMSetProperty(inst, "pae", (CMPIValue *)&bool_val, CMPI_boolean); 4.1227 + 4.1228 + map_val = xen_utils_get_from_string_string_map(vm_rec->platform, "usb"); 4.1229 + bool_val = (map_val && !strcmp(map_val, "1")) ? 1 : 0; 4.1230 + CMSetProperty(inst, "usb", (CMPIValue *)&bool_val, CMPI_boolean); 4.1231 4.1232 - /* Initialized Xen session object. */ 4.1233 - if (session == NULL) 4.1234 - xen_utils_xen_init(&session); 4.1235 + map_val = xen_utils_get_from_string_string_map(vm_rec->platform, "usbdevice"); 4.1236 + if (map_val) 4.1237 + CMSetProperty(inst, "usbdevice", (CMPIValue *)map_val, CMPI_chars); 4.1238 + } 4.1239 + else { 4.1240 + /* PV settings */ 4.1241 + CMSetProperty(inst, "VirtualSystemType", 4.1242 + (CMPIValue *)"xen-3.0-unknown", CMPI_chars); 4.1243 + 4.1244 + if (vm_rec->pv_kernel && vm_rec->pv_kernel[0] != '\0') 4.1245 + CMSetProperty(inst, "Kernel", 4.1246 + (CMPIValue *)vm_rec->pv_kernel, CMPI_chars); 4.1247 + if (vm_rec->pv_ramdisk && vm_rec->pv_ramdisk[0] != '\0') 4.1248 + CMSetProperty(inst, "RAMDisk", 4.1249 + (CMPIValue *)vm_rec->pv_ramdisk, CMPI_chars); 4.1250 + if (vm_rec->pv_args && vm_rec->pv_args[0] != '\0') 4.1251 + CMSetProperty(inst, "KernelOptions", 4.1252 + (CMPIValue *)vm_rec->pv_args, CMPI_chars); 4.1253 + if (vm_rec->pv_bootloader && vm_rec->pv_bootloader[0] != '\0') 4.1254 + CMSetProperty(inst, "Bootloader", 4.1255 + (CMPIValue *)vm_rec->pv_bootloader, CMPI_chars); 4.1256 + if (vm_rec->pv_bootloader_args && vm_rec->pv_bootloader_args[0] != '\0') 4.1257 + CMSetProperty(inst, "BootloaderOptions", 4.1258 + (CMPIValue *)vm_rec->pv_bootloader_args, CMPI_chars); 4.1259 + } 4.1260 + 4.1261 + /* Common settings */ 4.1262 + CMSetProperty(inst, "ElementName", 4.1263 + (CMPIValue *)vm_rec->name_label, CMPI_chars); 4.1264 + CMSetProperty(inst, "VirtualSystemIdentifier", 4.1265 + (CMPIValue *)vm_rec->name_label, CMPI_chars); 4.1266 4.1267 - _SBLIM_RETURN(); 4.1268 + if (vm_rec->uuid) 4.1269 + CMSetProperty(inst, "UUID", (CMPIValue *)vm_rec->uuid, CMPI_chars); 4.1270 + 4.1271 + map_val = xen_utils_get_from_string_string_map(vm_rec->platform, "localtime"); 4.1272 + bool_val = (map_val && !strcmp(map_val, "1")) ? 1 : 0; 4.1273 + CMSetProperty(inst, "localtime", (CMPIValue *)&bool_val, CMPI_boolean); 4.1274 + 4.1275 + CMSetProperty(inst, "OnPoweroff", 4.1276 + (CMPIValue *)&(vm_rec->actions_after_shutdown), CMPI_uint16); 4.1277 + CMSetProperty(inst, "OnReboot", 4.1278 + (CMPIValue *)&(vm_rec->actions_after_reboot), CMPI_uint16); 4.1279 + CMSetProperty(inst, "OnCrash", 4.1280 + (CMPIValue *)&(vm_rec->actions_after_crash), CMPI_uint16); 4.1281 + 4.1282 + return CMPI_RC_OK; 4.1283 } 4.1284 4.1285 -// ============================================================================ 4.1286 -// CMPI INSTANCE PROVIDER FUNCTION TABLE SETUP 4.1287 -// ============================================================================ 4.1288 -CMInstanceMIStub( , Xen_ComputerSystemSettingData, _BROKER, Initialize(&mi, ctx)); 4.1289 + 4.1290 +/* 4.1291 + * Set resource data from the CMPIInstance properties. Only needs to 4.1292 + * be implemented if add() and/or modify() are supported. 4.1293 + */ 4.1294 +static CMPIrc extract(void **res, const CMPIInstance *inst, 4.1295 + const char **properties) 4.1296 +{ 4.1297 + cs_resource *resource; 4.1298 + 4.1299 + (void)properties; 4.1300 + 4.1301 + /* Get memory for resource. */ 4.1302 + resource = (cs_resource *)calloc(1, sizeof(cs_resource)); 4.1303 + if (resource == NULL) 4.1304 + return CMPI_RC_ERR_FAILED; 4.1305 + 4.1306 + resource->u.cmpi_inst = (CMPIInstance *)inst; 4.1307 + *res = (void *)resource; 4.1308 + return CMPI_RC_OK; 4.1309 +} 4.1310 + 4.1311 + 4.1312 +/* Get resource id from CMPIInstance properties. */ 4.1313 +static CMPIrc extractid(void **res_id, const CMPIInstance* inst) 4.1314 +{ 4.1315 + *res_id = (void *)inst; 4.1316 + return CMPI_RC_OK; 4.1317 +} 4.1318 + 4.1319 + 4.1320 +/* Release resource id created in resId4inst(). */ 4.1321 +static void releaseid(void* res_id) 4.1322 +{ 4.1323 + (void)res_id; 4.1324 +} 4.1325 + 4.1326 + 4.1327 +/* Setup CMPILIFY function tables and instance provider entry point.*/ 4.1328 +/* CMPILIFYInstanceMIStub(<CLASS>,<PROVIDER_NAME>,<keys>,<CMPIInstanceMI_HANDLE>) */ 4.1329 +static char * keys[] = {"InstanceID", NULL}; 4.1330 + 4.1331 +CMPILIFYInstanceMIStub(Xen_ComputerSystemSettingData, Xen_ComputerSystemSettingData, keys, mi)
5.1 --- a/src/Xen_ComputerSystemSettingData_Resource.c Tue Jul 17 16:10:55 2007 -0600 5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 5.3 @@ -1,256 +0,0 @@ 5.4 -// Copyright (C) 2006 IBM Corporation 5.5 -// 5.6 -// This library is free software; you can redistribute it and/or 5.7 -// modify it under the terms of the GNU Lesser General Public 5.8 -// License as published by the Free Software Foundation; either 5.9 -// version 2.1 of the License, or (at your option) any later version. 5.10 -// 5.11 -// This library is distributed in the hope that it will be useful, 5.12 -// but WITHOUT ANY WARRANTY; without even the implied warranty of 5.13 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 5.14 -// Lesser General Public License for more details. 5.15 -// 5.16 -// You should have received a copy of the GNU Lesser General Public 5.17 -// License along with this library; if not, write to the Free Software 5.18 -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 5.19 -// ============================================================================ 5.20 -// Authors: Dr. Gareth S. Bestor, <bestor@us.ibm.com> 5.21 -// Contributors: Jim Fehlig, <jfehlig@novell.com> 5.22 -// Description: 5.23 -// ============================================================================ 5.24 - 5.25 -#include <stdlib.h> 5.26 -#include <string.h> 5.27 -#include <assert.h> 5.28 - 5.29 -#include <xen_common.h> 5.30 -#include <xen_vm.h> 5.31 - 5.32 -#include "Xen_ComputerSystemSettingData_Resource.h" 5.33 - 5.34 -/* Include the required CMPI data types, function headers, and macros. */ 5.35 -#include "cmpidt.h" 5.36 -#include "cmpift.h" 5.37 -#include "cmpimacs.h" 5.38 - 5.39 -#include "xen_utils.h" 5.40 -#include "provider_common.h" 5.41 - 5.42 - 5.43 -static int get_platform_bool_val(_RESOURCE *resource, char *key) 5.44 -{ 5.45 - int i; 5.46 - 5.47 - xen_string_string_map *map = resource->platform; 5.48 - for (i = 0; i < map->size; i++) 5.49 - if (strcmp(map->contents[i].key, key) == 0) 5.50 - if (strcmp(map->contents[i].val, "1") == 0) 5.51 - return 1; 5.52 - 5.53 - return 0; 5.54 -} 5.55 - 5.56 -static char *get_platform_string_val(_RESOURCE *resource, char *key) 5.57 -{ 5.58 - int i; 5.59 - 5.60 - xen_string_string_map *map = resource->platform; 5.61 - for (i = 0; i < map->size; i++) 5.62 - if (strcmp(map->contents[i].key, key) == 0) 5.63 - return map->contents[i].val; 5.64 - 5.65 - return NULL; 5.66 -} 5.67 - 5.68 - 5.69 -// ---------------------------------------------------------------------------- 5.70 - 5.71 -/* Get a handle to the list of all system resources for this class. */ 5.72 -int Xen_ComputerSystemSettingData_getResources(xen_utils_session *session, 5.73 - _RESOURCES ** resources) 5.74 -{ 5.75 - return xen_utils_get_domain_resources(session, resources); 5.76 -} 5.77 - 5.78 -// ---------------------------------------------------------------------------- 5.79 - 5.80 -/* Free/deallocate/cleanup the resources list after use. */ 5.81 -int Xen_ComputerSystemSettingData_freeResources(_RESOURCES * resources) 5.82 -{ 5.83 - return xen_utils_free_domain_resources(resources); 5.84 -} 5.85 - 5.86 -// ---------------------------------------------------------------------------- 5.87 - 5.88 -/* Iterator to get the next resource from the resources list. */ 5.89 -int Xen_ComputerSystemSettingData_getNextResource(xen_utils_session *session, 5.90 - _RESOURCES * resources, 5.91 - _RESOURCE ** resource) 5.92 -{ 5.93 - return xen_utils_get_next_domain_resource(session, resources, resource); 5.94 -} 5.95 - 5.96 -// ---------------------------------------------------------------------------- 5.97 - 5.98 -/* Get the specific resource that matches the CMPI object path. */ 5.99 -int Xen_ComputerSystemSettingData_getResourceForObjectPath(xen_utils_session *session, 5.100 - _RESOURCES * resources, 5.101 - _RESOURCE ** resource, 5.102 - const CMPIObjectPath * objectpath) 5.103 -{ 5.104 - char *instId; 5.105 - char name[MAX_SYSTEM_NAME_LEN]; 5.106 - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ 5.107 - 5.108 - /* Check input params are valid. */ 5.109 - if (resources == NULL) return 0; 5.110 - if (CMIsNullObject(objectpath)) return 0; 5.111 - 5.112 - /* Obtain the target resource identifier from the CMPIObjectPath key(s). */ 5.113 - CMPIData iddata = CMGetKey(objectpath, "InstanceID", &status); 5.114 - if ((status.rc != CMPI_RC_OK) || CMIsNullValue(iddata)) return 0; 5.115 - 5.116 - /* Extract the id string from the CMPIString. */ 5.117 - instId = CMGetCharPtr(iddata.value.string); 5.118 - if ((instId== NULL) || (*instId == '\0')) return 0; 5.119 - 5.120 - /* Retrieve domain name from InstanceID. */ 5.121 - if (!_CMPIStrncpySystemNameFromID(name, instId, MAX_SYSTEM_NAME_LEN)) 5.122 - return 0; 5.123 - 5.124 - /* Get all the resource data for the target resource. */ 5.125 - xen_vm_set *vms; 5.126 - if (!xen_vm_get_by_name_label(session->xen, &vms, name)) { 5.127 - /* Error is in session object! */ 5.128 - *resource = NULL; 5.129 - return 0; 5.130 - } 5.131 - 5.132 - assert(vms->size == 1); 5.133 - if (!xen_vm_get_record(session->xen, resource, vms->contents[0])) { 5.134 - /* Error description in session object! */ 5.135 - xen_vm_set_free(vms); 5.136 - return 0; 5.137 - } 5.138 - 5.139 - xen_vm_set_free(vms); 5.140 - 5.141 - return 1; 5.142 -} 5.143 - 5.144 -// ---------------------------------------------------------------------------- 5.145 - 5.146 -/* Free/deallocate/cleanup the resource after use. */ 5.147 -int Xen_ComputerSystemSettingData_freeResource(_RESOURCE * resource) 5.148 -{ 5.149 - return xen_utils_free_domain_resource(resource); 5.150 -} 5.151 - 5.152 - 5.153 -// ---------------------------------------------------------------------------- 5.154 - 5.155 -/* Set the property values of a CMPI instance from a specific resource. */ 5.156 -int Xen_ComputerSystemSettingData_setInstanceFromResource(_RESOURCE * resource, 5.157 - const CMPIInstance * instance, 5.158 - const CMPIBroker * broker) 5.159 -{ 5.160 - char inst_id[1024]; 5.161 - int prop_bool_val; 5.162 - char *prop_string_val; 5.163 - char *hvm_boot_order; 5.164 - if (resource == NULL) return 0; 5.165 - if (CMIsNullObject(instance)) return 0; 5.166 - 5.167 - /* Set the CMPIInstance properties from the resource data. */ 5.168 - snprintf(inst_id, 1024, "Xen:%s", resource->name_label); 5.169 - CMSetProperty(instance, "InstanceID",(CMPIValue *)inst_id, CMPI_chars); 5.170 -// There must be an easier way of figuring out pv/hvm, but, until we figure that out, we will keep this - Raj 5.171 - if ((hvm_boot_order = xen_utils_get_from_string_string_map(resource->hvm_boot_params, "order"))) { 5.172 - /* HVM settings */ 5.173 - CMSetProperty(instance, "VirtualSystemType", (CMPIValue *)"hvm-3.0-unknown", CMPI_chars); 5.174 - CMSetProperty(instance, "BootOrder", (CMPIValue *)hvm_boot_order, CMPI_chars); 5.175 - prop_bool_val = get_platform_bool_val(resource, "stdvga"); 5.176 - CMSetProperty(instance, "stdvga", (CMPIValue *)&prop_bool_val, CMPI_boolean); 5.177 - 5.178 - prop_bool_val = get_platform_bool_val(resource, "apic"); 5.179 - CMSetProperty(instance, "apic", (CMPIValue *)&prop_bool_val, CMPI_boolean); 5.180 - 5.181 - prop_bool_val = get_platform_bool_val(resource, "acpi"); 5.182 - CMSetProperty(instance, "acpi", (CMPIValue *)&prop_bool_val, CMPI_boolean); 5.183 - 5.184 - prop_bool_val = get_platform_bool_val(resource, "pae"); 5.185 - CMSetProperty(instance, "pae", (CMPIValue *)&prop_bool_val, CMPI_boolean); 5.186 - 5.187 - prop_bool_val = get_platform_bool_val(resource, "usb"); 5.188 - CMSetProperty(instance, "usb", (CMPIValue *)&prop_bool_val, CMPI_boolean); 5.189 - 5.190 - prop_string_val = get_platform_string_val(resource, "usbdevice"); 5.191 - if (prop_string_val != NULL) 5.192 - CMSetProperty(instance, "usbdevice", (CMPIValue *)prop_string_val, CMPI_chars); 5.193 - } 5.194 - else { 5.195 - /* PV settings */ 5.196 - CMSetProperty(instance, "VirtualSystemType", (CMPIValue *)"xen-3.0-unknown", CMPI_chars); 5.197 - 5.198 - if (resource->pv_kernel && (resource->pv_kernel[0] != '\0')) 5.199 - CMSetProperty(instance, "Kernel", (CMPIValue *)resource->pv_kernel, CMPI_chars); 5.200 - if (resource->pv_ramdisk && (resource->pv_ramdisk[0] != '\0')) 5.201 - CMSetProperty(instance, "RAMDisk", (CMPIValue *)resource->pv_ramdisk, CMPI_chars); 5.202 - if (resource->pv_args && (resource->pv_args[0] != '\0')) 5.203 - CMSetProperty(instance, "KernelOptions" , (CMPIValue *)resource->pv_args, CMPI_chars); 5.204 - if (resource->pv_bootloader && (resource->pv_bootloader[0] != '\0')) 5.205 - CMSetProperty(instance, "Bootloader", (CMPIValue *)resource->pv_bootloader, CMPI_chars); 5.206 - if (resource->pv_bootloader_args && (resource->pv_bootloader_args[0] != '\0')) 5.207 - CMSetProperty(instance, "BootloaderOptions", (CMPIValue *)resource->pv_bootloader_args, CMPI_chars); 5.208 - } 5.209 - 5.210 - /* Common settings */ 5.211 - CMSetProperty(instance, "ElementName",(CMPIValue *)resource->name_label, CMPI_chars); 5.212 - CMSetProperty(instance, "VirtualSystemIdentifier",(CMPIValue *)resource->name_label, CMPI_chars); 5.213 - 5.214 - if (resource->uuid && (resource->uuid[0] != '\0')) 5.215 - CMSetProperty(instance, "UUID", (CMPIValue *)resource->uuid, CMPI_chars); 5.216 - 5.217 - prop_bool_val = get_platform_bool_val(resource, "localtime"); 5.218 - CMSetProperty(instance, "localtime", (CMPIValue *)&prop_bool_val, CMPI_boolean); 5.219 - 5.220 - CMSetProperty(instance, "OnPoweroff", (CMPIValue *)&(resource->actions_after_shutdown), CMPI_uint16); 5.221 - CMSetProperty(instance, "OnReboot", (CMPIValue *)&(resource->actions_after_reboot), CMPI_uint16); 5.222 - CMSetProperty(instance, "OnCrash", (CMPIValue *)&(resource->actions_after_crash), CMPI_uint16); 5.223 - 5.224 - return 1; 5.225 -} 5.226 - 5.227 -// ---------------------------------------------------------------------------- 5.228 - 5.229 -/* Delete the specified resource from the system. */ 5.230 -int Xen_ComputerSystemSettingData_deleteResource(_RESOURCES * resources, 5.231 - _RESOURCE * resource) 5.232 -{ 5.233 - /* Unsupported. */ 5.234 - return -1; 5.235 -} 5.236 - 5.237 -// ---------------------------------------------------------------------------- 5.238 - 5.239 -/* Modify the specified resource using the property values of a CMPI instance. */ 5.240 -int Xen_ComputerSystemSettingData_setResourceFromInstance(_RESOURCE * resource, 5.241 - const CMPIInstance * instance, 5.242 - const CMPIBroker * broker) 5.243 -{ 5.244 - /* Unsupported. */ 5.245 - return -1; 5.246 -} 5.247 - 5.248 -// ---------------------------------------------------------------------------- 5.249 - 5.250 -/* Create a new resource using the property values of a CMPI instance. */ 5.251 -int Xen_ComputerSystemSettingData_createResourceFromInstance(_RESOURCES * resources, 5.252 - _RESOURCE ** resource, 5.253 - const CMPIInstance * instance, 5.254 - const CMPIBroker * broker) 5.255 -{ 5.256 - /* Unsupported. */ 5.257 - return -1; 5.258 -} 5.259 -
6.1 --- a/src/Xen_ComputerSystemSettingData_Resource.h Tue Jul 17 16:10:55 2007 -0600 6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 6.3 @@ -1,100 +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 -// Contributors: Jim Fehlig, <jfehlig@novell.com> 6.22 -// Description: 6.23 -// ============================================================================ 6.24 - 6.25 -/* Include required libxen headers. */ 6.26 -#include <xen_common.h> 6.27 -#include <xen_vm.h> 6.28 - 6.29 -#include "xen_utils.h" 6.30 - 6.31 - 6.32 -/*** CUSTOMIZE FOR EACH PROVIDER ***/ 6.33 -/* DEFINE A HANDLE TO REPRESENT THE 'LIST' OF ALL SYSTEM RESOURCES. 6.34 - THE MAIN PROVIDER CODE DOES NOT NEED TO KNOW THE PARTICULARS OF HOW THIS 6.35 - LIST IS IMPLEMENTED - IT MAY BE AN ARRAY, LINKED LIST, FILE, ETC. 6.36 - THIS HANDLE IS PASSED INTO THE APPROPRIATE RESOURCE ACCESS METHODS WHEN 6.37 - ACCESSING/ITERATING/ADDING/REMOVING RESOURCES INSTANCES. */ 6.38 -typedef xen_domain_resources _RESOURCES; 6.39 - 6.40 -/*** CUSTOMIZE FOR EACH PROVIDER ***/ 6.41 -/* DEFINE A HANDLE TO BE USED FOR EACH INSTANCE OF A SYSTEM RESOURCE. 6.42 - THE MAIN PROVIDER CODE DOES NOT NEED TO KNOW THE PARTICULARS OF HOW EACH 6.43 - RESOURCE IS REPRESENTED, BUT TYPICALLY IT IS A STRUCTURE MIRRORING THE 6.44 - PROPERTIES IN THE CIM CLASS. THIS HANDLE IS PASSED BETWEEN THE RESOURCE 6.45 - ACCESS METHODS WHEN MANIPULATING SPECIFIC RESOURCE INSTANCES. */ 6.46 -typedef xen_vm_record _RESOURCE; 6.47 - 6.48 -/* NOTHING BELOW THIS LINE SHOULD NEED TO BE CHANGED. */ 6.49 - 6.50 -/* Include the required CMPI data types. */ 6.51 -#include "cmpidt.h" 6.52 - 6.53 -// ---------------------------------------------------------------------------- 6.54 -// Generic resource access methods for CMPI providers. 6.55 -// Return value: 6.56 -// -1 = Unsupported 6.57 -// 0 = Failed 6.58 -// 1 = OK 6.59 -// ---------------------------------------------------------------------------- 6.60 - 6.61 -/* Get a handle to the list of all system resources for this class. */ 6.62 -int Xen_ComputerSystemSettingData_getResources(xen_utils_session *session, 6.63 - _RESOURCES ** resources); 6.64 - 6.65 -/* Free/deallocate/cleanup the resources list after use. */ 6.66 -int Xen_ComputerSystemSettingData_freeResources(_RESOURCES * resources); 6.67 - 6.68 -/* Iterator to get the next resource from the resources list. */ 6.69 -int Xen_ComputerSystemSettingData_getNextResource(xen_utils_session *session, 6.70 - _RESOURCES * resources, 6.71 - _RESOURCE ** resource); 6.72 - 6.73 -/* Get the specific resource that matches the CMPI object path. */ 6.74 -int Xen_ComputerSystemSettingData_getResourceForObjectPath(xen_utils_session *session, 6.75 - _RESOURCES * resources, 6.76 - _RESOURCE ** resource, 6.77 - const CMPIObjectPath * objectpath); 6.78 - 6.79 -/* Free/deallocate/cleanup a resource after use. */ 6.80 -int Xen_ComputerSystemSettingData_freeResource(_RESOURCE * resource); 6.81 - 6.82 -/* Set the property values of a CMPI instance from a specific resource. */ 6.83 -int Xen_ComputerSystemSettingData_setInstanceFromResource(_RESOURCE * resource, 6.84 - const CMPIInstance * instance, 6.85 - const CMPIBroker * broker); 6.86 - 6.87 -// THE FOLLOWING METHODS MAY/NOT BE SUPPORTED BY THE SYSTEM FOR THIS CLASS 6.88 - 6.89 -/* Delete the specified resource from the system. */ 6.90 -int Xen_ComputerSystemSettingData_deleteResource(_RESOURCES * resources, 6.91 - _RESOURCE * resource); 6.92 - 6.93 -/* Modify the specified resource using the property values of a CMPI instance. */ 6.94 -int Xen_ComputerSystemSettingData_setResourceFromInstance(_RESOURCE * resource, 6.95 - const CMPIInstance * instance, 6.96 - const CMPIBroker * broker); 6.97 - 6.98 -/* Create a new resource using the property values of a CMPI instance. */ 6.99 -int Xen_ComputerSystemSettingData_createResourceFromInstance(_RESOURCES * resources, 6.100 - _RESOURCE ** resource, 6.101 - const CMPIInstance * instance, 6.102 - const CMPIBroker * broker); 6.103 -