[PATCH 0 of 4] Add IPv6 Support

# HG changeset patch # User Sharad Mishra <snmishra@us.ibm.com> # Date 1257536605 28800 # Node ID 131932045d30226468c63942407321f29c65a33f # Parent 906a78ecf9f3e4972133c6792c1ff543cc57b493 (#2) This patch adds support for IPv6 in KVMRedirectionSAP provider. The code now loops through currently active IPv4 and IPv6 connections. It tries to read both /proc/net/tcp and /proc/net/tcp6 files. If one of the two files is successfully read, it does not return an error. For the function to return an error, both IPv4 and IPv6 file reads should fail. Signed-off-by: Sharad Mishra <snmishra@us.ibm.com> diff -r 906a78ecf9f3 -r 131932045d30 src/Virt_KVMRedirectionSAP.c --- a/src/Virt_KVMRedirectionSAP.c Mon Oct 05 06:02:39 2009 -0700 +++ b/src/Virt_KVMRedirectionSAP.c Fri Nov 06 11:43:25 2009 -0800 @@ -39,7 +39,8 @@ #include "Virt_KVMRedirectionSAP.h" -#define PROC_TCP "/proc/net/tcp" +#define PROC_TCP4 "/proc/net/tcp" +#define PROC_TCP6 "/proc/net/tcp6" const static CMPIBroker *_BROKER; @@ -139,50 +140,47 @@ return inst; } -static CMPIStatus get_vnc_sessions(const CMPIBroker *broker, - const CMPIObjectPath *ref, - virConnectPtr conn, - struct vnc_ports ports, - struct inst_list *list) +static CMPIStatus read_tcp_file(const CMPIBroker *broker, + const CMPIObjectPath *ref, + virConnectPtr conn, + struct vnc_ports ports, + struct inst_list *list, + FILE *fl) { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst; - const char *path = PROC_TCP; unsigned int lport = 0; unsigned int rport = 0; - FILE *tcp_info; char *line = NULL; size_t len = 0; int val; int ret; int i; - tcp_info = fopen(path, "r"); - if (tcp_info == NULL) { - cu_statusf(broker, &s, + if (getline(&line, &len, fl) == -1) { + cu_statusf(broker, + &s, CMPI_RC_ERR_FAILED, - "Failed to open %s: %m", tcp_info); + "Failed to read from %s", + fl); goto out; } - if (getline(&line, &len, tcp_info) == -1) { - cu_statusf(broker, &s, - CMPI_RC_ERR_FAILED, - "Failed to read from %s", tcp_info); - goto out; - } - - while (getline(&line, &len, tcp_info) > 0) { - ret = sscanf(line, "%d: %*[^:]:%X %*[^:]:%X", &val, &lport, + while (getline(&line, &len, fl) > 0) { + ret = sscanf(line, + "%d: %*[^:]:%X %*[^:]:%X", + &val, + &lport, &rport); if (ret != 3) { - cu_statusf(broker, &s, + cu_statusf(broker, + &s, CMPI_RC_ERR_FAILED, "Unable to determine active sessions"); goto out; } - for (i = 0; i < ports.max; i++) { + for (i = 0; i < ports.max; i++) { if (lport != ports.list[i]->port) continue; @@ -198,6 +196,46 @@ inst_list_add(list, inst); } } + + out: + return s; +} + +static CMPIStatus get_vnc_sessions(const CMPIBroker *broker, + const CMPIObjectPath *ref, + virConnectPtr conn, + struct vnc_ports ports, + struct inst_list *list) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst; + const char *path[2] = {PROC_TCP4, PROC_TCP6}; + FILE *tcp_info; + int i, j; + int error = 0; + + for (j = 0; j < 2; j++) { + tcp_info = fopen(path[j], "r"); + if (tcp_info == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Failed to open %s: %m", tcp_info); + error++; + continue; + } + + s = read_tcp_file(broker, + ref, + conn, + ports, + list, + tcp_info); + + fclose(tcp_info); + + if (s.rc != CMPI_RC_OK) + error++; + } /* Handle any guests that were missed. These guest don't have active or enabled sessions. */ @@ -212,8 +250,10 @@ inst_list_add(list, inst); } + if (error != 2) + s.rc = CMPI_RC_OK; + out: - fclose(tcp_info); return s; }

