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