os-cmpi-xen

changeset 88:9a96ebba2b60

Added support for localtime, stdvga, OnPoweroff, OnReboot, and OnCrash to Xen_ComputerSystemSettingData.

Signed-off-by: Jim Fehlig <jfehlig@novell.com>
author Jim Fehlig <jfehlig@novell.com>
date Mon Feb 26 14:52:36 2007 -0700 (2007-02-26)
parents 4ae953dc7f33
children 93600f4355d8
files ChangeLog schema/Xen_ComputerSystemSettingData.mof src/Xen_ComputerSystemSettingData_Resource.c src/Xen_VirtualSystemManagementService.c
line diff
     1.1 --- a/ChangeLog	Fri Feb 23 14:56:02 2007 -0700
     1.2 +++ b/ChangeLog	Mon Feb 26 14:52:36 2007 -0700
     1.3 @@ -1,3 +1,9 @@
     1.4 +-------------------------------------------------------------------
     1.5 +Mon Feb 26 14:48:40 MST 2007 - jfehlig@novell.com
     1.6 +
     1.7 +        - Added support for localtime, stdvga, OnPoweroff,
     1.8 +          OnReboot, and OnCrash to Xen_ComputerSystemSettingData.
     1.9 +
    1.10  -------------------------------------------------------------------
    1.11  Fri Feb 23 14:53:40 MST 2007 - jfehlig@novell.com
    1.12  
     2.1 --- a/schema/Xen_ComputerSystemSettingData.mof	Fri Feb 23 14:56:02 2007 -0700
     2.2 +++ b/schema/Xen_ComputerSystemSettingData.mof	Mon Feb 26 14:52:36 2007 -0700
     2.3 @@ -30,9 +30,6 @@ class Xen_ComputerSystemSettingData : CI
     2.4     [Description ("Command line options to pass to the kernel.")]
     2.5     string KernelOptions = "";
     2.6  
     2.7 -   [Description ("Root boot device to pass to the kernel.")]
     2.8 -   string Root;
     2.9 -
    2.10     [Description ("Bootloader used to extract kernel for booting.  "
    2.11  	"Examples are \"/usr/lib/xen/boot/domUloader.py\" or "
    2.12  	"\"/usr/bin/pygrub\".  If Bootloader is specified, values "
    2.13 @@ -52,17 +49,29 @@ class Xen_ComputerSystemSettingData : CI
    2.14     [Description ("UUID assigned to this domain.")]
    2.15     string UUID;
    2.16  
    2.17 -//   [Description ("Set if you want to use DHCP to configure networking.")]
    2.18 -//   boolean DHCP;
    2.19 +   [Description ("Specify whether domain expects virtual hardware "
    2.20 +	"clock to be in local time or UTC.")]
    2.21 +   boolean localtime;
    2.22  
    2.23 -//   [Description ("Manually configured IP netmask.")]
    2.24 -//   string Netmask;
    2.25 +   [Description ("Specify emulation of standard VGA instead of "
    2.26 +	"cirrus logic.")]
    2.27 +   boolean stdvga;
    2.28  
    2.29 -//   [Description ("Manually configured IP gateway.")]
    2.30 -//   string Gateway;
    2.31 +   [Description ("Specify behavior when domain is powered-off"),
    2.32 +   ValueMap { "0", "1", ".." },
    2.33 +   Values { "Destroy", "Restart", "Reserved"}]
    2.34 +   uint16 OnPoweroff;
    2.35  
    2.36 -//   [Description ("Manually configured the IP hostname.")]
    2.37 -//   string Hostname;
    2.38 +   [Description ("Specify behavior when domain is rebooted"),
    2.39 +   ValueMap { "0", "1", ".." },
    2.40 +   Values { "Destroy", "Restart", "Reserved"}]
    2.41 +   uint16 OnReboot;
    2.42  
    2.43 +   [Description ("Specify behavior when domain crashes"),
    2.44 +   ValueMap { "0", "1", "2", "3", "4", "5", ".." },
    2.45 +   Values { "Destroy", "Restart", "Core Dump and Destroy",
    2.46 +	"Core Dump and Restart", "Preserve", "Rename and Restart",
    2.47 +	 "Reserved"}]
    2.48 +   uint16 OnCrash;
    2.49  
    2.50  };
     3.1 --- a/src/Xen_ComputerSystemSettingData_Resource.c	Fri Feb 23 14:56:02 2007 -0700
     3.2 +++ b/src/Xen_ComputerSystemSettingData_Resource.c	Mon Feb 26 14:52:36 2007 -0700
     3.3 @@ -126,45 +126,49 @@ int Xen_ComputerSystemSettingData_setIns
     3.4                                                            const CMPIInstance * instance,
     3.5                                                            const CMPIBroker * broker)
     3.6  {
     3.7 -   char instId[1024];
     3.8 +   char inst_id[1024];
     3.9  
    3.10     if (resource == NULL) return 0;
    3.11     if (CMIsNullObject(instance)) return 0;
    3.12  
    3.13     /* Set the CMPIInstance properties from the resource data. */
    3.14 -   snprintf(instId, 1024, "Xen:%s", resource->name_label);
    3.15 -   CMSetProperty(instance, "InstanceID",(CMPIValue *)instId, CMPI_chars);
    3.16 +   snprintf(inst_id, 1024, "Xen:%s", resource->name_label);
    3.17 +   CMSetProperty(instance, "InstanceID",(CMPIValue *)inst_id, CMPI_chars);
    3.18  
    3.19 +   if (resource->hvm_boot) {
    3.20 +      /* HVM settings */
    3.21 +      CMSetProperty(instance, "VirtualSystemType", (CMPIValue *)"Xen HVM", CMPI_chars);
    3.22 +      CMSetProperty(instance, "BootOrder", (CMPIValue *)resource->hvm_boot, CMPI_chars);
    3.23 +      CMSetProperty(instance, "stdvga", (CMPIValue *)&(resource->platform_std_vga), CMPI_boolean);
    3.24 +   }
    3.25 +   else {
    3.26 +      /* PV settings */
    3.27 +      CMSetProperty(instance, "VirtualSystemType", (CMPIValue *)"Xen Paravirtual", CMPI_chars);
    3.28 +      
    3.29 +      if (resource->pv_kernel)
    3.30 +         CMSetProperty(instance, "Kernel", (CMPIValue *)resource->pv_kernel, CMPI_chars);
    3.31 +      if (resource->pv_ramdisk)
    3.32 +         CMSetProperty(instance, "RAMDisk", (CMPIValue *)resource->pv_ramdisk, CMPI_chars);
    3.33 +      if (resource->pv_args)
    3.34 +         CMSetProperty(instance, "KernelOptions" , (CMPIValue *)resource->pv_args, CMPI_chars);
    3.35 +      if (resource->pv_bootloader)
    3.36 +         CMSetProperty(instance, "Bootloader", (CMPIValue *)resource->pv_bootloader, CMPI_chars);
    3.37 +      if (resource->pv_bootloader_args)
    3.38 +         CMSetProperty(instance, "BootloaderOptions", (CMPIValue *)resource->pv_bootloader_args, CMPI_chars);
    3.39 +   }
    3.40 +   
    3.41 +   /* Common settings */
    3.42     CMSetProperty(instance, "ElementName",(CMPIValue *)resource->name_label, CMPI_chars);
    3.43     CMSetProperty(instance, "VirtualSystemIdentifier",(CMPIValue *)resource->name_label, CMPI_chars);
    3.44  
    3.45 -   /* If kernel or bootloader specified, domain is paravirtual */
    3.46 -   if (resource->pv_bootloader || resource->pv_kernel)
    3.47 -      CMSetProperty(instance, "VirtualSystemType", (CMPIValue *)"Xen Paravirtual", CMPI_chars);
    3.48 -   else if (resource->hvm_boot)
    3.49 -      CMSetProperty(instance, "VirtualSystemType", (CMPIValue *)"Xen HVM", CMPI_chars);
    3.50 -
    3.51 -   if (resource->pv_kernel)
    3.52 -      CMSetProperty(instance, "Kernel", (CMPIValue *)resource->pv_kernel, CMPI_chars);
    3.53 -   if (resource->pv_ramdisk)
    3.54 -      CMSetProperty(instance, "RAMDisk", (CMPIValue *)resource->pv_ramdisk, CMPI_chars);
    3.55 -   if (resource->pv_args)
    3.56 -      CMSetProperty(instance, "KernelOptions" , (CMPIValue *)resource->pv_args, CMPI_chars);
    3.57 -   if (resource->pv_bootloader)
    3.58 -      CMSetProperty(instance, "Bootloader", (CMPIValue *)resource->pv_bootloader, CMPI_chars);
    3.59 -   if (resource->pv_bootloader_args)
    3.60 -      CMSetProperty(instance, "BootloaderOptions", (CMPIValue *)resource->pv_bootloader_args, CMPI_chars);
    3.61 -
    3.62     if (resource->uuid)
    3.63        CMSetProperty(instance, "UUID", (CMPIValue *)resource->uuid, CMPI_chars);
    3.64  
    3.65 -   /*
    3.66 -    * TODO:
    3.67 -    * How do we want to handle specifying root?  Maybe just remove it
    3.68 -    * and make part of kernel args.  But what about boot loaders
    3.69 -    * requiring root partition to extract kernel?
    3.70 -    */
    3.71 -   //   if (resource->root != NULL) CMSetProperty(instance, "Root" , (CMPIValue *)resource->root, CMPI_chars);
    3.72 +   CMSetProperty(instance, "localtime", (CMPIValue *)&(resource->platform_localtime), CMPI_boolean);   
    3.73 +
    3.74 +   CMSetProperty(instance, "OnPoweroff", (CMPIValue *)&(resource->actions_after_shutdown), CMPI_uint16);   
    3.75 +   CMSetProperty(instance, "OnReboot", (CMPIValue *)&(resource->actions_after_reboot), CMPI_uint16);   
    3.76 +   CMSetProperty(instance, "OnCrash", (CMPIValue *)&(resource->actions_after_crash), CMPI_uint16);   
    3.77  
    3.78     return 1;
    3.79  }
     4.1 --- a/src/Xen_VirtualSystemManagementService.c	Fri Feb 23 14:56:02 2007 -0700
     4.2 +++ b/src/Xen_VirtualSystemManagementService.c	Mon Feb 26 14:52:36 2007 -0700
     4.3 @@ -1578,11 +1578,22 @@ static int vssd2xenconfig(CMPIInstance *
     4.4     if ((status->rc == CMPI_RC_OK) && !CMIsNullValue(propertyvalue))
     4.5        vm_rec->uuid = strdup(CMGetCharPtr(propertyvalue.value.string));
     4.6     
     4.7 -   /*
     4.8 -    * TODO:
     4.9 -    * 1. Handle defaults, e.g. missing required domain setting.
    4.10 -    */
    4.11 -
    4.12 +   propertyvalue = CMGetProperty(vssd, "localtime", status);
    4.13 +   if ((status->rc == CMPI_RC_OK) && !CMIsNullValue(propertyvalue))
    4.14 +      vm_rec->platform_localtime = propertyvalue.value.boolean;
    4.15 +   
    4.16 +   propertyvalue = CMGetProperty(vssd, "OnPoweroff", status);
    4.17 +   if ((status->rc == CMPI_RC_OK) && !CMIsNullValue(propertyvalue))
    4.18 +      vm_rec->actions_after_shutdown = propertyvalue.value.uint16;
    4.19 +   
    4.20 +   propertyvalue = CMGetProperty(vssd, "OnReboot", status);
    4.21 +   if ((status->rc == CMPI_RC_OK) && !CMIsNullValue(propertyvalue))
    4.22 +      vm_rec->actions_after_reboot = propertyvalue.value.uint16;
    4.23 +   
    4.24 +   propertyvalue = CMGetProperty(vssd, "OnCrash", status);
    4.25 +   if ((status->rc == CMPI_RC_OK) && !CMIsNullValue(propertyvalue))
    4.26 +      vm_rec->actions_after_crash = propertyvalue.value.uint16;
    4.27 +   
    4.28     /* Paravirtual or HVM domain? */
    4.29     propertyvalue = CMGetProperty(vssd, "VirtualSystemType", status);
    4.30     if ((status->rc != CMPI_RC_OK) || CMIsNullValue(propertyvalue)) {
    4.31 @@ -1640,38 +1651,6 @@ static int vssd2xenconfig(CMPIInstance *
    4.32        if ((status->rc == CMPI_RC_OK) && !CMIsNullValue(propertyvalue)) {
    4.33           vm_rec->pv_args = strdup(CMGetCharPtr(propertyvalue.value.string));
    4.34        }
    4.35 -   
    4.36 -      propertyvalue = CMGetProperty(vssd, "Root", status);
    4.37 -      if ((status->rc == CMPI_RC_OK) && !CMIsNullValue(propertyvalue)) {
    4.38 -         char *root = CMGetCharPtr(propertyvalue.value.string);
    4.39 -         int len;
    4.40 -         char *temp;
    4.41 -         if (vm_rec->pv_args) {
    4.42 -            char *args = vm_rec->pv_args;
    4.43 -            len = strlen(args) + strlen(root) + 6 + 1; /* 6 -> " root=" */
    4.44 -            temp = malloc(len);
    4.45 -            if (temp == NULL) {
    4.46 -               free(args);
    4.47 -               _SBLIM_TRACE(1,("--- Cannot malloc memory for kernel args"));
    4.48 -               CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERROR_SYSTEM, "Unable to malloc memory");
    4.49 -               return 0;
    4.50 -            }
    4.51 -            snprintf(temp, len, "%s root=%s", args, root);
    4.52 -            vm_rec->pv_args = temp;
    4.53 -            free(args);
    4.54 -         }
    4.55 -         else {
    4.56 -            len = strlen(root) + 5 + 1; /* 5 -> "root=" */
    4.57 -            temp = malloc(len);
    4.58 -            if (temp == NULL) {
    4.59 -               _SBLIM_TRACE(1,("--- Cannot malloc memory for kernel args"));
    4.60 -               CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERROR_SYSTEM, "Unable to malloc memory");
    4.61 -               return 0;
    4.62 -            }
    4.63 -            snprintf(temp, len, "root=%s", root);
    4.64 -            vm_rec->pv_args = temp;
    4.65 -         }
    4.66 -      }
    4.67     }
    4.68     else if (strcasecmp(vsType, "Xen HVM") == 0) {
    4.69        propertyvalue = CMGetProperty(vssd, "BootOrder", status);
    4.70 @@ -1682,6 +1661,10 @@ static int vssd2xenconfig(CMPIInstance *
    4.71           return 0;
    4.72        }
    4.73        vm_rec->hvm_boot = strdup(CMGetCharPtr(propertyvalue.value.string));
    4.74 +      
    4.75 +      propertyvalue = CMGetProperty(vssd, "stdvga", status);
    4.76 +      if ((status->rc == CMPI_RC_OK) && !CMIsNullValue(propertyvalue))
    4.77 +         vm_rec->platform_std_vga = propertyvalue.value.boolean;
    4.78     }
    4.79     else {
    4.80        _SBLIM_TRACE(1,("--- Invalide VirtualSystemType %s specified", vsType));