[Libvirt-cim] [PATCH 1 of 3] Added association HostedAccessPoint (HostSystem <-> KVMRedirectionSAP)

Richard Maciel richardm at br.ibm.com
Wed Dec 3 21:15:01 UTC 2008


# HG changeset patch
# User Richard Maciel <richardm at br.ibm.com>
# Date 1228338795 7200
# Node ID 0424a762d6f8b1ba9c36ab18aeafcf20c27350fa
# 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

Signed-off by: Richard Maciel <richardm at br.ibm.com>

diff -r ae687011f6de -r 0424a762d6f8 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 19:13:15 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 0424a762d6f8 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 19:13:15 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




More information about the Libvirt-cim mailing list