# HG changeset patch # User Sharad Mishra <snmishra@us.ibm.com> # Date 1257536616 28800 # Node ID 6e39d3b64240e12aa6b2fa2769ac4e794abf0e3a # Parent 131932045d30226468c63942407321f29c65a33f This patch add support to input IPv6 address for vncserver. Signed-off-by: Sharad Mishra <snmishra@us.ibm.com> diff -r 131932045d30 -r 6e39d3b64240 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Fri Nov 06 11:43:25 2009 -0800 +++ b/src/Virt_VirtualSystemManagementService.c Fri Nov 06 11:43:36 2009 -0800 @@ -895,6 +895,44 @@ return NULL; } +static int parse_vnc_address(const char *id, + char **ip, + char **port) +{ + int ret; + char *tmp_ip = NULL; + char *tmp_port = NULL; + + CU_DEBUG("Entering parse_vnc_address, address is %s", id); + if (strstr(id, "[") != NULL) { + /* its an ipv6 address */ + ret = sscanf(id, "%a[^]]]:%as", &tmp_ip, &tmp_port); + strcat(tmp_ip, "]"); + } else { + ret = sscanf(id, "%a[^:]:%as", &tmp_ip, &tmp_port); + } + + if (ret != 2) { + ret = 0; + goto out; + } + + if (ip) + *ip = strdup(tmp_ip); + + if (port) + *port = strdup(tmp_port); + + ret = 1; + + out: + CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", *ip, *port); + free(tmp_ip); + free(tmp_port); + + return ret; +} + static const char *graphics_rasd_to_vdev(CMPIInstance *inst, struct virt_device *dev) { @@ -914,7 +952,7 @@ dev->dev.graphics.port = strdup("-1"); dev->dev.graphics.host = strdup("127.0.0.1"); } else { - ret = parse_id(val, + ret = parse_vnc_address(val, &dev->dev.graphics.host, &dev->dev.graphics.port); if (ret != 1) {

# HG changeset patch # User Sharad Mishra <snmishra@us.ibm.com> # Date 1257536626 28800 # Node ID 9bcb945a1a3b61b2dceb99d84378ede5b3d6167b # Parent 6e39d3b64240e12aa6b2fa2769ac4e794abf0e3a Added "Address" field to RASD mof file. Signed-off-by: Sharad Mishra <snmishra@us.ibm.com> diff -r 6e39d3b64240 -r 9bcb945a1a3b schema/ResourceAllocationSettingData.mof --- a/schema/ResourceAllocationSettingData.mof Fri Nov 06 11:43:36 2009 -0800 +++ b/schema/ResourceAllocationSettingData.mof Fri Nov 06 11:43:46 2009 -0800 @@ -130,6 +130,10 @@ ] class Xen_GraphicsResourceAllocationSettingData : Xen_ResourceAllocationSettingData { + [Description ("VNC Address. IPv4 in a.b.c.d:port or" + "IPv6 in [ip]:port format")] + string Address; + [Description ("Keyboard keymapping")] string KeyMap; @@ -142,6 +146,10 @@ ] class KVM_GraphicsResourceAllocationSettingData : KVM_ResourceAllocationSettingData { + [Description ("VNC Address. IPv4 in a.b.c.d:port or" + "IPv6 in [ip]:port format")] + string Address; + [Description ("Keyboard keymapping")] string KeyMap; @@ -154,6 +162,10 @@ ] class LXC_GraphicsResourceAllocationSettingData : LXC_ResourceAllocationSettingData { + [Description ("VNC Address. IPv4 in a.b.c.d:port or" + "IPv6 in [ip]:port format")] + string Address; + [Description ("Keyboard keymapping")] string KeyMap;

# HG changeset patch # User Sharad Mishra <snmishra@us.ibm.com> # Date 1257536640 28800 # Node ID d52ebba7ae4c0a30078d67b79f68c91eaa5ae137 # Parent 9bcb945a1a3b61b2dceb99d84378ede5b3d6167b Added template RASD for IPv6 addresses. Signed-off-by: Sharad Mishra <snmishra@us.ibm.com> diff -r 9bcb945a1a3b -r d52ebba7ae4c src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Fri Nov 06 11:43:46 2009 -0800 +++ b/src/Virt_SettingsDefineCapabilities.c Fri Nov 06 11:44:00 2009 -0800 @@ -1523,6 +1523,7 @@ static CMPIStatus set_graphics_props(const CMPIObjectPath *ref, const char *id, const char *type, + const char *addr, struct inst_list *list) { CMPIInstance *inst; @@ -1533,8 +1534,6 @@ CMSetProperty(inst, "InstanceID", (CMPIValue *)id, CMPI_chars); if (STREQC(type, "vnc")) { - const char *addr = "127.0.0.1:-1"; - CMSetProperty(inst, "Address", (CMPIValue *)addr, CMPI_chars); CMSetProperty(inst, "KeyMap", (CMPIValue *)"en-us", CMPI_chars); @@ -1553,9 +1552,10 @@ { const char *id; CMPIStatus s = {CMPI_RC_OK, NULL}; - const char *type[] = {"vnc", "sdl"}; + const char *type[] = {"sdl", "vnc"}; + const char *addr[] = {NULL, "127.0.0.1:-1", "[::1]:-1"}; int type_ct = 2; - int i; + int i,j; switch(template_type) { case SDC_RASD_MIN: @@ -1578,9 +1578,18 @@ } for (i = 0; i < type_ct; i++) { - s = set_graphics_props(ref, id, type[i], list); - if (s.rc != CMPI_RC_OK) - goto out; + for (j = 1; j < 3; j++){ + s = set_graphics_props(ref, + id, + type[i], + addr[i*j], + list); + if (s.rc != CMPI_RC_OK) + goto out; + + if (i == 0) + break; + } } out:
participants (1)
-
Sharad Mishra