os-cmpi-xen

changeset 99:7ca3bbf0810a

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 <raj.subrahmanian@unisys.com>
author Jim Fehlig <jfehlig@novell.com>
date Thu Apr 19 15:50:09 2007 -0600 (2007-04-19)
parents aad84ea2d09e
children 891f3ab3933b
files src/Xen_ComputerSystemSettingData_Resource.c src/Xen_ComputerSystem_Resource.c src/Xen_DiskSettingData_Resource.c src/Xen_Disk_Resource.c src/Xen_Memory.c src/Xen_MemorySettingData.c src/Xen_MemorySettingData_Resource.c src/Xen_MemorySettingData_Resource.h src/Xen_Memory_Resource.c src/Xen_Memory_Resource.h src/Xen_NetworkPortSettingData_Resource.c src/Xen_NetworkPort_Resource.c src/Xen_OperatingSystem.c src/Xen_OperatingSystem_Resource.c src/Xen_OperatingSystem_Resource.h src/Xen_ProcessorSettingData.c src/Xen_ProcessorSettingData_Resource.c src/Xen_ProcessorSettingData_Resource.h src/Xen_Processor_Resource.c src/Xen_VirtualSystemManagementCapabilities.c src/Xen_VirtualSystemManagementService.c src/Xen_VirtualSystemManagementService_Resource.c src/xen_utils.c src/xen_utils.h
line diff
     1.1 --- a/src/Xen_ComputerSystemSettingData_Resource.c	Thu Apr 19 15:45:31 2007 -0600
     1.2 +++ b/src/Xen_ComputerSystemSettingData_Resource.c	Thu Apr 19 15:50:09 2007 -0600
     1.3 @@ -157,18 +157,18 @@ int Xen_ComputerSystemSettingData_setIns
     1.4     char inst_id[1024];
     1.5     int prop_bool_val;
     1.6     char *prop_string_val;
     1.7 -
     1.8 +   char hvm_boot_order[1024];
     1.9     if (resource == NULL) return 0;
    1.10     if (CMIsNullObject(instance)) return 0;
    1.11  
    1.12     /* Set the CMPIInstance properties from the resource data. */
    1.13     snprintf(inst_id, 1024, "Xen:%s", resource->name_label);
    1.14     CMSetProperty(instance, "InstanceID",(CMPIValue *)inst_id, CMPI_chars);
    1.15 -
    1.16 -   if (resource->hvm_boot && (resource->hvm_boot[0] != '\0')) {
    1.17 +// There must be an easier way of figuring out pv/hvm, but, until we figure that out, we will keep this - Raj
    1.18 +   if (xen_utils_get_value_from_map(resource->hvm_boot_params, "order", hvm_boot_order)&& (hvm_boot_order[0] != '\0')) {
    1.19        /* HVM settings */
    1.20        CMSetProperty(instance, "VirtualSystemType", (CMPIValue *)"hvm-3.0-unknown", CMPI_chars);
    1.21 -      CMSetProperty(instance, "BootOrder", (CMPIValue *)resource->hvm_boot, CMPI_chars);
    1.22 +      CMSetProperty(instance, "BootOrder", (CMPIValue *)hvm_boot_order, CMPI_chars);
    1.23        prop_bool_val = get_platform_bool_val(resource, "stdvga");
    1.24        CMSetProperty(instance, "stdvga", (CMPIValue *)&prop_bool_val, CMPI_boolean);
    1.25  
     2.1 --- a/src/Xen_ComputerSystem_Resource.c	Thu Apr 19 15:45:31 2007 -0600
     2.2 +++ b/src/Xen_ComputerSystem_Resource.c	Thu Apr 19 15:50:09 2007 -0600
     2.3 @@ -170,13 +170,13 @@ int Xen_ComputerSystem_setInstanceFromRe
     2.4           CMSetProperty(instance, "Status",(CMPIValue *)"Suspended", CMPI_chars);
     2.5           break;
     2.6        
     2.7 -      case XEN_VM_POWER_STATE_SHUTTINGDOWN:
     2.8 +/*      case :
     2.9           statusvalue = 9; // "Stopping"
    2.10           enabledStateVal = 4; // "Shutting Down"
    2.11           requestedStateVal = 3; // "Disabled"
    2.12           CMSetProperty(instance, "Status",(CMPIValue *)"Stopping", CMPI_chars);
    2.13           break;
    2.14 -
    2.15 +*/
    2.16        default:
    2.17           statusvalue = 0; // "Unknown"
    2.18           enabledStateVal = 0; // "Unknown"
    2.19 @@ -212,8 +212,9 @@ int Xen_ComputerSystem_deleteResource(xe
    2.20      * For now we'll treat this operation as synchronous and not wait
    2.21      * for shutdown before removing the domain.
    2.22      */
    2.23 -   if ((resource->power_state !=  XEN_VM_POWER_STATE_HALTED) ||
    2.24 -       (resource->power_state !=  XEN_VM_POWER_STATE_SHUTTINGDOWN))   {
    2.25 +   if (resource->power_state !=  XEN_VM_POWER_STATE_HALTED)
    2.26 +//       (resource->power_state !=  XEN_VM_POWER_STATE_SHUTTINGDOWN))   
    2.27 +   {
    2.28        /* Initiate an asynchronous graceful shutdown of the domain's OS.
    2.29           Note - this will also eventually destroy the domain! */
    2.30        if (!xen_vm_clean_shutdown(session->xen, resource->handle)) {
     3.1 --- a/src/Xen_DiskSettingData_Resource.c	Thu Apr 19 15:45:31 2007 -0600
     3.2 +++ b/src/Xen_DiskSettingData_Resource.c	Thu Apr 19 15:50:09 2007 -0600
     3.3 @@ -257,9 +257,10 @@ int Xen_DiskSettingData_setInstanceFromR
     3.4     else
     3.5        mode = "r";
     3.6  
     3.7 -   snprintf(buf, MAX_INSTANCEID_LEN, "%s,%s,%s", resource->image, resource->device, mode);
     3.8 +/*   snprintf(buf, MAX_INSTANCEID_LEN, "%s,%s,%s", resource->image, resource->device, mode);
     3.9     CMSetProperty(instance, "DiskConfigInfo",(CMPIValue *)buf, CMPI_chars);
    3.10 -
    3.11 +	VDI<->VBD issue
    3.12 +*/
    3.13     /*
    3.14      * TODO:
    3.15      * PoolID, Weight, HostResource (mapped device in dom0)
     4.1 --- a/src/Xen_Disk_Resource.c	Thu Apr 19 15:45:31 2007 -0600
     4.2 +++ b/src/Xen_Disk_Resource.c	Thu Apr 19 15:50:09 2007 -0600
     4.3 @@ -241,7 +241,7 @@ int Xen_Disk_setInstanceFromResource(xen
     4.4  
     4.5     CMSetProperty(instance, "Name",(CMPIValue *)resource->device, CMPI_chars);
     4.6  
     4.7 -   CMSetProperty(instance, "Device",(CMPIValue *)resource->image, CMPI_chars);
     4.8 +   //CMSetProperty(instance, "Device",(CMPIValue *)resource->image, CMPI_chars); VDI <-> VBD issue
     4.9     CMSetProperty(instance, "DeviceName",(CMPIValue *)resource->device, CMPI_chars);
    4.10  
    4.11     char *mode;
    4.12 @@ -259,7 +259,7 @@ int Xen_Disk_setInstanceFromResource(xen
    4.13     CMSetProperty(instance, "Access",(CMPIValue *)&access, CMPI_uint16);
    4.14  
    4.15     char diskinfo[1024];
    4.16 -   snprintf(diskinfo, 1024, "%s,%s,%s", resource->image, resource->device, mode);
    4.17 +   //snprintf(diskinfo, 1024, "%s,%s,%s", resource->image, resource->device, mode); VDI<->VBD issue
    4.18     CMSetProperty(instance, "DiskConfigInfo",(CMPIValue *)diskinfo, CMPI_chars);
    4.19  
    4.20     if (vm_rec->power_state != XEN_VM_POWER_STATE_HALTED) {
     5.1 --- a/src/Xen_Memory.c	Thu Apr 19 15:45:31 2007 -0600
     5.2 +++ b/src/Xen_Memory.c	Thu Apr 19 15:50:09 2007 -0600
     5.3 @@ -133,7 +133,7 @@ static CMPIStatus EnumInstanceNames(
     5.4        }
     5.5  
     5.6        /* Set the instance property values from the resource data. */
     5.7 -      if (!Xen_Memory_setInstanceFromResource(resource, instance, _BROKER)) {
     5.8 +      if (!Xen_Memory_setInstanceFromResource(session, resource, instance, _BROKER)) {
     5.9           _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed"));
    5.10           CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data");
    5.11           goto exit;
    5.12 @@ -227,7 +227,7 @@ static CMPIStatus EnumInstances(
    5.13        }
    5.14  
    5.15        /* Set the instance property values from the resource data. */
    5.16 -      if (!Xen_Memory_setInstanceFromResource(resource, instance, _BROKER)) {
    5.17 +      if (!Xen_Memory_setInstanceFromResource(session, resource, instance, _BROKER)) {
    5.18           _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed"));
    5.19           CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data");
    5.20           goto exit;
    5.21 @@ -319,7 +319,7 @@ static CMPIStatus GetInstance(
    5.22     }
    5.23  
    5.24     /* Set the instance property values from the resource data. */
    5.25 -   if (!Xen_Memory_setInstanceFromResource(resource, instance, _BROKER)) {
    5.26 +   if (!Xen_Memory_setInstanceFromResource(session, resource, instance, _BROKER)) {
    5.27        _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed"));
    5.28        CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data");
    5.29        goto exit;
     6.1 --- a/src/Xen_MemorySettingData.c	Thu Apr 19 15:45:31 2007 -0600
     6.2 +++ b/src/Xen_MemorySettingData.c	Thu Apr 19 15:50:09 2007 -0600
     6.3 @@ -132,7 +132,7 @@ static CMPIStatus EnumInstanceNames(
     6.4        }
     6.5  
     6.6        /* Set the instance property values from the resource data. */
     6.7 -      if (!Xen_MemorySettingData_setInstanceFromResource(resource, instance, _BROKER)) {
     6.8 +      if (!Xen_MemorySettingData_setInstanceFromResource(session, resource, instance, _BROKER)) {
     6.9           _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed"));
    6.10           CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data");
    6.11           goto exit;
    6.12 @@ -226,7 +226,7 @@ static CMPIStatus EnumInstances(
    6.13        }
    6.14  
    6.15        /* Set the instance property values from the resource data. */
    6.16 -      if (!Xen_MemorySettingData_setInstanceFromResource(resource, instance, _BROKER)) {
    6.17 +      if (!Xen_MemorySettingData_setInstanceFromResource(session, resource, instance, _BROKER)) {
    6.18           _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed"));
    6.19           CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data");
    6.20           goto exit;
    6.21 @@ -318,7 +318,7 @@ static CMPIStatus GetInstance(
    6.22     }
    6.23  
    6.24     /* Set the instance property values from the resource data. */
    6.25 -   if (!Xen_MemorySettingData_setInstanceFromResource(resource, instance, _BROKER)) {
    6.26 +   if (!Xen_MemorySettingData_setInstanceFromResource(session, resource, instance, _BROKER)) {
    6.27        _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed"));
    6.28        CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data");
    6.29        goto exit;
     7.1 --- a/src/Xen_MemorySettingData_Resource.c	Thu Apr 19 15:45:31 2007 -0600
     7.2 +++ b/src/Xen_MemorySettingData_Resource.c	Thu Apr 19 15:50:09 2007 -0600
     7.3 @@ -16,7 +16,8 @@
     7.4  // ============================================================================
     7.5  // Authors:       Dr. Gareth S. Bestor, <bestor@us.ibm.com>
     7.6  // Contributors:  Jim Fehlig, <jfehlig@novell.com>
     7.7 -// Description:
     7.8 +//		  Raj Subrahmanian <raj.subrahmanian@unisys.com>
     7.9 +// Description:   
    7.10  // ============================================================================
    7.11  
    7.12  #include <stdlib.h>
    7.13 @@ -25,7 +26,7 @@
    7.14  
    7.15  #include <xen_common.h>
    7.16  #include <xen_vm.h>
    7.17 -
    7.18 +#include <xen_vm_metrics.h>
    7.19  #include "Xen_MemorySettingData_Resource.h"
    7.20  
    7.21  /* Include the required CMPI data types, function headers, and macros. */
    7.22 @@ -125,7 +126,8 @@ int Xen_MemorySettingData_freeResource(_
    7.23  // ---------------------------------------------------------------------------- 
    7.24  
    7.25  /* Set the property values of a CMPI instance from a specific resource. */
    7.26 -int Xen_MemorySettingData_setInstanceFromResource(_RESOURCE * resource,
    7.27 +int Xen_MemorySettingData_setInstanceFromResource(xen_utils_session *session,
    7.28 +						  _RESOURCE * resource,
    7.29                                                    const CMPIInstance * instance,
    7.30                                                    const CMPIBroker * broker)
    7.31  {
    7.32 @@ -146,8 +148,12 @@ int Xen_MemorySettingData_setInstanceFro
    7.33     int consumerVisibility = 2; /* 2 == Passed-Through */
    7.34     CMSetProperty(instance, "ConsumerVisibility" , (CMPIValue *)&consumerVisibility, CMPI_uint16);
    7.35  
    7.36 -   unsigned long long memory;
    7.37 -   memory = resource->memory_actual;
    7.38 +   int64_t memory;
    7.39 +   // Get the memory_actual
    7.40 +   if (resource->metrics->is_record)
    7.41 +	memory=resource->metrics->u.record->memory_actual;
    7.42 +   else	
    7.43 +	xen_vm_metrics_get_memory_actual(session, &memory, resource->metrics->u.handle);;
    7.44     CMSetProperty(instance, "Reservation",(CMPIValue *)&memory, CMPI_uint64);
    7.45     CMSetProperty(instance, "VirtualQuantity",(CMPIValue *)&memory, CMPI_uint64);
    7.46     memory = resource->memory_dynamic_max;
     8.1 --- a/src/Xen_MemorySettingData_Resource.h	Thu Apr 19 15:45:31 2007 -0600
     8.2 +++ b/src/Xen_MemorySettingData_Resource.h	Thu Apr 19 15:50:09 2007 -0600
     8.3 @@ -77,7 +77,8 @@ int Xen_MemorySettingData_getResourceFor
     8.4  int Xen_MemorySettingData_freeResource(_RESOURCE * resource);
     8.5  
     8.6  /* Set the property values of a CMPI instance from a specific resource. */
     8.7 -int Xen_MemorySettingData_setInstanceFromResource(_RESOURCE * resource,
     8.8 +int Xen_MemorySettingData_setInstanceFromResource(xen_utils_session *session,
     8.9 +						  _RESOURCE * resource,
    8.10                                                    const CMPIInstance * instance,
    8.11                                                    const CMPIBroker * broker);
    8.12  
     9.1 --- a/src/Xen_Memory_Resource.c	Thu Apr 19 15:45:31 2007 -0600
     9.2 +++ b/src/Xen_Memory_Resource.c	Thu Apr 19 15:50:09 2007 -0600
     9.3 @@ -17,11 +17,13 @@
     9.4  // Authors:       Dr. Gareth S. Bestor, <bestor@us.ibm.com>
     9.5  //                Tokunbo Adeshiyan, <tokunbo@us.ibm.com>
     9.6  // Contributors:  Jim Fehlig, <jfehlig@novell.com>
     9.7 +//		  Raj Subrahmanian <raj.subrahmanian@unisys.com>
     9.8  // Description:
     9.9  // ============================================================================
    9.10  
    9.11  #include <xen_common.h>
    9.12  #include <xen_vm.h>
    9.13 +#include <xen_vm_metrics.h>
    9.14  
    9.15  #include <stdlib.h>
    9.16  #include <assert.h>
    9.17 @@ -142,8 +144,10 @@ int Xen_Memory_freeResource(_RESOURCE * 
    9.18  
    9.19  // ---------------------------------------------------------------------------- 
    9.20  
    9.21 -/* Set the property values of a CMPI instance from a specific resource. */
    9.22 -int Xen_Memory_setInstanceFromResource(_RESOURCE * resource,
    9.23 +/* Set the property values of a CMPI instance from a specific resource. 
    9.24 +   Added session parameter so that the memory_actual value can be picked up from xen_vm_metrics : Raj Subrahmanian 04/04/2007*/
    9.25 +int Xen_Memory_setInstanceFromResource(xen_utils_session *session,
    9.26 +				       _RESOURCE * resource,
    9.27                                         const CMPIInstance * instance,
    9.28                                         const CMPIBroker * broker)
    9.29  {
    9.30 @@ -165,13 +169,17 @@ int Xen_Memory_setInstanceFromResource(_
    9.31     uint64_t blocksize = 1;
    9.32     CMSetProperty(instance, "BlockSize", (CMPIValue *)&blocksize, CMPI_uint64);
    9.33  
    9.34 -   unsigned long long blocks = resource->memory_dynamic_max;
    9.35 +   int64_t blocks = resource->memory_dynamic_max;
    9.36     CMSetProperty(instance, "NumberOfBlocks", (CMPIValue *)&blocks, CMPI_uint64);
    9.37 -   blocks = resource->memory_actual;
    9.38 +   
    9.39 +   // Get the memory_actual
    9.40 +   if (resource->metrics->is_record)
    9.41 +	blocks=resource->metrics->u.record->memory_actual;
    9.42 +   else	
    9.43 +	xen_vm_metrics_get_memory_actual(session, &blocks, resource->metrics->u.handle);
    9.44     CMSetProperty(instance, "ConsumableBlocks", (CMPIValue *)&blocks, CMPI_uint64);
    9.45  
    9.46 -   if ((resource->power_state == XEN_VM_POWER_STATE_RUNNING) ||
    9.47 -       (resource->power_state == XEN_VM_POWER_STATE_SHUTTINGDOWN))
    9.48 +   if (resource->power_state == XEN_VM_POWER_STATE_RUNNING) 
    9.49        CMSetProperty(instance, "Status", (CMPIValue *)"OK", CMPI_chars);
    9.50     else
    9.51        CMSetProperty(instance, "Status", (CMPIValue *)"No Contact", CMPI_chars);
    10.1 --- a/src/Xen_Memory_Resource.h	Thu Apr 19 15:45:31 2007 -0600
    10.2 +++ b/src/Xen_Memory_Resource.h	Thu Apr 19 15:50:09 2007 -0600
    10.3 @@ -78,7 +78,8 @@ int Xen_Memory_getResourceForObjectPath(
    10.4  int Xen_Memory_freeResource(_RESOURCE * resource);
    10.5  
    10.6  /* Set the property values of a CMPI instance from a specific resource. */
    10.7 -int Xen_Memory_setInstanceFromResource(_RESOURCE * resource,
    10.8 +int Xen_Memory_setInstanceFromResource(xen_utils_session *session,
    10.9 +				       _RESOURCE * resource,
   10.10                                         const CMPIInstance * instance,
   10.11                                         const CMPIBroker * broker);
   10.12  
    11.1 --- a/src/Xen_NetworkPortSettingData_Resource.c	Thu Apr 19 15:45:31 2007 -0600
    11.2 +++ b/src/Xen_NetworkPortSettingData_Resource.c	Thu Apr 19 15:50:09 2007 -0600
    11.3 @@ -251,10 +251,10 @@ int Xen_NetworkPortSettingData_setInstan
    11.4     nic_config_info[0] = '\0';
    11.5     if (resource->mac)
    11.6        snprintf(nic_config_info, 512, "mac=%s", resource->mac);
    11.7 -   if (resource->model) {
    11.8 +/*   if (resource->model) {
    11.9        strncat(nic_config_info, ",model=", 512 - strlen(nic_config_info));
   11.10        strncat(nic_config_info, resource->model, 512 - strlen(nic_config_info));
   11.11 -   }
   11.12 +   }Nic config info does have model*/
   11.13     if (nic_config_info[0] != '\0')
   11.14        CMSetProperty(instance, "NICConfigInfo" , (CMPIValue *)nic_config_info, CMPI_chars);
   11.15     
    12.1 --- a/src/Xen_NetworkPort_Resource.c	Thu Apr 19 15:45:31 2007 -0600
    12.2 +++ b/src/Xen_NetworkPort_Resource.c	Thu Apr 19 15:50:09 2007 -0600
    12.3 @@ -262,10 +262,10 @@ int Xen_NetworkPort_setInstanceFromResou
    12.4     nic_config_info[0] = '\0';
    12.5     if (resource->mac)
    12.6        snprintf(nic_config_info, 512, "mac=%s", resource->mac);
    12.7 -   if (resource->model) {
    12.8 +   /*if (resource->model) {
    12.9        strncat(nic_config_info, ",model=", 512 - strlen(nic_config_info));
   12.10        strncat(nic_config_info, resource->model, 512 - strlen(nic_config_info));
   12.11 -   }
   12.12 +   } NIC config info does not have model*/
   12.13     if (nic_config_info[0] != '\0')
   12.14        CMSetProperty(instance, "NICConfigInfo" , (CMPIValue *)nic_config_info, CMPI_chars);
   12.15  
    13.1 --- a/src/Xen_OperatingSystem.c	Thu Apr 19 15:45:31 2007 -0600
    13.2 +++ b/src/Xen_OperatingSystem.c	Thu Apr 19 15:50:09 2007 -0600
    13.3 @@ -134,7 +134,7 @@ static CMPIStatus EnumInstanceNames(
    13.4        }
    13.5  
    13.6        /* Set the instance property values from the resource data. */
    13.7 -      if (!Xen_OperatingSystem_setInstanceFromResource(resource, instance, _BROKER)) {
    13.8 +      if (!Xen_OperatingSystem_setInstanceFromResource(session,resource, instance, _BROKER)) {
    13.9           _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed"));
   13.10           CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data");
   13.11           goto exit;
   13.12 @@ -228,7 +228,7 @@ static CMPIStatus EnumInstances(
   13.13        }
   13.14  
   13.15        /* Set the instance property values from the resource data. */
   13.16 -      if (!Xen_OperatingSystem_setInstanceFromResource(resource, instance, _BROKER)) {
   13.17 +      if (!Xen_OperatingSystem_setInstanceFromResource(session, resource, instance, _BROKER)) {
   13.18           _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed"));
   13.19           CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data");
   13.20           goto exit;
   13.21 @@ -320,7 +320,7 @@ static CMPIStatus GetInstance(
   13.22     }
   13.23  
   13.24     /* Set the instance property values from the resource data. */
   13.25 -   if (!Xen_OperatingSystem_setInstanceFromResource(resource, instance, _BROKER)) {
   13.26 +   if (!Xen_OperatingSystem_setInstanceFromResource(session,resource, instance, _BROKER)) {
   13.27        _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed"));
   13.28        CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data");
   13.29        goto exit;
    14.1 --- a/src/Xen_OperatingSystem_Resource.c	Thu Apr 19 15:45:31 2007 -0600
    14.2 +++ b/src/Xen_OperatingSystem_Resource.c	Thu Apr 19 15:50:09 2007 -0600
    14.3 @@ -26,6 +26,7 @@
    14.4  
    14.5  #include <xen_common.h>
    14.6  #include <xen_vm.h>
    14.7 +#include <xen_vm_metrics.h>
    14.8  
    14.9  #include "Xen_OperatingSystem_Resource.h"
   14.10  
   14.11 @@ -116,7 +117,8 @@ int Xen_OperatingSystem_freeResource(_RE
   14.12  // ---------------------------------------------------------------------------- 
   14.13  
   14.14  /* Set the property values of a CMPI instance from a specific resource. */
   14.15 -int Xen_OperatingSystem_setInstanceFromResource(_RESOURCE * resource,
   14.16 +int Xen_OperatingSystem_setInstanceFromResource(xen_utils_session *session,
   14.17 +						_RESOURCE * resource,
   14.18                                                  const CMPIInstance * instance,
   14.19                                                  const CMPIBroker * broker)
   14.20  {
   14.21 @@ -171,12 +173,12 @@ int Xen_OperatingSystem_setInstanceFromR
   14.22           // Status is just a string (and deprecated), so just say Suspended
   14.23           CMSetProperty(instance, "Status",(CMPIValue *)"Suspended", CMPI_chars);
   14.24           break;
   14.25 -      
   14.26 +/*      
   14.27        case XEN_VM_POWER_STATE_SHUTTINGDOWN:
   14.28           statusvalue = 9; // "Stopping"
   14.29           CMSetProperty(instance, "Status",(CMPIValue *)"Stopping", CMPI_chars);
   14.30           break;
   14.31 -
   14.32 +*/
   14.33        default:
   14.34           statusvalue = 0; // "Unknown"
   14.35           CMSetProperty(instance, "Status",(CMPIValue *)"No Contact", CMPI_chars);
   14.36 @@ -192,8 +194,15 @@ int Xen_OperatingSystem_setInstanceFromR
   14.37     /*
   14.38      * TODO:
   14.39      * What memory_* field of xen_vm_record should we use here?
   14.40 -    */
   14.41 -   CMSetProperty(instance, "TotalVisibleMemorySize", (CMPIValue *)&(resource->memory_actual), CMPI_uint64);
   14.42 +   */
   14.43 +   int64_t memory=0;
   14.44 +   // Get the memory_actual
   14.45 +   if (resource->metrics->is_record)
   14.46 +	memory=resource->metrics->u.record->memory_actual;
   14.47 +   else	
   14.48 +	xen_vm_metrics_get_memory_actual(session, &memory, resource->metrics->u.handle);
   14.49 +   
   14.50 +   CMSetProperty(instance, "TotalVisibleMemorySize", (CMPIValue *)&(memory), CMPI_uint64);
   14.51  
   14.52     return 1;
   14.53  }
    15.1 --- a/src/Xen_OperatingSystem_Resource.h	Thu Apr 19 15:45:31 2007 -0600
    15.2 +++ b/src/Xen_OperatingSystem_Resource.h	Thu Apr 19 15:50:09 2007 -0600
    15.3 @@ -77,7 +77,8 @@ int Xen_OperatingSystem_getResourceForOb
    15.4  int Xen_OperatingSystem_freeResource(_RESOURCE * resource);
    15.5  
    15.6  /* Set the property values of a CMPI instance from a specific resource. */
    15.7 -int Xen_OperatingSystem_setInstanceFromResource(_RESOURCE * resource,
    15.8 +int Xen_OperatingSystem_setInstanceFromResource(xen_utils_session *session,
    15.9 +						_RESOURCE * resource,
   15.10                                                  const CMPIInstance * instance,
   15.11                                                  const CMPIBroker * broker);
   15.12  
    16.1 --- a/src/Xen_ProcessorSettingData.c	Thu Apr 19 15:45:31 2007 -0600
    16.2 +++ b/src/Xen_ProcessorSettingData.c	Thu Apr 19 15:50:09 2007 -0600
    16.3 @@ -16,6 +16,7 @@
    16.4  // ============================================================================
    16.5  // Authors:       Dr. Gareth S. Bestor, <bestor@us.ibm.com>
    16.6  // Contributors:  Jim Fehlig, <jfehlig@novell.com>
    16.7 +//		  Raj Subrahmanian <raj.subrahmanian@unisys.com>
    16.8  // Description:
    16.9  // ============================================================================
   16.10  
   16.11 @@ -132,7 +133,7 @@ static CMPIStatus EnumInstanceNames(
   16.12        }
   16.13  
   16.14        /* Set the instance property values from the resource data. */
   16.15 -      if (!Xen_ProcessorSettingData_setInstanceFromResource(resource, instance, _BROKER)) {
   16.16 +      if (!Xen_ProcessorSettingData_setInstanceFromResource(session, resource, instance, _BROKER)) {
   16.17           _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed"));
   16.18           CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data");
   16.19           goto exit;
   16.20 @@ -226,7 +227,7 @@ static CMPIStatus EnumInstances(
   16.21        }
   16.22  
   16.23        /* Set the instance property values from the resource data. */
   16.24 -      if (!Xen_ProcessorSettingData_setInstanceFromResource(resource, instance, _BROKER)) {
   16.25 +      if (!Xen_ProcessorSettingData_setInstanceFromResource(session, resource, instance, _BROKER)) {
   16.26           _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed"));
   16.27           CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data");
   16.28           goto exit;
   16.29 @@ -318,7 +319,7 @@ static CMPIStatus GetInstance(
   16.30     }
   16.31  
   16.32     /* Set the instance property values from the resource data. */
   16.33 -   if (!Xen_ProcessorSettingData_setInstanceFromResource(resource, instance, _BROKER)) {
   16.34 +   if (!Xen_ProcessorSettingData_setInstanceFromResource(session, resource, instance, _BROKER)) {
   16.35        _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed"));
   16.36        CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data");
   16.37        goto exit;
    17.1 --- a/src/Xen_ProcessorSettingData_Resource.c	Thu Apr 19 15:45:31 2007 -0600
    17.2 +++ b/src/Xen_ProcessorSettingData_Resource.c	Thu Apr 19 15:50:09 2007 -0600
    17.3 @@ -16,6 +16,7 @@
    17.4  // ============================================================================
    17.5  // Authors:       Dr. Gareth S. Bestor, <bestor@us.ibm.com>
    17.6  // Contributors:  Jim Fehlig, <jfehlig@novell.com>
    17.7 +//		  Raj Subrahmanian <raj.subrahmanian@unisys.com>
    17.8  // Description:
    17.9  // ============================================================================
   17.10  
   17.11 @@ -25,6 +26,7 @@
   17.12  
   17.13  #include <xen_common.h>
   17.14  #include <xen_vm.h>
   17.15 +#include <xen_vm_metrics.h>
   17.16  
   17.17  #include "Xen_ProcessorSettingData_Resource.h"
   17.18  
   17.19 @@ -121,8 +123,11 @@ int Xen_ProcessorSettingData_freeResourc
   17.20  
   17.21  // ---------------------------------------------------------------------------- 
   17.22  
   17.23 -/* Set the property values of a CMPI instance from a specific resource. */
   17.24 -int Xen_ProcessorSettingData_setInstanceFromResource(_RESOURCE * resource,
   17.25 +/* Set the property values of a CMPI instance from a specific resource. 
   17.26 +   We also pass in the session object so that the metrics class can be accessed when required.
   17.27 +*/
   17.28 +int Xen_ProcessorSettingData_setInstanceFromResource(xen_utils_session *session,
   17.29 +						     _RESOURCE * resource,
   17.30                                                       const CMPIInstance * instance,
   17.31                                                       const CMPIBroker * broker)
   17.32  {
   17.33 @@ -143,12 +148,15 @@ int Xen_ProcessorSettingData_setInstance
   17.34     int consumerVisibility = 3; /* 3 == Virtualized */
   17.35     CMSetProperty(instance, "ConsumerVisibility" , (CMPIValue *)&consumerVisibility, CMPI_uint16);
   17.36  
   17.37 -   unsigned long long cpus = 1;
   17.38 +   int64_t cpus = 1;
   17.39     CMSetProperty(instance, "Reservation",(CMPIValue *)&cpus, CMPI_uint64);
   17.40     CMSetProperty(instance, "Limit",(CMPIValue *)&cpus, CMPI_uint64);
   17.41     CMSetProperty(instance, "AllocationUnits",(CMPIValue *)"Cores", CMPI_chars);
   17.42 -   cpus = resource->vcpus_number;
   17.43 -   CMSetProperty(instance, "VirtualQuantity",(CMPIValue *)&cpus, CMPI_uint64);
   17.44 +   if (resource->metrics->is_record)
   17.45 +	cpus=resource->metrics->u.record->vcpus_number;
   17.46 +   else	
   17.47 +	xen_vm_metrics_get_vcpus_number(session, &cpus, resource->metrics->u.handle);
   17.48 +      CMSetProperty(instance, "VirtualQuantity",(CMPIValue *)&cpus, CMPI_uint64);
   17.49  
   17.50     int alloctype = 1;
   17.51     CMSetProperty(instance, "AutomaticAllocation" , (CMPIValue *)&alloctype, CMPI_boolean);
    18.1 --- a/src/Xen_ProcessorSettingData_Resource.h	Thu Apr 19 15:45:31 2007 -0600
    18.2 +++ b/src/Xen_ProcessorSettingData_Resource.h	Thu Apr 19 15:50:09 2007 -0600
    18.3 @@ -76,7 +76,8 @@ int Xen_ProcessorSettingData_getResource
    18.4  int Xen_ProcessorSettingData_freeResource(_RESOURCE * resource);
    18.5  
    18.6  /* Set the property values of a CMPI instance from a specific resource. */
    18.7 -int Xen_ProcessorSettingData_setInstanceFromResource(_RESOURCE * resource,
    18.8 +int Xen_ProcessorSettingData_setInstanceFromResource(xen_utils_session *session,
    18.9 +						     _RESOURCE * resource,
   18.10                                                       const CMPIInstance * instance,
   18.11                                                       const CMPIBroker * broker);
   18.12  
    19.1 --- a/src/Xen_Processor_Resource.c	Thu Apr 19 15:45:31 2007 -0600
    19.2 +++ b/src/Xen_Processor_Resource.c	Thu Apr 19 15:50:09 2007 -0600
    19.3 @@ -17,6 +17,7 @@
    19.4  // Authors:       Dr. Gareth S. Bestor, <bestor@us.ibm.com>
    19.5  //                Tokunbo Adeshiyan, <tokunbo@us.ibm.com>
    19.6  // Contributors:  Jim Fehlig, <jfehlig@novell.com>
    19.7 +//		  Raj Subrahmanian <raj.subrahmanian@unisys.com>
    19.8  // Description:
    19.9  // ============================================================================
   19.10  
   19.11 @@ -25,6 +26,7 @@
   19.12  
   19.13  #include <xen_common.h>
   19.14  #include <xen_vm.h>
   19.15 +#include <xen_vm_metrics.h>
   19.16  
   19.17  #include "Xen_Processor_Resource.h"
   19.18  
   19.19 @@ -72,12 +74,14 @@ int Xen_Processor_freeResources(_RESOURC
   19.20  }
   19.21  
   19.22  // ----------------------------------------------------------------------------
   19.23 -
   19.24 +// This function was changed to extract the vcpus_number value from the metrics structure rather
   19.25 +// Raj - 04/04/2007
   19.26  /* Iterator to get the next resource from the resources list. */
   19.27  int Xen_Processor_getNextResource(xen_utils_session *session,
   19.28                                    _RESOURCES * resources,
   19.29                                    _RESOURCE ** resource)
   19.30  {
   19.31 +   int64_t vcpus_number;
   19.32     if (resources == NULL) return 0;
   19.33  
   19.34     /* Check if reached the end of the list of Xen domain names. */
   19.35 @@ -97,8 +101,13 @@ int Xen_Processor_getNextResource(xen_ut
   19.36     resources->currentprocessornum++;
   19.37  
   19.38     /* Return success while there are still processor devices for this domain. */
   19.39 -   if (resources->currentprocessornum <= (*resource)->vcpus_number)
   19.40 -      return 1;
   19.41 +   // Get the vcpus_number
   19.42 +   if ((*resource)->metrics->is_record)
   19.43 +	vcpus_number=(*resource)->metrics->u.record->vcpus_number;
   19.44 +   else	
   19.45 +	xen_vm_metrics_get_vcpus_number(session, &vcpus_number, (*resource)->metrics->u.handle);
   19.46 +   if (resources->currentprocessornum <= vcpus_number)
   19.47 +      return 1; 
   19.48  
   19.49   NextDomain:
   19.50     /* All processors in this domain have been exhausted. */
    20.1 --- a/src/Xen_VirtualSystemManagementCapabilities.c	Thu Apr 19 15:45:31 2007 -0600
    20.2 +++ b/src/Xen_VirtualSystemManagementCapabilities.c	Thu Apr 19 15:50:09 2007 -0600
    20.3 @@ -15,7 +15,7 @@
    20.4  //    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    20.5  // ============================================================================
    20.6  // Authors:       Jim Fehlig, <jfehlig@novell.com>
    20.7 -// Contributors:
    20.8 +// Contributors:  
    20.9  // Description:   A class used to represent the capabilities of 
   20.10  //                Xen_VirtualSystemManagementService, e.g. which
   20.11  //                methods are supported.
    21.1 --- a/src/Xen_VirtualSystemManagementService.c	Thu Apr 19 15:45:31 2007 -0600
    21.2 +++ b/src/Xen_VirtualSystemManagementService.c	Thu Apr 19 15:50:09 2007 -0600
    21.3 @@ -16,6 +16,7 @@
    21.4  // ============================================================================
    21.5  // Authors:       Dr. Gareth S. Bestor, <bestor@us.ibm.com>
    21.6  // Contributors:  Jim Fehlig, <jfehlig@novell.com>
    21.7 +//		  Raj Subrahmanian <raj.subrahmanian@unisys.com>
    21.8  // Description:
    21.9  // ============================================================================
   21.10  
   21.11 @@ -34,6 +35,7 @@
   21.12  #include <xen_vif.h>
   21.13  #include <xen_vbd.h>
   21.14  #include <xen_console.h>
   21.15 +#include <xen_vm_metrics.h>
   21.16  #include <xen_string_string_map.h>
   21.17  
   21.18  /* Include utility functions */
   21.19 @@ -1428,7 +1430,7 @@ static int add_resource_to_vm(xen_vm_rec
   21.20        }
   21.21        
   21.22        /* Adding cpus means just that - adding to existing amount */
   21.23 -      uint64_t cpus = propertyvalue.value.uint64 + vmRec->vcpus_number;
   21.24 +      uint64_t cpus = propertyvalue.value.uint64 + vmRec->vcpus_number; 
   21.25        /*
   21.26         * TODO:
   21.27         * 1. CPU weights and other scheduling parameters?
   21.28 @@ -1688,8 +1690,8 @@ static int vssd2xenconfig(CMPIInstance *
   21.29                                "No BootOrder specified for HVM guest");
   21.30           return 0;
   21.31        }
   21.32 -      vm_rec->hvm_boot = strdup(CMGetCharPtr(propertyvalue.value.string));
   21.33 -      
   21.34 +      //vm_rec->hvm_boot_params = strdup(CMGetCharPtr(propertyvalue.value.string));
   21.35 +      add_strings_to_map("order", CMGetCharPtr(propertyvalue.value.string),&(vm_rec->hvm_boot_params ));
   21.36        /* Default stdvga to 0 */
   21.37        plat_val = "0";
   21.38        propertyvalue = CMGetProperty(vssd, "stdvga", status);
   21.39 @@ -1794,7 +1796,7 @@ static int vssd2xenconfig(CMPIInstance *
   21.40     return 1;
   21.41  }
   21.42  
   21.43 -
   21.44 +// Look for vcpus_number in the metrics structure.
   21.45  static int proc_rasd2vmconfig(CMPIInstance *proc_rasd, xen_vm_record *vm_rec,
   21.46                                CMPIStatus *status)
   21.47  {
   21.48 @@ -1806,10 +1808,13 @@ static int proc_rasd2vmconfig(CMPIInstan
   21.49         * TODO:
   21.50         * 1. Handle defaults if processors not specified.
   21.51         * 2. CPU weights and other scheduling parameters?
   21.52 +	
   21.53         */
   21.54 -      vm_rec->vcpus_number = propertyvalue.value.uint64;
   21.55 -
   21.56 -      return 1;
   21.57 +   if (vm_rec->metrics->is_record)
   21.58 +	vm_rec->metrics->u.record->vcpus_number=propertyvalue.value.uint64;
   21.59 +   else	
   21.60 +	xen_vm_metrics_set_vcpus_number(session, propertyvalue.value.uint64, vm_rec->metrics->u.handle);	
   21.61 +    return 1;
   21.62     }
   21.63  
   21.64     return 0;
   21.65 @@ -1866,7 +1871,7 @@ static int disk_rasd2vmconfig(CMPIInstan
   21.66           free(string);
   21.67           goto Error;
   21.68        }
   21.69 -      (*vbd_rec)->image = strdup(tok);
   21.70 +//      (*vbd_rec)->image = strdup(tok); VDI<->BBD issue
   21.71  
   21.72        if ((tok = strtok_r(NULL, ",", &next_tok)) == NULL) {
   21.73           _SBLIM_TRACE(1,("--- Malformed DiskConfigInfo property in disk setting data"));
   21.74 @@ -1888,7 +1893,7 @@ static int disk_rasd2vmconfig(CMPIInstan
   21.75           (*vbd_rec)->mode = XEN_VBD_MODE_RO;
   21.76  
   21.77        free(string);
   21.78 -      _SBLIM_TRACE(2,("--- uname = %s", (*vbd_rec)->image));
   21.79 +      //_SBLIM_TRACE(2,("--- uname = %s", (*vbd_rec)->image));
   21.80        _SBLIM_TRACE(2,("--- dev = %s", (*vbd_rec)->device));
   21.81        _SBLIM_TRACE(2,("--- mode = %s",
   21.82                        (*vbd_rec)->mode == XEN_VBD_MODE_RW ? "RW" : "RO"));
   21.83 @@ -1935,8 +1940,8 @@ static int nic_rasd2vmconfig(CMPIInstanc
   21.84     while (tok) {
   21.85        if (strncmp(tok, "mac", 3) == 0)
   21.86           (*vif_rec)->mac = strdup(tok + 4);
   21.87 -      else if (strncmp(tok, "model", 5) == 0)
   21.88 -         (*vif_rec)->model = strdup(tok + 6);
   21.89 +/*      else if (strncmp(tok, "model", 5) == 0)
   21.90 +         (*vif_rec)->model = strdup(tok + 6); Commented off to compile the code*/ 
   21.91        
   21.92        tok = strtok_r(NULL, ",", &next_tok);
   21.93     }
    22.1 --- a/src/Xen_VirtualSystemManagementService_Resource.c	Thu Apr 19 15:45:31 2007 -0600
    22.2 +++ b/src/Xen_VirtualSystemManagementService_Resource.c	Thu Apr 19 15:50:09 2007 -0600
    22.3 @@ -16,6 +16,7 @@
    22.4  // ============================================================================
    22.5  // Authors:       Dr. Gareth S. Bestor, <bestor@us.ibm.com>
    22.6  // Contributors:  Jim Fehlig, <jfehlig@novell.com>
    22.7 +
    22.8  // Description:
    22.9  // ============================================================================
   22.10  
    23.1 --- a/src/xen_utils.c	Thu Apr 19 15:45:31 2007 -0600
    23.2 +++ b/src/xen_utils.c	Thu Apr 19 15:50:09 2007 -0600
    23.3 @@ -15,7 +15,7 @@
    23.4  //    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    23.5  // ============================================================================
    23.6  // Authors:       Jim Fehlig, <jfehlig@novell.com>
    23.7 -// Contributors:
    23.8 +// Contributors:  Raj Subrahmanian <raj.subrahmanian@unisys.com>
    23.9  // Description:   Utilitiy functions built on top of libxen for use in all
   23.10  //                providers.
   23.11  // ============================================================================
   23.12 @@ -682,3 +682,25 @@ int xen_utils_is_domain_active(xen_utils
   23.13     return 1;
   23.14  }
   23.15  
   23.16 +/*
   23.17 + * Extract the value from a string map given a key
   23.18 + *
   23.19 +*/
   23.20 +int xen_utils_get_value_from_map(xen_string_string_map *map, const char *key, char *val)
   23.21 +{
   23.22 +   int i=0;
   23.23 +   // Make sure you have a good value
   23.24 +   if(!map) return 0;
   23.25 +   // String map is empty
   23.26 +   if (map->size==0) return 0;
   23.27 +   while (i<map->size)
   23.28 +   {   // Found key
   23.29 +       if (strcmp(key, map->contents[i].key)==0)
   23.30 +       {
   23.31 +	 val=strdup(map->contents[i].val);
   23.32 +	 return 1;
   23.33 +       }
   23.34 +       i++;
   23.35 +   }
   23.36 +   return 0;
   23.37 +}
   23.38 \ No newline at end of file
    24.1 --- a/src/xen_utils.h	Thu Apr 19 15:45:31 2007 -0600
    24.2 +++ b/src/xen_utils.h	Thu Apr 19 15:50:09 2007 -0600
    24.3 @@ -179,5 +179,12 @@ int xen_utils_is_domain_active(xen_utils
    24.4                                 int *isActive);
    24.5  
    24.6  
    24.7 +/*
    24.8 + * Extract the value from a string map given a key
    24.9 + *
   24.10 +*/
   24.11 +int xen_utils_get_value_from_map(xen_string_string_map *map, const char *key, char *val);
   24.12 +
   24.13 +
   24.14  
   24.15  #endif /* __XEN_UTILS_H__ */