# HG changeset patch
# User Richard Maciel <richardm(a)br.ibm.com>
# Date 1227890924 7200
# Node ID 74137e041664ce92f28d41ea12358c4508949cde
# Parent f21e9ebf0ad0573bf55be7c16a9d32a07d9ac899
* Created a new function in the Virt_KVMRedirectionSAP.c called enum_console_saps()
that is responsible for returning a CMPIResult type containing the redirection saps
* Function return_console_sap in Virt_KVMRedirectionSAP.c now only takes three
arguments: the reference to the broker, the reference and a return argument that
represent the list of redirection saps
Signed-off by: Richard Maciel <richardm(a)br.ibm.com>
diff -r f21e9ebf0ad0 -r 74137e041664 src/Virt_KVMRedirectionSAP.c
--- a/src/Virt_KVMRedirectionSAP.c Mon Nov 24 13:06:18 2008 -0800
+++ b/src/Virt_KVMRedirectionSAP.c Fri Nov 28 14:48:44 2008 -0200
@@ -241,26 +241,46 @@
return true;
}
-static CMPIStatus return_console_sap(const CMPIObjectPath *ref,
- const CMPIResult *results,
- bool names_only)
+static CMPIStatus enum_console_saps(const CMPIObjectPath *ref,
+ const CMPIResult *results,
+ bool names_only)
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ struct inst_list list;
+
+ inst_list_init(&list);
+
+ s = return_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 return_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 +288,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 +297,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 +306,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 +325,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 +333,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 +350,12 @@
port_list.max = port_list.cur;
port_list.cur = 0;
- s = get_vnc_sessions(ref, conn, port_list, &list);
+ s = get_vnc_sessions(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);
@@ -478,7 +492,7 @@
const CMPIResult *results,
const CMPIObjectPath *reference)
{
- return return_console_sap(reference, results, true);
+ return enum_console_saps(reference, results, true);
}
static CMPIStatus EnumInstances(CMPIInstanceMI *self,
@@ -488,7 +502,7 @@
const char **properties)
{
- return return_console_sap(reference, results, false);
+ return enum_console_saps(reference, results, false);
}
static CMPIStatus GetInstance(CMPIInstanceMI *self,
diff -r f21e9ebf0ad0 -r 74137e041664 src/Virt_KVMRedirectionSAP.h
--- a/src/Virt_KVMRedirectionSAP.h Mon Nov 24 13:06:18 2008 -0800
+++ b/src/Virt_KVMRedirectionSAP.h Fri Nov 28 14:48:44 2008 -0200
@@ -28,6 +28,10 @@
const CMPIObjectPath *reference,
CMPIInstance **_inst);
+CMPIStatus return_console_sap(const CMPIBroker *broker,
+ const CMPIObjectPath *ref,
+ struct inst_list *list);
+
/*
* Local Variables:
* mode: C