
# HG changeset patch # User Richard Maciel <richardm@br.ibm.com> # Date 1228423286 7200 # Node ID 3fd91510a5db88c2429a6bd1a6a21cf6287e1418 # Parent ae687011f6def5df176e5b9b553b93e9f907b7d6 Added association HostedAccessPoint (HostSystem <-> KVMRedirectionSAP) * Changed function return_console_sap in the Virt_KVMRedirectionSAP.c so it is responsible for returning a CMPIResult type containing the redirection saps * Created new function enum_console_sap in Virt_KVMRedirectionSAP.c to return a list containg the redirection saps. This new function only takes three arguments: the reference to the broker, the reference and a return argument that represent the list of redirection saps Changes for submission #4 * Added parameter broker to the get_vnc_sessions function and changed enum_console_sap function to call this function properly Signed-off by: Richard Maciel <richardm@br.ibm.com> diff -r ae687011f6de -r 3fd91510a5db src/Virt_KVMRedirectionSAP.c --- a/src/Virt_KVMRedirectionSAP.c Wed Dec 03 16:21:29 2008 -0200 +++ b/src/Virt_KVMRedirectionSAP.c Thu Dec 04 18:41:26 2008 -0200 @@ -139,7 +139,8 @@ return inst; } -static CMPIStatus get_vnc_sessions(const CMPIObjectPath *ref, +static CMPIStatus get_vnc_sessions(const CMPIBroker *broker, + const CMPIObjectPath *ref, virConnectPtr conn, struct vnc_ports ports, struct inst_list *list) @@ -158,14 +159,14 @@ tcp_info = fopen(path, "r"); if (tcp_info == NULL) { - cu_statusf(_BROKER, &s, + cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, "Failed to open %s: %m", tcp_info); goto out; } if (getline(&line, &len, tcp_info) == -1) { - cu_statusf(_BROKER, &s, + cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, "Failed to read from %s", tcp_info); goto out; @@ -175,7 +176,7 @@ 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; @@ -186,7 +187,7 @@ continue; ports.list[i]->remote_port = rport; - inst = get_console_sap(_BROKER, + inst = get_console_sap(broker, ref, conn, ports.list[i], @@ -204,7 +205,7 @@ if (ports.list[i]->remote_port != -1) continue; - inst = get_console_sap(_BROKER, ref, conn, ports.list[i], &s); + inst = get_console_sap(broker, ref, conn, ports.list[i], &s); if ((s.rc != CMPI_RC_OK) || (inst == NULL)) goto out; @@ -246,21 +247,41 @@ bool names_only) { CMPIStatus s = {CMPI_RC_OK, NULL}; + struct inst_list list; + + inst_list_init(&list); + + s = enum_console_sap(_BROKER, ref, &list); + if (s.rc != CMPI_RC_OK) + goto out; + + if (names_only) + cu_return_instance_names(results, &list); + else + cu_return_instances(results, &list); + + out: + inst_list_free(&list); + return s; +} + +CMPIStatus enum_console_sap(const CMPIBroker *broker, + const CMPIObjectPath *ref, + struct inst_list *list) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; virConnectPtr conn; virDomainPtr *domain_list; struct domain *dominfo = NULL; - struct inst_list list; struct vnc_ports port_list; int count; int lport; int ret; int i; - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); + conn = connect_by_classname(broker, CLASSNAME(ref), &s); if (conn == NULL) return s; - - inst_list_init(&list); port_list.list = NULL; port_list.max = 0; @@ -268,7 +289,7 @@ count = get_domain_list(conn, &domain_list); if (count < 0) { - cu_statusf(_BROKER, &s, + cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, "Failed to enumerate domains"); goto out; @@ -277,7 +298,7 @@ port_list.list = malloc(count * sizeof(struct vnc_port *)); if (port_list.list == NULL) { - cu_statusf(_BROKER, &s, + cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, "Unable to allocate guest port list"); goto out; @@ -286,7 +307,7 @@ for (i = 0; i < count; i++) { port_list.list[i] = malloc(sizeof(struct vnc_port)); if (port_list.list[i] == NULL) { - cu_statusf(_BROKER, &s, + cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, "Unable to allocate guest port list"); goto out; @@ -305,7 +326,7 @@ "%d", &lport); if (ret != 1) { - cu_statusf(_BROKER, &s, + cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, "Unable to guest's console port"); goto out; @@ -313,7 +334,7 @@ port_list.list[port_list.cur]->name = strdup(dominfo->name); if (port_list.list[port_list.cur]->name == NULL) { - cu_statusf(_BROKER, &s, + cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, "Unable to allocate string"); goto out; @@ -330,18 +351,12 @@ port_list.max = port_list.cur; port_list.cur = 0; - s = get_vnc_sessions(ref, conn, port_list, &list); + s = get_vnc_sessions(broker, ref, conn, port_list, list); if (s.rc != CMPI_RC_OK) goto out; - if (names_only) - cu_return_instance_names(results, &list); - else - cu_return_instances(results, &list); - out: free(domain_list); - inst_list_free(&list); for (i = 0; i < count; i++) { free(port_list.list[i]->name); diff -r ae687011f6de -r 3fd91510a5db src/Virt_KVMRedirectionSAP.h --- a/src/Virt_KVMRedirectionSAP.h Wed Dec 03 16:21:29 2008 -0200 +++ b/src/Virt_KVMRedirectionSAP.h Thu Dec 04 18:41:26 2008 -0200 @@ -28,6 +28,10 @@ const CMPIObjectPath *reference, CMPIInstance **_inst); +CMPIStatus enum_console_sap(const CMPIBroker *broker, + const CMPIObjectPath *ref, + struct inst_list *list); + /* * Local Variables: * mode: C