[Libvirt-cim] [PATCH] Add support for StoragePool autostart

Chip Vincent cvincent at linux.vnet.ibm.com
Mon Apr 25 14:48:02 UTC 2011


+1

On 04/14/2011 01:01 PM, Sharad Mishra wrote:
> # HG changeset patch
> # User Sharad Mishra<snmishra at us.ibm.com>
> # Date 1302722853 25200
> # Node ID b1695aa081851829a25a8210bef8de0348c7b089
> # Parent  a521a11eeec4b41399ca954ab17b874a708eb4b3
> Add support for StoragePool autostart.
>
> This patch adds support to set autostart on StoragePools
>
> Signed-off-by: Sharad Mishra<snmishra at us.ibm.com>
>
> diff -r a521a11eeec4 -r b1695aa08185 libxkutil/pool_parsing.c
> --- a/libxkutil/pool_parsing.c	Wed Mar 23 09:32:46 2011 -0700
> +++ b/libxkutil/pool_parsing.c	Wed Apr 13 12:27:33 2011 -0700
> @@ -241,6 +241,7 @@
>           const xmlChar *xpathstr = (xmlChar *)"/pool";
>           const char *name;
>
> +        CU_DEBUG("Pool XML : %s", xml);
>   	len = strlen(xml) + 1;
>
>           if ((xmldoc = xmlParseMemory(xml, len)) == NULL)
> @@ -277,11 +278,11 @@
>           return ret;
>   }
>
> -int define_pool(virConnectPtr conn, const char *xml, int res_type)
> +int define_pool(virConnectPtr conn, const char *xml, struct virt_pool *pool)
>   {
>           int ret = 1;
>
> -        if (res_type == CIM_RES_TYPE_NET) {
> +        if (pool->type == CIM_RES_TYPE_NET) {
>                   virNetworkPtr ptr = virNetworkDefineXML(conn, xml);
>                   if (ptr == NULL) {
>                           CU_DEBUG("Unable to define virtual network");
> @@ -297,7 +298,7 @@
>                   }
>
>                   virNetworkFree(ptr);
> -        } else if (res_type == CIM_RES_TYPE_DISK) {
> +        } else if (pool->type == CIM_RES_TYPE_DISK) {
>   #if VIR_USE_LIBVIRT_STORAGE
>                   virStoragePoolPtr ptr = virStoragePoolDefineXML(conn, xml, 0);
>                   if (ptr == NULL) {
> @@ -313,6 +314,11 @@
>                                   CU_DEBUG("Unable to undefine storage pool");
>                   }
>
> +                if (pool->pool_info.disk.autostart == 1) {
> +                        if (virStoragePoolSetAutostart(ptr, 1) != 0)
> +                                CU_DEBUG("Unable to set autostart for pool");
> +                }
> +
>                   virStoragePoolFree(ptr);
>   #endif
>           }
> diff -r a521a11eeec4 -r b1695aa08185 libxkutil/pool_parsing.h
> --- a/libxkutil/pool_parsing.h	Wed Mar 23 09:32:46 2011 -0700
> +++ b/libxkutil/pool_parsing.h	Wed Apr 13 12:27:33 2011 -0700
> @@ -53,6 +53,7 @@
>           char *adapter;
>           char *port_name;
>           char *node_name;
> +        uint16_t autostart;
>   };
>
>   struct virt_pool {
> @@ -89,7 +90,7 @@
>   int get_pool_from_xml(const char *xml, struct virt_pool *pool, int type);
>   char *get_disk_pool_type(uint16_t type);
>
> -int define_pool(virConnectPtr conn, const char *xml, int res_type);
> +int define_pool(virConnectPtr conn, const char *xml, struct virt_pool *pool);
>   int destroy_pool(virConnectPtr conn, const char *name, int res_type);
>
>   char *create_resource(virConnectPtr conn, const char *pname,
> diff -r a521a11eeec4 -r b1695aa08185 schema/ResourceAllocationSettingData.mof
> --- a/schema/ResourceAllocationSettingData.mof	Wed Mar 23 09:32:46 2011 -0700
> +++ b/schema/ResourceAllocationSettingData.mof	Wed Apr 13 12:27:33 2011 -0700
> @@ -350,6 +350,7 @@
>           Values {"Unknown", "Directory, File System, Network File System, "
>                   "Disk, ISCSI, Logical, SCSI Host Bus Adapter"}]
>         uint16 Type;
> +      uint16 Autostart;
>         string Path;
>         string DevicePaths[];
>         string Host;
> @@ -369,6 +370,7 @@
>           Values {"Unknown", "Directory, File System, Network File System, "
>                   "Disk, ISCSI, Logical, SCSI Host Bus Adapter"}]
>         uint16 Type;
> +      uint16 Autostart;
>         string Path;
>         string DevicePaths[];
>         string Host;
> @@ -388,6 +390,7 @@
>           Values {"Unknown", "Directory, File System, Network File System, "
>                   "Disk, ISCSI, Logical, SCSI Host Bus Adapter"}]
>         uint16 Type;
> +      uint16 Autostart;
>         string Path;
>         string DevicePaths[];
>         string Host;
> diff -r a521a11eeec4 -r b1695aa08185 src/Virt_DevicePool.c
> --- a/src/Virt_DevicePool.c	Wed Mar 23 09:32:46 2011 -0700
> +++ b/src/Virt_DevicePool.c	Wed Apr 13 12:27:33 2011 -0700
> @@ -101,6 +101,8 @@
>           if (xml == NULL)
>                   return 0;
>
> +        CU_DEBUG("pool xml is %s", xml);
> +
>           *pool = malloc(sizeof(**pool));
>           if (*pool == NULL) {
>                   ret = 0;
> @@ -175,6 +177,8 @@
>           uint16_t type;
>           struct virt_pool *pool_vals = NULL;
>           const char *pool_str = NULL;
> +        uint16_t autostart;
> +        int  start;
>
>           pool = virStoragePoolLookupByName(conn, _pool->tag);
>           if (pool == NULL) {
> @@ -215,6 +219,17 @@
>                                 CMPI_chars);
>           }
>
> +        if (virStoragePoolGetAutostart(pool,&start) == -1) {
> +                CU_DEBUG("Failed to read if %s StoragePool is set for "
> +                         "Autostart", _pool->tag);
> +                goto out;
> +        }
> +
> +        autostart = start;
> +
> +        CMSetProperty(inst, "Autostart",
> +                      (CMPIValue *)&autostart, CMPI_uint16);
> +
>           result = true;
>    out:
>           virStoragePoolFree(pool);
> diff -r a521a11eeec4 -r b1695aa08185 src/Virt_ResourcePoolConfigurationService.c
> --- a/src/Virt_ResourcePoolConfigurationService.c	Wed Mar 23 09:32:46 2011 -0700
> +++ b/src/Virt_ResourcePoolConfigurationService.c	Wed Apr 13 12:27:33 2011 -0700
> @@ -150,6 +150,7 @@
>           pool->pool_info.disk.adapter = NULL;
>           pool->pool_info.disk.port_name = NULL;
>           pool->pool_info.disk.node_name = NULL;
> +        pool->pool_info.disk.autostart = 0;
>   }
>
>   static char *get_dev_paths(CMPIInstance *inst,
> @@ -289,6 +290,7 @@
>           const char *val = NULL;
>           const char *msg = NULL;
>           uint16_t type;
> +        uint16_t autostart;
>
>           if (cu_get_u16_prop(inst, "Type",&type) != CMPI_RC_OK)
>                   return "Missing `Type' property";
> @@ -326,6 +328,14 @@
>
>           pool->pool_info.disk.path = strdup(val);
>
> +        if (cu_get_u16_prop(inst, "Autostart",&autostart) != CMPI_RC_OK) {
> +                CU_DEBUG("Failed to get Autostart, defaulting "
> +                         "to no autostart");
> +                autostart = 0;
> +        }
> +
> +        pool->pool_info.disk.autostart = autostart;
> +
>    out:
>           return msg;
>
> @@ -440,7 +450,7 @@
>   static CMPIInstance *connect_and_create(char *xml,
>                                           const CMPIObjectPath *ref,
>                                           const char *id,
> -                                        int res_type,
> +                                        struct virt_pool *pool,
>                                           CMPIStatus *s)
>   {
>           virConnectPtr conn;
> @@ -452,7 +462,7 @@
>                   return NULL;
>           }
>
> -        if (define_pool(conn, xml, res_type) == 0) {
> +        if (define_pool(conn, xml, pool) == 0) {
>                   virt_set_status(_BROKER, s,
>                                   CMPI_RC_ERR_FAILED,
>                                   conn,
> @@ -544,7 +554,7 @@
>
>           CU_DEBUG("Pool XML:\n%s", xml);
>
> -        inst = connect_and_create(xml, reference, full_id, pool->type,&s);
> +        inst = connect_and_create(xml, reference, full_id, pool,&s);
>           if (s.rc != CMPI_RC_OK)
>                   goto out;
>
> diff -r a521a11eeec4 -r b1695aa08185 src/Virt_SettingsDefineCapabilities.c
> --- a/src/Virt_SettingsDefineCapabilities.c	Wed Mar 23 09:32:46 2011 -0700
> +++ b/src/Virt_SettingsDefineCapabilities.c	Wed Apr 13 12:27:33 2011 -0700
> @@ -1521,19 +1521,24 @@
>                          DISK_POOL_SCSI};
>           int pool_types = 7;
>           int i;
> +        uint16_t autostart;
>
>           switch (template_type) {
>           case SDC_RASD_MIN:
>                   id = "Minimum";
> +                autostart = 0;
>                   break;
>           case SDC_RASD_MAX:
>                   id = "Maximum";
> +                autostart = 1;
>                   break;
>           case SDC_RASD_INC:
>                   id = "Increment";
> +                autostart = 1;
>                   break;
>           case SDC_RASD_DEF:
>                   id = "Default";
> +                autostart = 0;
>                   break;
>           default:
>                   cu_statusf(_BROKER,&s,
> @@ -1633,6 +1638,8 @@
>
>                   CMSetProperty(inst, "Type", (CMPIValue *)&type[i], CMPI_uint16);
>                   CMSetProperty(inst, "Path", (CMPIValue *)path, CMPI_chars);
> +                CMSetProperty(inst, "Autostart", (CMPIValue *)&autostart,
> +                              CMPI_uint16);
>
>                   inst_list_add(list, inst);
>           }
>
> _______________________________________________
> Libvirt-cim mailing list
> Libvirt-cim at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-cim

-- 
Chip Vincent
Open Virtualization
IBM Linux Technology Center
cvincent at linux.vnet.ibm.com




More information about the Libvirt-cim mailing list