# HG changeset patch
# User Richard Maciel <richardm(a)br.ibm.com>
# Date 1228337520 7200
# Node ID 63fa1c7aece56430f1b2b15376dcdf8a114e26d2
# Parent ae687011f6def5df176e5b9b553b93e9f907b7d6
Added association ServiceAccessBySAP (ConsoleRedirectionService <->
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
Signed-off by: Richard Maciel <richardm(a)br.ibm.com>
diff -r ae687011f6de -r 63fa1c7aece5 src/Virt_KVMRedirectionSAP.c
--- a/src/Virt_KVMRedirectionSAP.c Wed Dec 03 16:21:29 2008 -0200
+++ b/src/Virt_KVMRedirectionSAP.c Wed Dec 03 18:52:00 2008 -0200
@@ -246,21 +246,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 +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);
diff -r ae687011f6de -r 63fa1c7aece5 src/Virt_KVMRedirectionSAP.h
--- a/src/Virt_KVMRedirectionSAP.h Wed Dec 03 16:21:29 2008 -0200
+++ b/src/Virt_KVMRedirectionSAP.h Wed Dec 03 18:52:00 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