[Libvirt-cim] [PATCH 1 of 3] Added support to convert data in the internal format to the format used by the BootDevices property

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Thu Jun 4 13:50:28 UTC 2009


> diff -r 849171d2fbc0 -r e18c6d4d2ea4 src/Virt_VSSD.c
> --- a/src/Virt_VSSD.c	Mon Jun 01 14:01:21 2009 -0700
> +++ b/src/Virt_VSSD.c	Mon Jun 01 18:19:38 2009 -0300
> @@ -38,20 +38,91 @@
> 
>  const static CMPIBroker *_BROKER;
> 
> -static void _set_fv_prop(struct domain *dominfo,
> -                         CMPIInstance *inst)
> +static CMPIStatus _set_fv_prop(const CMPIBroker *broker,
> +                               struct domain *dominfo,
> +                               CMPIInstance *inst)
>  {
>          bool fv = true;
> +        CMPIArray *array;
> +        CMPICount bl_ct;
> +        CMPIStatus s = {CMPI_RC_OK, NULL};
> +        CMPICount i;
> 
>          if (dominfo->type == DOMAIN_XENFV)
>                  CMSetProperty(inst, "IsFullVirt",
>                                (CMPIValue *)&fv, CMPI_boolean);
> 
> -        if (dominfo->os_info.fv.boot != NULL)
> -                CMSetProperty(inst,
> -                              "BootDevice",
> -                              (CMPIValue *)dominfo->os_info.fv.boot,
> -                              CMPI_chars);
> +        bl_ct = dominfo->os_info.fv.bootlist_ct;
> +        if (bl_ct < 0) 
> +                return s;
> +
> +        CU_DEBUG("bootlist_ct = %d", bl_ct);
> +                
> +        array = CMNewArray(broker, 
> +                           bl_ct,
> +                           CMPI_string,
> +                           &s);
> +
> +        if (s.rc != CMPI_RC_OK) {
> +                cu_statusf(_BROKER, &s, 

This should be the broker that is passed in to the function, instead of 
using the provider's _BROKER.

> +                           CMPI_RC_ERR_FAILED, 
> +                           "Error creating BootDevices list");
> +                CU_DEBUG("CMNewArray call failed");
> +
> +                goto out;
> +        }
> +
> +        for (i = 0; i < bl_ct; i++) {
> +                CMPIString *cm_str;
> +
> +                CU_DEBUG("BootList[%u]=%s",
> +                         i,
> +                         dominfo->os_info.fv.bootlist[i]);
> +
> +                cm_str = CMNewString(broker,
> +                                     (const char *)dominfo->os_info.
> +                                     fv.bootlist[i],
> +                                     &s);
> +                if (s.rc != CMPI_RC_OK) {
> +                        CU_DEBUG("Error creating CMPIString");
> +                        cu_statusf(_BROKER, &s, 

Same here.

> +                                   CMPI_RC_ERR_FAILED, 
> +                                   "Error creating CMPIString for " 
> +                                   "BootDevices item");
> +
> +                        goto out;
> +                }
> +
> +                s = CMSetArrayElementAt(array,
> +                                        i,
> +                                        (CMPIValue *)&cm_str,
> +                                        CMPI_string);
> +                if (s.rc != CMPI_RC_OK) {
> +                        CU_DEBUG("Error in CMSetArrayElementAT call");
> +                        cu_statusf(_BROKER, &s, 

Here as well.

> +                                   CMPI_RC_ERR_FAILED, 
> +                                   "Error setting BootDevices array element");
> +
> +                        goto out;
> +                }
> +        }
> +
> +        s = CMSetProperty(inst,
> +                          "BootDevices",
> +                          (CMPIValue *)&array,
> +                          CMPI_stringA);
> +
> +        if (s.rc != CMPI_RC_OK) {
> +                CU_DEBUG("Error in CMSetProperty call");
> +                cu_statusf(_BROKER, &s, 

And here.

> +                           CMPI_RC_ERR_FAILED, 
> +                           "Error setting BootDevices property");
> +
> +                goto out;
> +        }
> +
> + out:
> +        return s;
>  }
> 

-- 
Kaitlin Rupert
IBM Linux Technology Center
kaitlin at linux.vnet.ibm.com




More information about the Libvirt-cim mailing list