[Libvirt-cim] [PATCH] Add ForwardDevice attribute for network pools

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Thu Apr 30 23:08:34 UTC 2009


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1241132900 25200
# Node ID 327098c60da19f0f3c2c0a3ec69955503a16602a
# Parent  94b1108c2a8be28472a171d9a09d08a2580cc53f
Add ForwardDevice attribute for network pools

libvirt allows you to restrict the firewall rules of a pool so that traffic
is forwarded through a specific device.

Also, fix a bug where the value for ForwardMode specified by the user wasn't
being read in properly.  Also change FowardMode to a value map attribute
instead of a string.

Fix a bug where the value for IPRangeStart is read in twice - IPRangeEnd wasn't
being read in at all.

Fix a bug in xmlgen code for the network pool forwarding device.

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r 94b1108c2a8b -r 327098c60da1 libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c	Thu Apr 30 13:46:35 2009 -0700
+++ b/libxkutil/xmlgen.c	Thu Apr 30 16:08:20 2009 -0700
@@ -785,7 +785,7 @@
                         if (xmlNewProp(forward,
                                        BAD_CAST "dev",
                                        BAD_CAST pool->forward_dev) == NULL)
-                        goto out;
+                                goto out;
                 }
         }
 
diff -r 94b1108c2a8b -r 327098c60da1 schema/ResourceAllocationSettingData.mof
--- a/schema/ResourceAllocationSettingData.mof	Thu Apr 30 13:46:35 2009 -0700
+++ b/schema/ResourceAllocationSettingData.mof	Thu Apr 30 16:08:20 2009 -0700
@@ -171,7 +171,12 @@
       string Netmask;
       string IPRangeStart;
       string IPRangeEnd;
-      string ForwardMode;
+      string ForwardDevice;
+
+      [Description ("Network pool forwarding mode"),
+        ValueMap {"0", "1", "2"},
+        Values {"None", "NAT", "Routed"}]
+      uint16 ForwardMode;
 };
 
 [Description ("KVM virtual network pool settings"),
@@ -182,7 +187,12 @@
       string Netmask;
       string IPRangeStart;
       string IPRangeEnd;
-      string ForwardMode;
+      string ForwardDevice;
+
+      [Description ("Network pool forwarding mode"),
+        ValueMap {"0", "1", "2"},
+        Values {"None", "NAT", "Routed"}]
+      uint16 ForwardMode;
 };
 
 [Description ("LXC virtual network pool settings"),
@@ -193,7 +203,12 @@
       string Netmask;
       string IPRangeStart;
       string IPRangeEnd;
-      string ForwardMode;
+      string ForwardDevice;
+
+      [Description ("Network pool forwarding mode"),
+        ValueMap {"0", "1", "2"},
+        Values {"None", "NAT", "Routed"}]
+      uint16 ForwardMode;
 };
 
 [Description ("Xen virtual disk pool settings"),
diff -r 94b1108c2a8b -r 327098c60da1 src/Virt_ResourcePoolConfigurationService.c
--- a/src/Virt_ResourcePoolConfigurationService.c	Thu Apr 30 13:46:35 2009 -0700
+++ b/src/Virt_ResourcePoolConfigurationService.c	Thu Apr 30 16:08:20 2009 -0700
@@ -82,6 +82,7 @@
 {
         const char *val = NULL;
         const char *msg = NULL;
+        uint16_t type;
 
         /*FIXME:  Need to add validation of addresses if user specified */
 
@@ -103,12 +104,37 @@
         free(pool->pool_info.net.ip_start);
         pool->pool_info.net.ip_start = strdup(val);
 
-        if (cu_get_str_prop(inst, "IPRangeStart", &val) != CMPI_RC_OK)
+        if (cu_get_str_prop(inst, "IPRangeEnd", &val) != CMPI_RC_OK)
                 val = "192.168.122.254";
 
         free(pool->pool_info.net.ip_end);
         pool->pool_info.net.ip_end = strdup(val);
 
+        if (cu_get_u16_prop(inst, "ForwardMode", &type) != CMPI_RC_OK) {
+                pool->pool_info.net.forward_mode = strdup("nat");
+        } else {
+                free(pool->pool_info.net.forward_mode);
+
+                switch (type) {
+                case NETPOOL_FORWARD_NONE:
+                        pool->pool_info.net.forward_mode = NULL;
+                        break;
+                case NETPOOL_FORWARD_NAT:
+                        pool->pool_info.net.forward_mode = strdup("nat");
+                        break;
+                case NETPOOL_FORWARD_ROUTED:
+                        pool->pool_info.net.forward_mode = strdup("route");
+                        break;
+                default:
+                        return "Storage pool type not supported";
+                }
+        }
+
+        if (cu_get_str_prop(inst, "ForwardDevice", &val) == CMPI_RC_OK) {
+                free(pool->pool_info.net.forward_dev);
+                pool->pool_info.net.forward_dev = strdup(val);
+        }
+
         return msg;
 
 }
diff -r 94b1108c2a8b -r 327098c60da1 src/svpc_types.h
--- a/src/svpc_types.h	Thu Apr 30 13:46:35 2009 -0700
+++ b/src/svpc_types.h	Thu Apr 30 16:08:20 2009 -0700
@@ -66,6 +66,10 @@
 #define CIM_SAP_INACTIVE_STATE  3
 #define CIM_SAP_AVAILABLE_STATE 6
 
+#define NETPOOL_FORWARD_NONE 0
+#define NETPOOL_FORWARD_NAT 1
+#define NETPOOL_FORWARD_ROUTED 2
+
 #include <libcmpiutil/libcmpiutil.h>
 #include <string.h>
 




More information about the Libvirt-cim mailing list