os-cmpi-xen

changeset 93:44127f60b2da

Upstream patch 14341 was added to Xen 3.0.4-testing bits of SLES10 SP1.
Modified providers to account for changes in xen_vm.h in libxenapi.

Signed-off-by: Jim Fehlig <jfehlig@novell.com>
author Jim Fehlig <jfehlig@novell.com>
date Tue Mar 20 16:28:56 2007 -0600 (2007-03-20)
parents 66600aae1e53
children eb8803aa395b
files ChangeLog src/Xen_ComputerSystemSettingData_Resource.c src/Xen_VirtualSystemManagementService.c
line diff
     1.1 --- a/ChangeLog	Fri Mar 09 16:52:35 2007 -0700
     1.2 +++ b/ChangeLog	Tue Mar 20 16:28:56 2007 -0600
     1.3 @@ -1,3 +1,10 @@
     1.4 +-------------------------------------------------------------------
     1.5 +Tue Mar 20 16:23:35 MDT 2007 - jfehlig@novell.com
     1.6 +
     1.7 +        - Upstream patch 14341 was added to Xen 3.0.4-testing bits
     1.8 +          of SLES10 SP1.  Providers had to be modified to account
     1.9 +          for changes in xen_vm.h in libxenapi.
    1.10 +
    1.11  -------------------------------------------------------------------
    1.12  Fri Mar  9 16:47:13 MST 2007 - jfehlig@novell.com
    1.13  
     2.1 --- a/src/Xen_ComputerSystemSettingData_Resource.c	Fri Mar 09 16:52:35 2007 -0700
     2.2 +++ b/src/Xen_ComputerSystemSettingData_Resource.c	Tue Mar 20 16:28:56 2007 -0600
     2.3 @@ -36,6 +36,21 @@
     2.4  #include "xen_utils.h"
     2.5  #include "provider_common.h"
     2.6  
     2.7 +
     2.8 +static int get_platform_bool_val(_RESOURCE *resource, char  *key)
     2.9 +{
    2.10 +   int i;
    2.11 +   
    2.12 +   xen_string_string_map *map = resource->platform;
    2.13 +   for (i = 0; i < map->size; i++)
    2.14 +      if (strcmp(map->contents[i].key, key) == 0)
    2.15 +         if (strcmp(map->contents[i].val, "1") == 0)
    2.16 +            return 1;
    2.17 +   
    2.18 +   return 0;
    2.19 +}
    2.20 +
    2.21 +
    2.22  // ----------------------------------------------------------------------------
    2.23  
    2.24  /* Get a handle to the list of all system resources for this class. */
    2.25 @@ -119,6 +134,7 @@ int Xen_ComputerSystemSettingData_freeRe
    2.26     return xen_utils_free_domain_resource(resource);
    2.27  }
    2.28  
    2.29 +
    2.30  // ---------------------------------------------------------------------------- 
    2.31  
    2.32  /* Set the property values of a CMPI instance from a specific resource. */
    2.33 @@ -127,6 +143,7 @@ int Xen_ComputerSystemSettingData_setIns
    2.34                                                            const CMPIBroker * broker)
    2.35  {
    2.36     char inst_id[1024];
    2.37 +   int prop_val;
    2.38  
    2.39     if (resource == NULL) return 0;
    2.40     if (CMIsNullObject(instance)) return 0;
    2.41 @@ -139,7 +156,8 @@ int Xen_ComputerSystemSettingData_setIns
    2.42        /* HVM settings */
    2.43        CMSetProperty(instance, "VirtualSystemType", (CMPIValue *)"Xen HVM", CMPI_chars);
    2.44        CMSetProperty(instance, "BootOrder", (CMPIValue *)resource->hvm_boot, CMPI_chars);
    2.45 -      CMSetProperty(instance, "stdvga", (CMPIValue *)&(resource->platform_std_vga), CMPI_boolean);
    2.46 +      prop_val = get_platform_bool_val(resource, "stdvga");
    2.47 +      CMSetProperty(instance, "stdvga", (CMPIValue *)&prop_val, CMPI_boolean);
    2.48     }
    2.49     else {
    2.50        /* PV settings */
    2.51 @@ -164,7 +182,8 @@ int Xen_ComputerSystemSettingData_setIns
    2.52     if (resource->uuid && (resource->uuid[0] != '\0'))
    2.53        CMSetProperty(instance, "UUID", (CMPIValue *)resource->uuid, CMPI_chars);
    2.54  
    2.55 -   CMSetProperty(instance, "localtime", (CMPIValue *)&(resource->platform_localtime), CMPI_boolean);   
    2.56 +   prop_val = get_platform_bool_val(resource, "localtime");
    2.57 +   CMSetProperty(instance, "localtime", (CMPIValue *)&prop_val, CMPI_boolean);   
    2.58  
    2.59     CMSetProperty(instance, "OnPoweroff", (CMPIValue *)&(resource->actions_after_shutdown), CMPI_uint16);   
    2.60     CMSetProperty(instance, "OnReboot", (CMPIValue *)&(resource->actions_after_reboot), CMPI_uint16);   
     3.1 --- a/src/Xen_VirtualSystemManagementService.c	Fri Mar 09 16:52:35 2007 -0700
     3.2 +++ b/src/Xen_VirtualSystemManagementService.c	Tue Mar 20 16:28:56 2007 -0600
     3.3 @@ -106,6 +106,8 @@ static int nic_rasd2vmconfig(CMPIInstanc
     3.4                               CMPIStatus *status);
     3.5  static int con_rasd2vmconfig(CMPIInstance *instance, xen_console_record *con_rec,
     3.6                               CMPIStatus *status);
     3.7 +static int add_strings_to_map(const char *key, const char *val,
     3.8 +                              xen_string_string_map **map);
     3.9  static CMPIInstance *parse_embedded_instance(char *instanceStr);
    3.10  
    3.11  
    3.12 @@ -1134,7 +1136,7 @@ CMMethodMIStub( , Xen_VirtualSystemManag
    3.13        list->contents[list->size] = device;                                      \
    3.14        list->size++;                                                             \
    3.15     }                                                                            \
    3.16 -}                                                                               \
    3.17 +}
    3.18  
    3.19  
    3.20  static int create_vm(CMPIInstance* vsSettingsInst, 
    3.21 @@ -1571,7 +1573,8 @@ static void remove_vm(xen_vm vm)
    3.22  static int vssd2xenconfig(CMPIInstance *vssd, xen_vm_record *vm_rec, CMPIStatus *status)
    3.23  {
    3.24     CMPIData propertyvalue;
    3.25 -   char *vsType;;
    3.26 +   char *vsType;
    3.27 +   const char *plat_val;
    3.28  
    3.29     /*
    3.30      * Get domain name.
    3.31 @@ -1592,8 +1595,20 @@ static int vssd2xenconfig(CMPIInstance *
    3.32        vm_rec->uuid = strdup(CMGetCharPtr(propertyvalue.value.string));
    3.33     
    3.34     propertyvalue = CMGetProperty(vssd, "localtime", status);
    3.35 -   if ((status->rc == CMPI_RC_OK) && !CMIsNullValue(propertyvalue))
    3.36 -      vm_rec->platform_localtime = propertyvalue.value.boolean;
    3.37 +   if ((status->rc == CMPI_RC_OK) && !CMIsNullValue(propertyvalue)) {
    3.38 +      if (propertyvalue.value.boolean)
    3.39 +         plat_val = "1";
    3.40 +      else
    3.41 +         plat_val = "0";
    3.42 +
    3.43 +      if (!add_strings_to_map("localtime", plat_val, &(vm_rec->platform))) {
    3.44 +         _SBLIM_TRACE(1,
    3.45 +                      ("Cannot malloc memory for xend platform settings list"));
    3.46 +         CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERROR_SYSTEM,
    3.47 +                              "Unable to malloc memory");
    3.48 +         return 0;
    3.49 +      }
    3.50 +   }
    3.51     
    3.52     propertyvalue = CMGetProperty(vssd, "OnPoweroff", status);
    3.53     if ((status->rc == CMPI_RC_OK) && !CMIsNullValue(propertyvalue))
    3.54 @@ -1675,9 +1690,22 @@ static int vssd2xenconfig(CMPIInstance *
    3.55        }
    3.56        vm_rec->hvm_boot = strdup(CMGetCharPtr(propertyvalue.value.string));
    3.57        
    3.58 +      /* Default stdvga to 0 */
    3.59 +      plat_val = "0";
    3.60        propertyvalue = CMGetProperty(vssd, "stdvga", status);
    3.61 -      if ((status->rc == CMPI_RC_OK) && !CMIsNullValue(propertyvalue))
    3.62 -         vm_rec->platform_std_vga = propertyvalue.value.boolean;
    3.63 +      if ((status->rc == CMPI_RC_OK) && !CMIsNullValue(propertyvalue)) {
    3.64 +         if (propertyvalue.value.boolean)
    3.65 +            plat_val = "1";
    3.66 +         else
    3.67 +            plat_val = "0";
    3.68 +      }
    3.69 +      if (!add_strings_to_map("stdvga", plat_val, &(vm_rec->platform))) {
    3.70 +         _SBLIM_TRACE(1,
    3.71 +                      ("Cannot malloc memory for xend platform settings list"));
    3.72 +         CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERROR_SYSTEM,
    3.73 +                              "Unable to malloc memory");
    3.74 +         return 0;
    3.75 +      }
    3.76     }
    3.77     else {
    3.78        _SBLIM_TRACE(1,("--- Invalid VirtualSystemType %s specified", vsType));
    3.79 @@ -1933,6 +1961,36 @@ static int con_rasd2vmconfig(CMPIInstanc
    3.80  }
    3.81  
    3.82  
    3.83 +/*
    3.84 + * Private function to support adding strings to a string map.
    3.85 + */
    3.86 +static int add_strings_to_map(const char *key, const char *val,
    3.87 +                              xen_string_string_map **map)
    3.88 +{
    3.89 +   if (*map == NULL) {
    3.90 +      *map = xen_string_string_map_alloc(1);
    3.91 +      if (*map == NULL)
    3.92 +         return 0;
    3.93 +      
    3.94 +      (*map)->size = 1;
    3.95 +      (*map)->contents[0].key = strdup(key);
    3.96 +      (*map)->contents[0].val = strdup(val);
    3.97 +      return 1;
    3.98 +   }
    3.99 +   
   3.100 +   /* Map is not empty.  Grow the map and add the new strings */
   3.101 +   int new_len = sizeof(xen_string_string_map) +
   3.102 +         (((*map)->size + 1) * sizeof(xen_string_string_map_contents));
   3.103 +   *map = realloc(*map, new_len);
   3.104 +   if (*map == NULL) 
   3.105 +      return 0;
   3.106 +
   3.107 +   (*map)->contents[(*map)->size].key = strdup(key);
   3.108 +   (*map)->contents[(*map)->size].val = strdup(val);
   3.109 +   (*map)->size++;
   3.110 +}
   3.111 +
   3.112 +
   3.113  
   3.114  // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
   3.115  // THE FOLLOWING CODE IS REQUIRED UNTIL EMBEDDEDOBJECT SUPPORT IS WORKING!!!