os-cmpi-xen

changeset 89:93600f4355d8

Added support for Xen_ConsoleSettingData.ConsoleConfigInfo
in Xen_VirtualSystemManagementService.DefineSystem(). This
allows specifying additional console configuration such as
vncunused=1, vncpasswd=foobar, etc.

Signed-off-by: Jim Fehlig <jfehlig@novell.com>
author Jim Fehlig <jfehlig@novell.com>
date Wed Feb 28 16:28:14 2007 -0700 (2007-02-28)
parents 9a96ebba2b60
children 585665e1a296
files ChangeLog src/Xen_VirtualSystemManagementService.c
line diff
     1.1 --- a/ChangeLog	Mon Feb 26 14:52:36 2007 -0700
     1.2 +++ b/ChangeLog	Wed Feb 28 16:28:14 2007 -0700
     1.3 @@ -1,3 +1,11 @@
     1.4 +-------------------------------------------------------------------
     1.5 +Wed Feb 28 16:25:05 MST 2007 - jfehlig@novell.com
     1.6 +
     1.7 +        - Added support for Xen_ConsoleSettingData.ConsoleConfigInfo
     1.8 +          in Xen_VirtualSystemManagementService.DefineSystem().  This
     1.9 +          allows specifying additional console configuration such as
    1.10 +          vncunused=1, vncpasswd=foobar, etc.
    1.11 +
    1.12  -------------------------------------------------------------------
    1.13  Mon Feb 26 14:48:40 MST 2007 - jfehlig@novell.com
    1.14  
     2.1 --- a/src/Xen_VirtualSystemManagementService.c	Mon Feb 26 14:52:36 2007 -0700
     2.2 +++ b/src/Xen_VirtualSystemManagementService.c	Wed Feb 28 16:28:14 2007 -0700
     2.3 @@ -34,6 +34,7 @@
     2.4  #include <xen_vif.h>
     2.5  #include <xen_vbd.h>
     2.6  #include <xen_console.h>
     2.7 +#include <xen_string_string_map.h>
     2.8  
     2.9  /* Include utility functions */
    2.10  #include "cmpiutil.h"
    2.11 @@ -1667,7 +1668,7 @@ static int vssd2xenconfig(CMPIInstance *
    2.12           vm_rec->platform_std_vga = propertyvalue.value.boolean;
    2.13     }
    2.14     else {
    2.15 -      _SBLIM_TRACE(1,("--- Invalide VirtualSystemType %s specified", vsType));
    2.16 +      _SBLIM_TRACE(1,("--- Invalid VirtualSystemType %s specified", vsType));
    2.17        CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_INVALID_PARAMETER,
    2.18                             "Invalid VirtualSystemType specified");
    2.19        return 0;
    2.20 @@ -1744,21 +1745,24 @@ static int disk_rasd2vmconfig(CMPIInstan
    2.21        tok = strtok_r(string, ",", &next_tok);
    2.22        if (tok == NULL) {
    2.23           _SBLIM_TRACE(1,("--- Malformed DiskConfigInfo property in disk setting data"));
    2.24 -         CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_INVALID_PARAMETER, "Invalide disk setting data");
    2.25 +         CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_INVALID_PARAMETER, "Invalid disk setting data");
    2.26 +         free(string);
    2.27           goto Error;
    2.28        }
    2.29        (*vbd_rec)->image = strdup(tok);
    2.30  
    2.31        if ((tok = strtok_r(NULL, ",", &next_tok)) == NULL) {
    2.32           _SBLIM_TRACE(1,("--- Malformed DiskConfigInfo property in disk setting data"));
    2.33 -         CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_INVALID_PARAMETER, "Invalide disk setting data");
    2.34 +         CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_INVALID_PARAMETER, "Invalid disk setting data");
    2.35 +         free(string);
    2.36           goto Error;
    2.37        }
    2.38        (*vbd_rec)->device = strdup(tok);
    2.39  
    2.40        if ((tok = strtok_r(NULL, ",", &next_tok)) == NULL) {
    2.41           _SBLIM_TRACE(1,("--- Malformed DiskConfigInfo property in disk setting data"));
    2.42 -         CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_INVALID_PARAMETER, "Invalide disk setting data");
    2.43 +         CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_INVALID_PARAMETER, "Invalid disk setting data");
    2.44 +         free(string);
    2.45           goto Error;
    2.46        }
    2.47        if (strcmp(tok, "w") == 0)
    2.48 @@ -1791,52 +1795,53 @@ static int nic_rasd2vmconfig(CMPIInstanc
    2.49     
    2.50     /* Set the domain config data from the Xen_NetworkPortSettingData. */
    2.51     propertyvalue = CMGetProperty(nic_rasd, "NICConfigInfo", status);
    2.52 -   if ((status->rc == CMPI_RC_OK) && !CMIsNullValue(propertyvalue)) {
    2.53 -      *vif_rec = xen_vif_record_alloc();
    2.54 -      if (*vif_rec == NULL) {
    2.55 -         _SBLIM_TRACE(1,("--- Cannot malloc memory for virtual network device"));
    2.56 -         CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERROR_SYSTEM, "Unable to malloc memory");
    2.57 -         return 0;
    2.58 -      }
    2.59 -
    2.60 -      /* Extract the type, mac and network params from the NicConfigInfo
    2.61 -       * string.  Expected syntax is "key=value,key=value" */
    2.62 -      char * next_tok;
    2.63 -      char * string = strdup(CMGetCharPtr(propertyvalue.value.string));
    2.64 -      char *tok = strtok_r(string, ",", &next_tok);
    2.65 -      /* If tok is NULL, then string contains only 1 key/value pair */
    2.66 -      if (tok == NULL)
    2.67 -         tok = string;
    2.68 -      while (tok) {
    2.69 -         if (strncmp(tok, "mac", 3) == 0)
    2.70 -            (*vif_rec)->mac = strdup(tok + 4);
    2.71 -         /*
    2.72 -          * TODO:
    2.73 -          * Map other config items in the NIC info to xen_vif_record struct.
    2.74 -          */
    2.75 -         
    2.76 -         tok = strtok_r(NULL, ",", &next_tok);
    2.77 -      }
    2.78 +   if ((status->rc != CMPI_RC_OK) || CMIsNullValue(propertyvalue)) {
    2.79 +      _SBLIM_TRACE(1,("--- No NICConfigInfo specified in network port setting data"));
    2.80 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_INVALID_PARAMETER, "No NICConfigInfo specified in network port setting data");
    2.81        
    2.82 -      free(string);
    2.83 -      _SBLIM_TRACE(2,("--- mac = %s",
    2.84 -                      (*vif_rec)->mac ?  (*vif_rec)->mac : "not specified"));
    2.85 -    
    2.86 -      return 1;
    2.87 +      *vif_rec = NULL;
    2.88 +      return 0;
    2.89 +   }
    2.90 +   
    2.91 +   *vif_rec = xen_vif_record_alloc();
    2.92 +   if (*vif_rec == NULL) {
    2.93 +      _SBLIM_TRACE(1,("--- Cannot malloc memory for virtual network device"));
    2.94 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERROR_SYSTEM, "Unable to malloc memory");
    2.95 +      return 0;
    2.96     }
    2.97     
    2.98 -   *vif_rec = NULL;
    2.99 -   return 0;
   2.100 +   /* Extract the type, mac and network params from the NicConfigInfo
   2.101 +    * string.  Expected syntax is "key=value,key=value" */
   2.102 +   char * next_tok;
   2.103 +   char * string = strdup(CMGetCharPtr(propertyvalue.value.string));
   2.104 +   char *tok = strtok_r(string, ",", &next_tok);
   2.105 +   while (tok) {
   2.106 +      if (strncmp(tok, "mac", 3) == 0)
   2.107 +         (*vif_rec)->mac = strdup(tok + 4);
   2.108 +      /*
   2.109 +       * TODO:
   2.110 +       * Map other config items in the NIC info to xen_vif_record struct.
   2.111 +       */
   2.112 +      
   2.113 +      tok = strtok_r(NULL, ",", &next_tok);
   2.114 +   }
   2.115 +   
   2.116 +   free(string);
   2.117 +   _SBLIM_TRACE(2,("--- mac = %s",
   2.118 +                   (*vif_rec)->mac ?  (*vif_rec)->mac : "not specified"));
   2.119 +   
   2.120 +   return 1;
   2.121  }
   2.122  
   2.123  
   2.124  static int con_rasd2vmconfig(CMPIInstance *con_rasd, xen_console_record *con_rec,
   2.125                               CMPIStatus *status)
   2.126  {
   2.127 +   CMPIStatus local_status = {CMPI_RC_OK, NULL};
   2.128     CMPIData propertyvalue;
   2.129     
   2.130 -   propertyvalue = CMGetProperty(con_rasd, "Protocol", status);
   2.131 -   if ((status->rc != CMPI_RC_OK) || CMIsNullValue(propertyvalue)) {
   2.132 +   propertyvalue = CMGetProperty(con_rasd, "Protocol", &local_status);
   2.133 +   if ((local_status.rc != CMPI_RC_OK) || CMIsNullValue(propertyvalue)) {
   2.134        _SBLIM_TRACE(1,("--- No protocol field specified in console setting data"));
   2.135        CMSetStatusWithChars(_BROKER, status,  CMPI_RC_ERR_INVALID_PARAMETER, "No protocol specified in console setting data");
   2.136        return 0;
   2.137 @@ -1858,6 +1863,60 @@ static int con_rasd2vmconfig(CMPIInstanc
   2.138           return 0;
   2.139     }
   2.140  
   2.141 +   /*
   2.142 +    * Get any additional config from ConsoleConfigInfo.
   2.143 +    * Expected syntax is "key=value,key=value"
   2.144 +    */
   2.145 +   propertyvalue = CMGetProperty(con_rasd, "ConsoleConfigInfo", &local_status);
   2.146 +   if ((local_status.rc == CMPI_RC_OK) && !CMIsNullValue(propertyvalue)) {
   2.147 +      /* Count number of config items */
   2.148 +      int num_items = 0;
   2.149 +      char *next_tok;
   2.150 +      char *string = strdup(CMGetCharPtr(propertyvalue.value.string));
   2.151 +      char *tok = strtok_r(string, ",", &next_tok);
   2.152 +      while (tok) {
   2.153 +         num_items++;
   2.154 +         tok = strtok_r(NULL, ",", &next_tok);
   2.155 +      }
   2.156 +      free(string);
   2.157 +      
   2.158 +      xen_string_string_map *con_params = xen_string_string_map_alloc(num_items);
   2.159 +      if (con_params == NULL) {
   2.160 +         _SBLIM_TRACE(1,("--- Cannot malloc memory for console options"));
   2.161 +         CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERROR_SYSTEM, "Unable to malloc memory");
   2.162 +         return 0;
   2.163 +      }
   2.164 +      
   2.165 +      /*
   2.166 +       * Go back through the options and populate the string map.
   2.167 +       */
   2.168 +      string = strdup(CMGetCharPtr(propertyvalue.value.string));
   2.169 +      tok = strtok_r(string, ",", &next_tok);
   2.170 +      /* If tok is NULL, then string contains only 1 key/value pair */
   2.171 +      if (tok == NULL)
   2.172 +         tok = string;
   2.173 +      int i = 0;
   2.174 +      while (tok) {
   2.175 +         char *val = strchr(tok, '=');
   2.176 +         if (val == NULL) {
   2.177 +            _SBLIM_TRACE(1,("--- Invalid console option specified in console setting data"));
   2.178 +            CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_INVALID_PARAMETER, "Invalid console option specified in console setting data");
   2.179 +            xen_string_string_map_free(con_params);
   2.180 +            free(string);
   2.181 +            return 0;
   2.182 +         }
   2.183 +         *val = '\0';
   2.184 +         val++;
   2.185 +         con_params->contents[i].key = strdup(tok);
   2.186 +         con_params->contents[i].val = strdup(val);
   2.187 +         i++;
   2.188 +         tok = strtok_r(NULL, ",", &next_tok);
   2.189 +      }
   2.190 +      
   2.191 +      con_rec->other_config = con_params;
   2.192 +      free(string);
   2.193 +   }
   2.194 +
   2.195     return 1;
   2.196  }
   2.197