Blame SOURCES/libvirt-cim-0.6.3-6bc7bfdf.patch

c55d09
From 6bc7bfdf7a162b0812bfe8e6f73e5fde3925e001 Mon Sep 17 00:00:00 2001
c55d09
From: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
c55d09
Date: Mon, 14 Oct 2013 17:29:43 +0200
c55d09
Subject: [PATCH 28/60] VSMS: Support for device addresses
c55d09
c55d09
This allows to define KVM guests with persistent device addresses
c55d09
for disks and network interfaces.
c55d09
The new function rasd_to_device_address extracts the address
c55d09
properties from the disk or network RASD and fills the
c55d09
device_address sub-structure of the affected virt_device.
c55d09
c55d09
Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
c55d09
Signed-off-by: John Ferlan <jferlan@redhat.com>
c55d09
---
c55d09
 src/Virt_VirtualSystemManagementService.c | 51 ++++++++++++++++++++++++++++++-
c55d09
 1 file changed, 50 insertions(+), 1 deletion(-)
c55d09
c55d09
diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c
c55d09
index d51f230..b813be6 100644
c55d09
--- a/src/Virt_VirtualSystemManagementService.c
c55d09
+++ b/src/Virt_VirtualSystemManagementService.c
c55d09
@@ -890,6 +890,50 @@ static const char *_net_rand_mac(const CMPIObjectPath *ref)
c55d09
         return _mac;
c55d09
 }
c55d09
 
c55d09
+static const char *rasd_to_device_address(CMPIInstance *inst,
c55d09
+                                          struct device_address *addr)
c55d09
+{
c55d09
+        CMPICount c1;
c55d09
+        CMPICount c2;
c55d09
+        CMPIArray *arr_keys;
c55d09
+        CMPIArray *arr_values;
c55d09
+        CMPIData data_key;
c55d09
+        CMPIData data_value;
c55d09
+        const char *str_key;
c55d09
+        const char *str_value;
c55d09
+        int i;
c55d09
+        const char * msg = NULL;
c55d09
+
c55d09
+        if (cu_get_array_prop(inst, "AddressProperties", &arr_keys) != CMPI_RC_OK ||
c55d09
+            cu_get_array_prop(inst, "AddressValues", &arr_values) != CMPI_RC_OK)
c55d09
+                goto out;
c55d09
+
c55d09
+        c1 = CMGetArrayCount(arr_keys, NULL);
c55d09
+        c2 = CMGetArrayCount(arr_values, NULL);
c55d09
+
c55d09
+        if (c1 != c2) {
c55d09
+                msg = "AddressProperties not matching AddressValues";
c55d09
+                goto out;
c55d09
+        }
c55d09
+
c55d09
+        for (i = 0; i < c1; i++) {
c55d09
+                data_key = CMGetArrayElementAt(arr_keys, i, NULL);
c55d09
+                data_value = CMGetArrayElementAt(arr_values, i, NULL);
c55d09
+
c55d09
+                if (!CMIsNullValue(data_key) && !CMIsNullValue(data_key)) {
c55d09
+                        str_key = CMGetCharPtr(data_key.value.string);
c55d09
+                        str_value = CMGetCharPtr(data_value.value.string);
c55d09
+                        if (!add_device_address_property(addr, str_key, str_value)) {
c55d09
+                                msg = "Could not set address properties in vdev";
c55d09
+                                goto out;
c55d09
+                        }
c55d09
+                }
c55d09
+        }
c55d09
+
c55d09
+ out:
c55d09
+        return msg;
c55d09
+}
c55d09
+
c55d09
 static const char *net_rasd_to_vdev(CMPIInstance *inst,
c55d09
                                     struct virt_device *dev,
c55d09
                                     const char *ns)
c55d09
@@ -1040,6 +1084,8 @@ static const char *net_rasd_to_vdev(CMPIInstance *inst,
c55d09
                             &dev->dev.net.limit) != CMPI_RC_OK)
c55d09
                 dev->dev.net.limit = 0;
c55d09
 
c55d09
+        msg = rasd_to_device_address(inst, &dev->dev.net.address);
c55d09
+
c55d09
  out:
c55d09
         free(network);
c55d09
         return msg;
c55d09
@@ -1050,6 +1096,7 @@ static const char *disk_rasd_to_vdev(CMPIInstance *inst,
c55d09
                                      char **p_error)
c55d09
 {
c55d09
         const char *val = NULL;
c55d09
+        const char *msg = NULL;
c55d09
         uint16_t type;
c55d09
         bool read = false;
c55d09
         int rc;
c55d09
@@ -1161,7 +1208,9 @@ static const char *disk_rasd_to_vdev(CMPIInstance *inst,
c55d09
         free(dev->id);
c55d09
         dev->id = strdup(dev->dev.disk.virtual_dev);
c55d09
 
c55d09
-        return NULL;
c55d09
+        msg = rasd_to_device_address(inst, &dev->dev.disk.address);
c55d09
+
c55d09
+        return msg;
c55d09
 }
c55d09
 
c55d09
 static const char *lxc_disk_rasd_to_vdev(CMPIInstance *inst,
c55d09
-- 
c55d09
2.1.0
c55d09