[Libvirt-cim] [PATCH 2 of 3] Add support to fetch data from BootDevices property to the internal data structure

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Wed Jun 3 15:59:11 UTC 2009


> diff -r abc90cae6c08 -r f2cb4b64756a src/Virt_VirtualSystemManagementService.c
> --- a/src/Virt_VirtualSystemManagementService.c	Mon Jun 01 18:19:38 2009 -0300
> +++ b/src/Virt_VirtualSystemManagementService.c	Mon Jun 01 18:19:43 2009 -0300
> @@ -197,6 +197,69 @@
>          return kvm;
>  }
> 
> +static int bootord_vssd_to_domain(CMPIInstance *inst,
> +                                  struct domain *domain)
> +{
> +        int ret;
> +        CMPICount i;
> +        CMPIArray *bootlist;
> +        CMPIStatus s;
> +        CMPIData boot_elem;
> +        char **tmp_str_arr;
> +
> +        for (i = 0; i < domain->os_info.fv.bootlist_ct; i++)
> +                free(domain->os_info.fv.bootlist[i]);
> +
> +        ret = cu_get_array_prop(inst, "BootDevices", &bootlist);
> +       
> +        if (ret == CMPI_RC_OK) {

You can save some indention here by doing something like:

if (ret != CMPI_RC_OK) {
         CU_DEBUG("Failed to get BootDevices property");
         return 1;
}


> +
> +                        str = CMGetCharPtr(boot_elem.value.string);
> +
> +                        if (s.rc != CMPI_RC_OK) {

Instead of checking the value of s.rc, you want to check to see if str 
is NULL.

> +                                CU_DEBUG("Could not extract char pointer from "
> +                                         "CMPIArray");
> +                                return 0;
> +                        }
> +
> +                        tmp_str_arr[i] = strdup(str);
> +                }
> +                domain->os_info.fv.bootlist_ct = bl_size;
> +                domain->os_info.fv.bootlist = tmp_str_arr;
> +
> +        } else 
> +                CU_DEBUG("Failed to get BootDevices property"); 
> +
> +        return 1;
> +}
> +
>  static int fv_vssd_to_domain(CMPIInstance *inst,
>                               struct domain *domain,
>                               const char *pfx)


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




More information about the Libvirt-cim mailing list