# HG changeset patch # User root@hyperion.shrike # Node ID 25962bc0d49ad3a8d13ad221a9c291dadbb90530 # Parent c37b7ff52b4f4b0e876f16c48f92ede5a90ab2e5 This patch moves the providers to the changeset 14542. There are two open problems. I have not updated the providers to make use of the vdi structure. These places have been commented out with VBD<->VDI issues. The second issue is that the upstream has not yet accepted the model field for networkport With these patches, I am able to compile and enumerate with the providers. Signed-off-by: Raj Subrahmanian diff -r c37b7ff52b4f -r 25962bc0d49a src/Xen_ComputerSystemSettingData_Resource.c --- a/src/Xen_ComputerSystemSettingData_Resource.c Thu Mar 29 16:09:37 2007 -0600 +++ b/src/Xen_ComputerSystemSettingData_Resource.c Wed Apr 04 22:46:28 2007 -0400 @@ -157,18 +157,18 @@ int Xen_ComputerSystemSettingData_setIns char inst_id[1024]; int prop_bool_val; char *prop_string_val; - + char hvm_boot_order[1024]; if (resource == NULL) return 0; if (CMIsNullObject(instance)) return 0; /* Set the CMPIInstance properties from the resource data. */ snprintf(inst_id, 1024, "Xen:%s", resource->name_label); CMSetProperty(instance, "InstanceID",(CMPIValue *)inst_id, CMPI_chars); - - if (resource->hvm_boot && (resource->hvm_boot[0] != '\0')) { +// There must be an easier way of figuring out pv/hvm, but, until we figure that out, we will keep this - Raj + if (xen_utils_get_value_from_map(resource->hvm_boot_params, "order", hvm_boot_order)&& (hvm_boot_order[0] != '\0')) { /* HVM settings */ CMSetProperty(instance, "VirtualSystemType", (CMPIValue *)"hvm-3.0-unknown", CMPI_chars); - CMSetProperty(instance, "BootOrder", (CMPIValue *)resource->hvm_boot, CMPI_chars); + CMSetProperty(instance, "BootOrder", (CMPIValue *)hvm_boot_order, CMPI_chars); prop_bool_val = get_platform_bool_val(resource, "stdvga"); CMSetProperty(instance, "stdvga", (CMPIValue *)&prop_bool_val, CMPI_boolean); diff -r c37b7ff52b4f -r 25962bc0d49a src/Xen_ComputerSystem_Resource.c --- a/src/Xen_ComputerSystem_Resource.c Thu Mar 29 16:09:37 2007 -0600 +++ b/src/Xen_ComputerSystem_Resource.c Wed Apr 04 22:46:28 2007 -0400 @@ -170,13 +170,13 @@ int Xen_ComputerSystem_setInstanceFromRe CMSetProperty(instance, "Status",(CMPIValue *)"Suspended", CMPI_chars); break; - case XEN_VM_POWER_STATE_SHUTTINGDOWN: +/* case : statusvalue = 9; // "Stopping" enabledStateVal = 4; // "Shutting Down" requestedStateVal = 3; // "Disabled" CMSetProperty(instance, "Status",(CMPIValue *)"Stopping", CMPI_chars); break; - +*/ default: statusvalue = 0; // "Unknown" enabledStateVal = 0; // "Unknown" @@ -212,8 +212,9 @@ int Xen_ComputerSystem_deleteResource(xe * For now we'll treat this operation as synchronous and not wait * for shutdown before removing the domain. */ - if ((resource->power_state != XEN_VM_POWER_STATE_HALTED) || - (resource->power_state != XEN_VM_POWER_STATE_SHUTTINGDOWN)) { + if (resource->power_state != XEN_VM_POWER_STATE_HALTED) +// (resource->power_state != XEN_VM_POWER_STATE_SHUTTINGDOWN)) + { /* Initiate an asynchronous graceful shutdown of the domain's OS. Note - this will also eventually destroy the domain! */ if (!xen_vm_clean_shutdown(session->xen, resource->handle)) { diff -r c37b7ff52b4f -r 25962bc0d49a src/Xen_DiskSettingData_Resource.c --- a/src/Xen_DiskSettingData_Resource.c Thu Mar 29 16:09:37 2007 -0600 +++ b/src/Xen_DiskSettingData_Resource.c Wed Apr 04 22:46:28 2007 -0400 @@ -257,9 +257,10 @@ int Xen_DiskSettingData_setInstanceFromR else mode = "r"; - snprintf(buf, MAX_INSTANCEID_LEN, "%s,%s,%s", resource->image, resource->device, mode); +/* snprintf(buf, MAX_INSTANCEID_LEN, "%s,%s,%s", resource->image, resource->device, mode); CMSetProperty(instance, "DiskConfigInfo",(CMPIValue *)buf, CMPI_chars); - + VDI<->VBD issue +*/ /* * TODO: * PoolID, Weight, HostResource (mapped device in dom0) diff -r c37b7ff52b4f -r 25962bc0d49a src/Xen_Disk_Resource.c --- a/src/Xen_Disk_Resource.c Thu Mar 29 16:09:37 2007 -0600 +++ b/src/Xen_Disk_Resource.c Wed Apr 04 22:46:28 2007 -0400 @@ -241,7 +241,7 @@ int Xen_Disk_setInstanceFromResource(xen CMSetProperty(instance, "Name",(CMPIValue *)resource->device, CMPI_chars); - CMSetProperty(instance, "Device",(CMPIValue *)resource->image, CMPI_chars); + //CMSetProperty(instance, "Device",(CMPIValue *)resource->image, CMPI_chars); VDI <-> VBD issue CMSetProperty(instance, "DeviceName",(CMPIValue *)resource->device, CMPI_chars); char *mode; @@ -259,7 +259,7 @@ int Xen_Disk_setInstanceFromResource(xen CMSetProperty(instance, "Access",(CMPIValue *)&access, CMPI_uint16); char diskinfo[1024]; - snprintf(diskinfo, 1024, "%s,%s,%s", resource->image, resource->device, mode); + //snprintf(diskinfo, 1024, "%s,%s,%s", resource->image, resource->device, mode); VDI<->VBD issue CMSetProperty(instance, "DiskConfigInfo",(CMPIValue *)diskinfo, CMPI_chars); if (vm_rec->power_state != XEN_VM_POWER_STATE_HALTED) { diff -r c37b7ff52b4f -r 25962bc0d49a src/Xen_Memory.c --- a/src/Xen_Memory.c Thu Mar 29 16:09:37 2007 -0600 +++ b/src/Xen_Memory.c Wed Apr 04 22:46:28 2007 -0400 @@ -133,7 +133,7 @@ static CMPIStatus EnumInstanceNames( } /* Set the instance property values from the resource data. */ - if (!Xen_Memory_setInstanceFromResource(resource, instance, _BROKER)) { + if (!Xen_Memory_setInstanceFromResource(session, resource, instance, _BROKER)) { _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed")); CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data"); goto exit; @@ -227,7 +227,7 @@ static CMPIStatus EnumInstances( } /* Set the instance property values from the resource data. */ - if (!Xen_Memory_setInstanceFromResource(resource, instance, _BROKER)) { + if (!Xen_Memory_setInstanceFromResource(session, resource, instance, _BROKER)) { _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed")); CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data"); goto exit; @@ -319,7 +319,7 @@ static CMPIStatus GetInstance( } /* Set the instance property values from the resource data. */ - if (!Xen_Memory_setInstanceFromResource(resource, instance, _BROKER)) { + if (!Xen_Memory_setInstanceFromResource(session, resource, instance, _BROKER)) { _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed")); CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data"); goto exit; diff -r c37b7ff52b4f -r 25962bc0d49a src/Xen_MemorySettingData.c --- a/src/Xen_MemorySettingData.c Thu Mar 29 16:09:37 2007 -0600 +++ b/src/Xen_MemorySettingData.c Wed Apr 04 22:46:28 2007 -0400 @@ -132,7 +132,7 @@ static CMPIStatus EnumInstanceNames( } /* Set the instance property values from the resource data. */ - if (!Xen_MemorySettingData_setInstanceFromResource(resource, instance, _BROKER)) { + if (!Xen_MemorySettingData_setInstanceFromResource(session, resource, instance, _BROKER)) { _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed")); CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data"); goto exit; @@ -226,7 +226,7 @@ static CMPIStatus EnumInstances( } /* Set the instance property values from the resource data. */ - if (!Xen_MemorySettingData_setInstanceFromResource(resource, instance, _BROKER)) { + if (!Xen_MemorySettingData_setInstanceFromResource(session, resource, instance, _BROKER)) { _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed")); CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data"); goto exit; @@ -318,7 +318,7 @@ static CMPIStatus GetInstance( } /* Set the instance property values from the resource data. */ - if (!Xen_MemorySettingData_setInstanceFromResource(resource, instance, _BROKER)) { + if (!Xen_MemorySettingData_setInstanceFromResource(session, resource, instance, _BROKER)) { _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed")); CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data"); goto exit; diff -r c37b7ff52b4f -r 25962bc0d49a src/Xen_MemorySettingData_Resource.c --- a/src/Xen_MemorySettingData_Resource.c Thu Mar 29 16:09:37 2007 -0600 +++ b/src/Xen_MemorySettingData_Resource.c Wed Apr 04 22:46:28 2007 -0400 @@ -16,7 +16,8 @@ // ============================================================================ // Authors: Dr. Gareth S. Bestor, // Contributors: Jim Fehlig, -// Description: +// Raj Subrahmanian +// Description: // ============================================================================ #include @@ -25,7 +26,7 @@ #include #include - +#include #include "Xen_MemorySettingData_Resource.h" /* Include the required CMPI data types, function headers, and macros. */ @@ -125,7 +126,8 @@ int Xen_MemorySettingData_freeResource(_ // ---------------------------------------------------------------------------- /* Set the property values of a CMPI instance from a specific resource. */ -int Xen_MemorySettingData_setInstanceFromResource(_RESOURCE * resource, +int Xen_MemorySettingData_setInstanceFromResource(xen_utils_session *session, + _RESOURCE * resource, const CMPIInstance * instance, const CMPIBroker * broker) { @@ -146,8 +148,12 @@ int Xen_MemorySettingData_setInstanceFro int consumerVisibility = 2; /* 2 == Passed-Through */ CMSetProperty(instance, "ConsumerVisibility" , (CMPIValue *)&consumerVisibility, CMPI_uint16); - unsigned long long memory; - memory = resource->memory_actual; + int64_t memory; + // Get the memory_actual + if (resource->metrics->is_record) + memory=resource->metrics->u.record->memory_actual; + else + xen_vm_metrics_get_memory_actual(session, &memory, resource->metrics->u.handle);; CMSetProperty(instance, "Reservation",(CMPIValue *)&memory, CMPI_uint64); CMSetProperty(instance, "VirtualQuantity",(CMPIValue *)&memory, CMPI_uint64); memory = resource->memory_dynamic_max; diff -r c37b7ff52b4f -r 25962bc0d49a src/Xen_MemorySettingData_Resource.h --- a/src/Xen_MemorySettingData_Resource.h Thu Mar 29 16:09:37 2007 -0600 +++ b/src/Xen_MemorySettingData_Resource.h Wed Apr 04 22:46:28 2007 -0400 @@ -77,7 +77,8 @@ int Xen_MemorySettingData_freeResource(_ int Xen_MemorySettingData_freeResource(_RESOURCE * resource); /* Set the property values of a CMPI instance from a specific resource. */ -int Xen_MemorySettingData_setInstanceFromResource(_RESOURCE * resource, +int Xen_MemorySettingData_setInstanceFromResource(xen_utils_session *session, + _RESOURCE * resource, const CMPIInstance * instance, const CMPIBroker * broker); diff -r c37b7ff52b4f -r 25962bc0d49a src/Xen_Memory_Resource.c --- a/src/Xen_Memory_Resource.c Thu Mar 29 16:09:37 2007 -0600 +++ b/src/Xen_Memory_Resource.c Wed Apr 04 22:46:28 2007 -0400 @@ -17,11 +17,13 @@ // Authors: Dr. Gareth S. Bestor, // Tokunbo Adeshiyan, // Contributors: Jim Fehlig, +// Raj Subrahmanian // Description: // ============================================================================ #include #include +#include #include #include @@ -142,8 +144,10 @@ int Xen_Memory_freeResource(_RESOURCE * // ---------------------------------------------------------------------------- -/* Set the property values of a CMPI instance from a specific resource. */ -int Xen_Memory_setInstanceFromResource(_RESOURCE * resource, +/* Set the property values of a CMPI instance from a specific resource. + Added session parameter so that the memory_actual value can be picked up from xen_vm_metrics : Raj Subrahmanian 04/04/2007*/ +int Xen_Memory_setInstanceFromResource(xen_utils_session *session, + _RESOURCE * resource, const CMPIInstance * instance, const CMPIBroker * broker) { @@ -165,13 +169,17 @@ int Xen_Memory_setInstanceFromResource(_ uint64_t blocksize = 1; CMSetProperty(instance, "BlockSize", (CMPIValue *)&blocksize, CMPI_uint64); - unsigned long long blocks = resource->memory_dynamic_max; + int64_t blocks = resource->memory_dynamic_max; CMSetProperty(instance, "NumberOfBlocks", (CMPIValue *)&blocks, CMPI_uint64); - blocks = resource->memory_actual; + + // Get the memory_actual + if (resource->metrics->is_record) + blocks=resource->metrics->u.record->memory_actual; + else + xen_vm_metrics_get_memory_actual(session, &blocks, resource->metrics->u.handle); CMSetProperty(instance, "ConsumableBlocks", (CMPIValue *)&blocks, CMPI_uint64); - if ((resource->power_state == XEN_VM_POWER_STATE_RUNNING) || - (resource->power_state == XEN_VM_POWER_STATE_SHUTTINGDOWN)) + if (resource->power_state == XEN_VM_POWER_STATE_RUNNING) CMSetProperty(instance, "Status", (CMPIValue *)"OK", CMPI_chars); else CMSetProperty(instance, "Status", (CMPIValue *)"No Contact", CMPI_chars); diff -r c37b7ff52b4f -r 25962bc0d49a src/Xen_Memory_Resource.h --- a/src/Xen_Memory_Resource.h Thu Mar 29 16:09:37 2007 -0600 +++ b/src/Xen_Memory_Resource.h Wed Apr 04 22:46:28 2007 -0400 @@ -78,7 +78,8 @@ int Xen_Memory_freeResource(_RESOURCE * int Xen_Memory_freeResource(_RESOURCE * resource); /* Set the property values of a CMPI instance from a specific resource. */ -int Xen_Memory_setInstanceFromResource(_RESOURCE * resource, +int Xen_Memory_setInstanceFromResource(xen_utils_session *session, + _RESOURCE * resource, const CMPIInstance * instance, const CMPIBroker * broker); diff -r c37b7ff52b4f -r 25962bc0d49a src/Xen_NetworkPortSettingData_Resource.c --- a/src/Xen_NetworkPortSettingData_Resource.c Thu Mar 29 16:09:37 2007 -0600 +++ b/src/Xen_NetworkPortSettingData_Resource.c Wed Apr 04 22:46:28 2007 -0400 @@ -251,10 +251,10 @@ int Xen_NetworkPortSettingData_setInstan nic_config_info[0] = '\0'; if (resource->mac) snprintf(nic_config_info, 512, "mac=%s", resource->mac); - if (resource->model) { +/* if (resource->model) { strncat(nic_config_info, ",model=", 512 - strlen(nic_config_info)); strncat(nic_config_info, resource->model, 512 - strlen(nic_config_info)); - } + }Nic config info does have model*/ if (nic_config_info[0] != '\0') CMSetProperty(instance, "NICConfigInfo" , (CMPIValue *)nic_config_info, CMPI_chars); diff -r c37b7ff52b4f -r 25962bc0d49a src/Xen_NetworkPort_Resource.c --- a/src/Xen_NetworkPort_Resource.c Thu Mar 29 16:09:37 2007 -0600 +++ b/src/Xen_NetworkPort_Resource.c Wed Apr 04 22:46:28 2007 -0400 @@ -262,10 +262,10 @@ int Xen_NetworkPort_setInstanceFromResou nic_config_info[0] = '\0'; if (resource->mac) snprintf(nic_config_info, 512, "mac=%s", resource->mac); - if (resource->model) { + /*if (resource->model) { strncat(nic_config_info, ",model=", 512 - strlen(nic_config_info)); strncat(nic_config_info, resource->model, 512 - strlen(nic_config_info)); - } + } NIC config info does not have model*/ if (nic_config_info[0] != '\0') CMSetProperty(instance, "NICConfigInfo" , (CMPIValue *)nic_config_info, CMPI_chars); diff -r c37b7ff52b4f -r 25962bc0d49a src/Xen_OperatingSystem.c --- a/src/Xen_OperatingSystem.c Thu Mar 29 16:09:37 2007 -0600 +++ b/src/Xen_OperatingSystem.c Wed Apr 04 22:46:28 2007 -0400 @@ -134,7 +134,7 @@ static CMPIStatus EnumInstanceNames( } /* Set the instance property values from the resource data. */ - if (!Xen_OperatingSystem_setInstanceFromResource(resource, instance, _BROKER)) { + if (!Xen_OperatingSystem_setInstanceFromResource(session,resource, instance, _BROKER)) { _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed")); CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data"); goto exit; @@ -228,7 +228,7 @@ static CMPIStatus EnumInstances( } /* Set the instance property values from the resource data. */ - if (!Xen_OperatingSystem_setInstanceFromResource(resource, instance, _BROKER)) { + if (!Xen_OperatingSystem_setInstanceFromResource(session, resource, instance, _BROKER)) { _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed")); CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data"); goto exit; @@ -320,7 +320,7 @@ static CMPIStatus GetInstance( } /* Set the instance property values from the resource data. */ - if (!Xen_OperatingSystem_setInstanceFromResource(resource, instance, _BROKER)) { + if (!Xen_OperatingSystem_setInstanceFromResource(session,resource, instance, _BROKER)) { _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed")); CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data"); goto exit; diff -r c37b7ff52b4f -r 25962bc0d49a src/Xen_OperatingSystem_Resource.c --- a/src/Xen_OperatingSystem_Resource.c Thu Mar 29 16:09:37 2007 -0600 +++ b/src/Xen_OperatingSystem_Resource.c Wed Apr 04 22:46:28 2007 -0400 @@ -26,6 +26,7 @@ #include #include +#include #include "Xen_OperatingSystem_Resource.h" @@ -116,7 +117,8 @@ int Xen_OperatingSystem_freeResource(_RE // ---------------------------------------------------------------------------- /* Set the property values of a CMPI instance from a specific resource. */ -int Xen_OperatingSystem_setInstanceFromResource(_RESOURCE * resource, +int Xen_OperatingSystem_setInstanceFromResource(xen_utils_session *session, + _RESOURCE * resource, const CMPIInstance * instance, const CMPIBroker * broker) { @@ -171,12 +173,12 @@ int Xen_OperatingSystem_setInstanceFromR // Status is just a string (and deprecated), so just say Suspended CMSetProperty(instance, "Status",(CMPIValue *)"Suspended", CMPI_chars); break; - +/* case XEN_VM_POWER_STATE_SHUTTINGDOWN: statusvalue = 9; // "Stopping" CMSetProperty(instance, "Status",(CMPIValue *)"Stopping", CMPI_chars); break; - +*/ default: statusvalue = 0; // "Unknown" CMSetProperty(instance, "Status",(CMPIValue *)"No Contact", CMPI_chars); @@ -192,8 +194,15 @@ int Xen_OperatingSystem_setInstanceFromR /* * TODO: * What memory_* field of xen_vm_record should we use here? - */ - CMSetProperty(instance, "TotalVisibleMemorySize", (CMPIValue *)&(resource->memory_actual), CMPI_uint64); + */ + int64_t memory=0; + // Get the memory_actual + if (resource->metrics->is_record) + memory=resource->metrics->u.record->memory_actual; + else + xen_vm_metrics_get_memory_actual(session, &memory, resource->metrics->u.handle); + + CMSetProperty(instance, "TotalVisibleMemorySize", (CMPIValue *)&(memory), CMPI_uint64); return 1; } diff -r c37b7ff52b4f -r 25962bc0d49a src/Xen_OperatingSystem_Resource.h --- a/src/Xen_OperatingSystem_Resource.h Thu Mar 29 16:09:37 2007 -0600 +++ b/src/Xen_OperatingSystem_Resource.h Wed Apr 04 22:46:28 2007 -0400 @@ -77,7 +77,8 @@ int Xen_OperatingSystem_freeResource(_RE int Xen_OperatingSystem_freeResource(_RESOURCE * resource); /* Set the property values of a CMPI instance from a specific resource. */ -int Xen_OperatingSystem_setInstanceFromResource(_RESOURCE * resource, +int Xen_OperatingSystem_setInstanceFromResource(xen_utils_session *session, + _RESOURCE * resource, const CMPIInstance * instance, const CMPIBroker * broker); diff -r c37b7ff52b4f -r 25962bc0d49a src/Xen_ProcessorSettingData.c --- a/src/Xen_ProcessorSettingData.c Thu Mar 29 16:09:37 2007 -0600 +++ b/src/Xen_ProcessorSettingData.c Wed Apr 04 22:46:28 2007 -0400 @@ -16,6 +16,7 @@ // ============================================================================ // Authors: Dr. Gareth S. Bestor, // Contributors: Jim Fehlig, +// Raj Subrahmanian // Description: // ============================================================================ @@ -132,7 +133,7 @@ static CMPIStatus EnumInstanceNames( } /* Set the instance property values from the resource data. */ - if (!Xen_ProcessorSettingData_setInstanceFromResource(resource, instance, _BROKER)) { + if (!Xen_ProcessorSettingData_setInstanceFromResource(session, resource, instance, _BROKER)) { _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed")); CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data"); goto exit; @@ -226,7 +227,7 @@ static CMPIStatus EnumInstances( } /* Set the instance property values from the resource data. */ - if (!Xen_ProcessorSettingData_setInstanceFromResource(resource, instance, _BROKER)) { + if (!Xen_ProcessorSettingData_setInstanceFromResource(session, resource, instance, _BROKER)) { _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed")); CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data"); goto exit; @@ -318,7 +319,7 @@ static CMPIStatus GetInstance( } /* Set the instance property values from the resource data. */ - if (!Xen_ProcessorSettingData_setInstanceFromResource(resource, instance, _BROKER)) { + if (!Xen_ProcessorSettingData_setInstanceFromResource(session, resource, instance, _BROKER)) { _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed")); CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data"); goto exit; diff -r c37b7ff52b4f -r 25962bc0d49a src/Xen_ProcessorSettingData_Resource.c --- a/src/Xen_ProcessorSettingData_Resource.c Thu Mar 29 16:09:37 2007 -0600 +++ b/src/Xen_ProcessorSettingData_Resource.c Wed Apr 04 22:46:28 2007 -0400 @@ -16,6 +16,7 @@ // ============================================================================ // Authors: Dr. Gareth S. Bestor, // Contributors: Jim Fehlig, +// Raj Subrahmanian // Description: // ============================================================================ @@ -25,6 +26,7 @@ #include #include +#include #include "Xen_ProcessorSettingData_Resource.h" @@ -121,8 +123,11 @@ int Xen_ProcessorSettingData_freeResourc // ---------------------------------------------------------------------------- -/* Set the property values of a CMPI instance from a specific resource. */ -int Xen_ProcessorSettingData_setInstanceFromResource(_RESOURCE * resource, +/* Set the property values of a CMPI instance from a specific resource. + We also pass in the session object so that the metrics class can be accessed when required. +*/ +int Xen_ProcessorSettingData_setInstanceFromResource(xen_utils_session *session, + _RESOURCE * resource, const CMPIInstance * instance, const CMPIBroker * broker) { @@ -143,12 +148,15 @@ int Xen_ProcessorSettingData_setInstance int consumerVisibility = 3; /* 3 == Virtualized */ CMSetProperty(instance, "ConsumerVisibility" , (CMPIValue *)&consumerVisibility, CMPI_uint16); - unsigned long long cpus = 1; + int64_t cpus = 1; CMSetProperty(instance, "Reservation",(CMPIValue *)&cpus, CMPI_uint64); CMSetProperty(instance, "Limit",(CMPIValue *)&cpus, CMPI_uint64); CMSetProperty(instance, "AllocationUnits",(CMPIValue *)"Cores", CMPI_chars); - cpus = resource->vcpus_number; - CMSetProperty(instance, "VirtualQuantity",(CMPIValue *)&cpus, CMPI_uint64); + if (resource->metrics->is_record) + cpus=resource->metrics->u.record->vcpus_number; + else + xen_vm_metrics_get_vcpus_number(session, &cpus, resource->metrics->u.handle); + CMSetProperty(instance, "VirtualQuantity",(CMPIValue *)&cpus, CMPI_uint64); int alloctype = 1; CMSetProperty(instance, "AutomaticAllocation" , (CMPIValue *)&alloctype, CMPI_boolean); diff -r c37b7ff52b4f -r 25962bc0d49a src/Xen_ProcessorSettingData_Resource.h --- a/src/Xen_ProcessorSettingData_Resource.h Thu Mar 29 16:09:37 2007 -0600 +++ b/src/Xen_ProcessorSettingData_Resource.h Wed Apr 04 22:46:28 2007 -0400 @@ -76,7 +76,8 @@ int Xen_ProcessorSettingData_freeResourc int Xen_ProcessorSettingData_freeResource(_RESOURCE * resource); /* Set the property values of a CMPI instance from a specific resource. */ -int Xen_ProcessorSettingData_setInstanceFromResource(_RESOURCE * resource, +int Xen_ProcessorSettingData_setInstanceFromResource(xen_utils_session *session, + _RESOURCE * resource, const CMPIInstance * instance, const CMPIBroker * broker); diff -r c37b7ff52b4f -r 25962bc0d49a src/Xen_Processor_Resource.c --- a/src/Xen_Processor_Resource.c Thu Mar 29 16:09:37 2007 -0600 +++ b/src/Xen_Processor_Resource.c Wed Apr 04 22:46:28 2007 -0400 @@ -17,6 +17,7 @@ // Authors: Dr. Gareth S. Bestor, // Tokunbo Adeshiyan, // Contributors: Jim Fehlig, +// Raj Subrahmanian // Description: // ============================================================================ @@ -25,6 +26,7 @@ #include #include +#include #include "Xen_Processor_Resource.h" @@ -72,12 +74,14 @@ int Xen_Processor_freeResources(_RESOURC } // ---------------------------------------------------------------------------- - +// This function was changed to extract the vcpus_number value from the metrics structure rather +// Raj - 04/04/2007 /* Iterator to get the next resource from the resources list. */ int Xen_Processor_getNextResource(xen_utils_session *session, _RESOURCES * resources, _RESOURCE ** resource) { + int64_t vcpus_number; if (resources == NULL) return 0; /* Check if reached the end of the list of Xen domain names. */ @@ -97,8 +101,13 @@ int Xen_Processor_getNextResource(xen_ut resources->currentprocessornum++; /* Return success while there are still processor devices for this domain. */ - if (resources->currentprocessornum <= (*resource)->vcpus_number) - return 1; + // Get the vcpus_number + if ((*resource)->metrics->is_record) + vcpus_number=(*resource)->metrics->u.record->vcpus_number; + else + xen_vm_metrics_get_vcpus_number(session, &vcpus_number, (*resource)->metrics->u.handle); + if (resources->currentprocessornum <= vcpus_number) + return 1; NextDomain: /* All processors in this domain have been exhausted. */ diff -r c37b7ff52b4f -r 25962bc0d49a src/Xen_VirtualSystemManagementCapabilities.c --- a/src/Xen_VirtualSystemManagementCapabilities.c Thu Mar 29 16:09:37 2007 -0600 +++ b/src/Xen_VirtualSystemManagementCapabilities.c Wed Apr 04 22:46:28 2007 -0400 @@ -15,7 +15,7 @@ // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // ============================================================================ // Authors: Jim Fehlig, -// Contributors: +// Contributors: // Description: A class used to represent the capabilities of // Xen_VirtualSystemManagementService, e.g. which // methods are supported. diff -r c37b7ff52b4f -r 25962bc0d49a src/Xen_VirtualSystemManagementService.c --- a/src/Xen_VirtualSystemManagementService.c Thu Mar 29 16:09:37 2007 -0600 +++ b/src/Xen_VirtualSystemManagementService.c Wed Apr 04 22:46:28 2007 -0400 @@ -16,6 +16,7 @@ // ============================================================================ // Authors: Dr. Gareth S. Bestor, // Contributors: Jim Fehlig, +// Raj Subrahmanian // Description: // ============================================================================ @@ -34,6 +35,7 @@ #include #include #include +#include #include /* Include utility functions */ @@ -1428,7 +1430,7 @@ static int add_resource_to_vm(xen_vm_rec } /* Adding cpus means just that - adding to existing amount */ - uint64_t cpus = propertyvalue.value.uint64 + vmRec->vcpus_number; + uint64_t cpus = propertyvalue.value.uint64 + vmRec->vcpus_number; /* * TODO: * 1. CPU weights and other scheduling parameters? @@ -1688,8 +1690,8 @@ static int vssd2xenconfig(CMPIInstance * "No BootOrder specified for HVM guest"); return 0; } - vm_rec->hvm_boot = strdup(CMGetCharPtr(propertyvalue.value.string)); - + //vm_rec->hvm_boot_params = strdup(CMGetCharPtr(propertyvalue.value.string)); + add_strings_to_map("order", CMGetCharPtr(propertyvalue.value.string),&(vm_rec->hvm_boot_params )); /* Default stdvga to 0 */ plat_val = "0"; propertyvalue = CMGetProperty(vssd, "stdvga", status); @@ -1794,7 +1796,7 @@ static int vssd2xenconfig(CMPIInstance * return 1; } - +// Look for vcpus_number in the metrics structure. static int proc_rasd2vmconfig(CMPIInstance *proc_rasd, xen_vm_record *vm_rec, CMPIStatus *status) { @@ -1806,10 +1808,13 @@ static int proc_rasd2vmconfig(CMPIInstan * TODO: * 1. Handle defaults if processors not specified. * 2. CPU weights and other scheduling parameters? + */ - vm_rec->vcpus_number = propertyvalue.value.uint64; - - return 1; + if (vm_rec->metrics->is_record) + vm_rec->metrics->u.record->vcpus_number=propertyvalue.value.uint64; + else + xen_vm_metrics_set_vcpus_number(session, propertyvalue.value.uint64, vm_rec->metrics->u.handle); + return 1; } return 0; @@ -1866,7 +1871,7 @@ static int disk_rasd2vmconfig(CMPIInstan free(string); goto Error; } - (*vbd_rec)->image = strdup(tok); +// (*vbd_rec)->image = strdup(tok); VDI<->BBD issue if ((tok = strtok_r(NULL, ",", &next_tok)) == NULL) { _SBLIM_TRACE(1,("--- Malformed DiskConfigInfo property in disk setting data")); @@ -1888,7 +1893,7 @@ static int disk_rasd2vmconfig(CMPIInstan (*vbd_rec)->mode = XEN_VBD_MODE_RO; free(string); - _SBLIM_TRACE(2,("--- uname = %s", (*vbd_rec)->image)); + //_SBLIM_TRACE(2,("--- uname = %s", (*vbd_rec)->image)); _SBLIM_TRACE(2,("--- dev = %s", (*vbd_rec)->device)); _SBLIM_TRACE(2,("--- mode = %s", (*vbd_rec)->mode == XEN_VBD_MODE_RW ? "RW" : "RO")); @@ -1935,8 +1940,8 @@ static int nic_rasd2vmconfig(CMPIInstanc while (tok) { if (strncmp(tok, "mac", 3) == 0) (*vif_rec)->mac = strdup(tok + 4); - else if (strncmp(tok, "model", 5) == 0) - (*vif_rec)->model = strdup(tok + 6); +/* else if (strncmp(tok, "model", 5) == 0) + (*vif_rec)->model = strdup(tok + 6); Commented off to compile the code*/ tok = strtok_r(NULL, ",", &next_tok); } diff -r c37b7ff52b4f -r 25962bc0d49a src/Xen_VirtualSystemManagementService_Resource.c --- a/src/Xen_VirtualSystemManagementService_Resource.c Thu Mar 29 16:09:37 2007 -0600 +++ b/src/Xen_VirtualSystemManagementService_Resource.c Wed Apr 04 22:46:28 2007 -0400 @@ -16,6 +16,7 @@ // ============================================================================ // Authors: Dr. Gareth S. Bestor, // Contributors: Jim Fehlig, + // Description: // ============================================================================ diff -r c37b7ff52b4f -r 25962bc0d49a src/xen_utils.c --- a/src/xen_utils.c Thu Mar 29 16:09:37 2007 -0600 +++ b/src/xen_utils.c Wed Apr 04 22:46:28 2007 -0400 @@ -15,7 +15,7 @@ // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // ============================================================================ // Authors: Jim Fehlig, -// Contributors: +// Contributors: Raj Subrahmanian // Description: Utilitiy functions built on top of libxen for use in all // providers. // ============================================================================ @@ -682,3 +682,25 @@ int xen_utils_is_domain_active(xen_utils return 1; } +/* + * Extract the value from a string map given a key + * +*/ +int xen_utils_get_value_from_map(xen_string_string_map *map, const char *key, char *val) +{ + int i=0; + // Make sure you have a good value + if(!map) return 0; + // String map is empty + if (map->size==0) return 0; + while (isize) + { // Found key + if (strcmp(key, map->contents[i].key)==0) + { + val=strdup(map->contents[i].val); + return 1; + } + i++; + } + return 0; +} \ No newline at end of file diff -r c37b7ff52b4f -r 25962bc0d49a src/xen_utils.h --- a/src/xen_utils.h Thu Mar 29 16:09:37 2007 -0600 +++ b/src/xen_utils.h Wed Apr 04 22:46:28 2007 -0400 @@ -179,5 +179,12 @@ int xen_utils_is_domain_active(xen_utils int *isActive); +/* + * Extract the value from a string map given a key + * +*/ +int xen_utils_get_value_from_map(xen_string_string_map *map, const char *key, char *val); + + #endif /* __XEN_UTILS_H__ */