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

Richard Maciel rmaciel at linux.vnet.ibm.com
Tue Jun 2 16:47:32 UTC 2009


# HG changeset patch
# User Richard Maciel <rmaciel at linux.vnet.ibm.com>
# Date 1243891183 10800
# Node ID f2cb4b64756a0f0eb284198cf47834c14f0d1f24
# Parent  abc90cae6c08598d0ada357a6cf2f4bb2b2cd1c7
Add support to fetch data from BootDevices property to the internal data structure

Signed-off-by: Richard Maciel <rmaciel at linux.vnet.ibm.com>

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) {
+                CMPICount bl_size;
+
+                bl_size = CMGetArrayCount(bootlist, &s);
+                if (s.rc != CMPI_RC_OK) {
+                        CU_DEBUG("Invalid BootDevice array size");
+                        return 0;
+                }
+
+                tmp_str_arr = (char **)realloc(domain->os_info.fv.bootlist,
+                                               bl_size * sizeof(char *));
+
+                if (tmp_str_arr == NULL) {
+                        CU_DEBUG("Could not alloc BootDevices array");
+                        return 0;
+                }
+
+                for (i = 0; i < bl_size; i++) {
+                        const char *str;
+
+                        boot_elem = CMGetArrayElementAt(bootlist, 
+                                                        i, 
+                                                        NULL); 
+
+                        if (CMIsNullValue(boot_elem)) {
+                                CU_DEBUG("Null BootDevice");
+                                return 0;
+                        }
+
+                        str = CMGetCharPtr(boot_elem.value.string);
+
+                        if (s.rc != CMPI_RC_OK) {
+                                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)
@@ -216,12 +279,9 @@
                 return 0;
         }
 
-        ret = cu_get_str_prop(inst, "BootDevice", &val);
-        if (ret != CMPI_RC_OK)
-                val = "hd";
-
-        free(domain->os_info.fv.boot);
-        domain->os_info.fv.boot = strdup(val);
+        ret = bootord_vssd_to_domain(inst, domain);
+        if (ret != 1)
+                return 0;
 
         ret = cu_get_str_prop(inst, "Emulator", &val);
         if (ret != CMPI_RC_OK)




More information about the Libvirt-cim mailing list