[Libvirt-cim] [PATCH 2 of 2]

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Fri Oct 24 22:15:46 UTC 2008


# HG changeset patch
# User kaitlin at elm3b43.beaverton.ibm.com
# Date 1224552270 25200
# Node ID c4e40b8d7aa0ad1135e9ea4273e3becff2fd3cbb
# Parent  22262aa6c752e15e6c9fa462cd3bb84b7ff49fd2
#2 Have get_console_sap_by_name() use Name attribute to determine session status

Updates:
 -Removed function that parses the Name attribute

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r 22262aa6c752 -r c4e40b8d7aa0 src/Virt_KVMRedirectionSAP.c
--- a/src/Virt_KVMRedirectionSAP.c	Mon Oct 20 18:24:30 2008 -0700
+++ b/src/Virt_KVMRedirectionSAP.c	Mon Oct 20 18:24:30 2008 -0700
@@ -344,7 +344,7 @@
 
 CMPIStatus get_console_sap_by_name(const CMPIBroker *broker,
                                    const CMPIObjectPath *ref,
-                                   const char *name,
+                                   const char *sys,
                                    CMPIInstance **_inst)
 {
         virConnectPtr conn;
@@ -352,6 +352,10 @@
         CMPIStatus s = {CMPI_RC_OK, NULL};
         CMPIInstance *inst = NULL;
         struct domain *dominfo = NULL;
+        struct vnc_port *port = NULL;
+        const char *name = NULL;
+        int lport;
+        int rport;
 
         conn = connect_by_classname(broker, CLASSNAME(ref), &s);
         if (conn == NULL) {
@@ -361,12 +365,12 @@
                 goto out;
         }
 
-        dom = virDomainLookupByName(conn, name);
+        dom = virDomainLookupByName(conn, sys);
         if (dom == NULL) {
                 cu_statusf(broker, &s,
                            CMPI_RC_ERR_NOT_FOUND,
                            "No such instance (%s)",
-                           name);
+                           sys);
                 goto out;
         }
 
@@ -374,9 +378,29 @@
                 cu_statusf(broker, &s,
                            CMPI_RC_ERR_FAILED,
                            "No console device for this guest");
+                goto out;
         }
 
-        inst = get_console_sap(_BROKER, ref, conn, dominfo, &s);
+        if (cu_get_str_path(ref, "Name", &name) != CMPI_RC_OK) {
+                cu_statusf(broker, &s,
+                           CMPI_RC_ERR_NOT_FOUND,
+                           "No such instance (System)");
+                goto out;
+        }
+
+        if (sscanf(name, "%d:%d", &lport, &rport) != 2) {
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "Unable to guest's console port");
+                goto out;
+        }
+
+        port = malloc(sizeof(struct vnc_port));
+        port->name = strdup(dominfo->name);
+        port->port = lport;
+        port->remote_port = rport;
+
+        inst = get_console_sap(_BROKER, ref, conn, port, &s);
 
         virDomainFree(dom);
 
@@ -387,6 +411,9 @@
 
  out:
         virConnectClose(conn);
+        free(port->name);
+        free(port);
+        port = NULL;
 
         return s;
 }
@@ -399,10 +426,10 @@
         CMPIInstance *inst = NULL;
         const char *sys = NULL;
 
-        if (cu_get_str_path(reference, "System", &sys) != CMPI_RC_OK) {
+        if (cu_get_str_path(reference, "SystemName", &sys) != CMPI_RC_OK) {
                 cu_statusf(broker, &s,
                            CMPI_RC_ERR_NOT_FOUND,
-                           "No such instance (System)");
+                           "No such instance (SystemName)");
                 goto out;
         }
 




More information about the Libvirt-cim mailing list