Blame SOURCES/libvirt-cim-0.6.3-a72ab39b.patch

9c78f5
From a72ab39ba75702676af64af30d9412f5d7730cd9 Mon Sep 17 00:00:00 2001
9c78f5
From: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
9c78f5
Date: Mon, 14 Oct 2013 17:29:42 +0200
9c78f5
Subject: [PATCH 27/60] RASD: Support for device address properties
9c78f5
9c78f5
This change allows to enumerate KVM disk and network RASDs containing
9c78f5
device addresses. A new function set_rasd_device_address fills the
9c78f5
CIM instance properties from a device_address structure.
9c78f5
9c78f5
Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
9c78f5
Signed-off-by: John Ferlan <jferlan@redhat.com>
9c78f5
---
9c78f5
 src/Virt_RASD.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
9c78f5
 1 file changed, 73 insertions(+)
9c78f5
9c78f5
diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c
9c78f5
index e28d4e6..df1e921 100644
9c78f5
--- a/src/Virt_RASD.c
9c78f5
+++ b/src/Virt_RASD.c
9c78f5
@@ -289,6 +289,67 @@ static bool get_vol_size(const CMPIBroker *broker,
9c78f5
 }
9c78f5
 #endif
9c78f5
 
9c78f5
+static CMPIStatus set_rasd_device_address(const CMPIBroker *broker,
9c78f5
+                                          const CMPIObjectPath *ref,
9c78f5
+                                          const struct device_address *addr,
9c78f5
+                                          CMPIInstance *inst)
9c78f5
+{
9c78f5
+        int i;
9c78f5
+        CMPIArray *arr_key;
9c78f5
+        CMPIArray *arr_value;
9c78f5
+        CMPIString *string;
9c78f5
+        CMPIStatus s = {CMPI_RC_OK, NULL};
9c78f5
+
9c78f5
+        arr_key = CMNewArray(broker,
9c78f5
+                             addr->ct,
9c78f5
+                             CMPI_string,
9c78f5
+                             &s);
9c78f5
+        if (s.rc != CMPI_RC_OK)
9c78f5
+                goto out;
9c78f5
+
9c78f5
+        arr_value = CMNewArray(broker,
9c78f5
+                               addr->ct,
9c78f5
+                               CMPI_string,
9c78f5
+                               &s);
9c78f5
+        if (s.rc != CMPI_RC_OK)
9c78f5
+                goto out;
9c78f5
+
9c78f5
+        for (i = 0; i < addr->ct; i++) {
9c78f5
+                string = CMNewString(broker,
9c78f5
+                                     addr->key[i],
9c78f5
+                                     &s);
9c78f5
+                if (s.rc != CMPI_RC_OK)
9c78f5
+                        goto out;
9c78f5
+
9c78f5
+                CMSetArrayElementAt(arr_key,
9c78f5
+                                    i,
9c78f5
+                                    (CMPIValue *)&string,
9c78f5
+                                    CMPI_string);
9c78f5
+
9c78f5
+                string = CMNewString(broker,
9c78f5
+                                     addr->value[i],
9c78f5
+                                     &s);
9c78f5
+                if (s.rc != CMPI_RC_OK)
9c78f5
+                        goto out;
9c78f5
+
9c78f5
+                CMSetArrayElementAt(arr_value,
9c78f5
+                                    i,
9c78f5
+                                    (CMPIValue *)&string,
9c78f5
+                                    CMPI_string);
9c78f5
+        }
9c78f5
+
9c78f5
+        CMSetProperty(inst, "AddressProperties",
9c78f5
+                      (CMPIValue *)&arr_key,
9c78f5
+                      CMPI_stringA);
9c78f5
+
9c78f5
+        CMSetProperty(inst, "AddressValues",
9c78f5
+                      (CMPIValue *)&arr_value,
9c78f5
+                      CMPI_stringA);
9c78f5
+
9c78f5
+ out:
9c78f5
+        return s;
9c78f5
+}
9c78f5
+
9c78f5
 static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker,
9c78f5
                                        const CMPIObjectPath *ref,
9c78f5
                                        const struct virt_device *dev,
9c78f5
@@ -427,6 +488,12 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker,
9c78f5
                               (CMPIValue *)&(dev->dev.disk.shareable),
9c78f5
                               CMPI_boolean);
9c78f5
 
9c78f5
+        if (dev->dev.disk.address.ct > 0)
9c78f5
+                set_rasd_device_address(broker,
9c78f5
+                                        ref,
9c78f5
+                                        &dev->dev.disk.address,
9c78f5
+                                        inst);
9c78f5
+
9c78f5
         virStoragePoolFree(pool);
9c78f5
         virStorageVolFree(vol);
9c78f5
         virConnectClose(conn);
9c78f5
@@ -590,6 +657,12 @@ static CMPIStatus set_net_rasd_params(const CMPIBroker *broker,
9c78f5
                               (CMPIValue *)dev->dev.net.poolid,
9c78f5
                               CMPI_chars);
9c78f5
 
9c78f5
+        if (dev->dev.net.address.ct > 0)
9c78f5
+                set_rasd_device_address(broker,
9c78f5
+                                        ref,
9c78f5
+                                        &dev->dev.net.address,
9c78f5
+                                        inst);
9c78f5
+
9c78f5
 #if LIBVIR_VERSION_NUMBER < 9000
9c78f5
 out:
9c78f5
 #endif
9c78f5
-- 
9c78f5
2.1.0
9c78f5