[Libvirt-cim] [PATCH]

Richard Maciel richardm at br.ibm.com
Wed Jan 7 01:53:40 UTC 2009


# HG changeset patch
# User Richard Maciel <richardm at br.ibm.com>
# Date 1229729923 7200
# Node ID ebb3a754af1f3eed21b8daf65c0b72ad9d7e65e3
# Parent  c4b178c78475fe8ad11328d80f38bcdcf0d50e70
#2 Added 2 end points for the ServiceAffectsElement association, both related to the LogicalDevice class.

- ConsoleRedirectionService <-> DisplayController

- ConsoleRedirectionService <-> PointingDevice

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

diff -r c4b178c78475 -r ebb3a754af1f src/Makefile.am
--- a/src/Makefile.am	Fri Dec 19 21:10:32 2008 -0200
+++ b/src/Makefile.am	Fri Dec 19 21:38:43 2008 -0200
@@ -213,9 +213,9 @@
 
 libVirt_ConsoleRedirectionServiceCapabilities_la_SOURCES = Virt_ConsoleRedirectionServiceCapabilities.c
 
-libVirt_ServiceAffectsElement_la_DEPENDENCIES = libVirt_ComputerSystem.la libVirt_ConsoleRedirectionService.la
+libVirt_ServiceAffectsElement_la_DEPENDENCIES = libVirt_ComputerSystem.la libVirt_Device.la libVirt_ConsoleRedirectionService.la 
 libVirt_ServiceAffectsElement_la_SOURCES = Virt_ServiceAffectsElement.c
-libVirt_ServiceAffectsElement_la_LIBADD = -lVirt_ComputerSystem -lVirt_ConsoleRedirectionService
+libVirt_ServiceAffectsElement_la_LIBADD = -lVirt_ComputerSystem -lVirt_Device -lVirt_ConsoleRedirectionService
 
 libVirt_KVMRedirectionSAP_la_SOURCES = Virt_KVMRedirectionSAP.c
 
diff -r c4b178c78475 -r ebb3a754af1f src/Virt_ServiceAffectsElement.c
--- a/src/Virt_ServiceAffectsElement.c	Fri Dec 19 21:10:32 2008 -0200
+++ b/src/Virt_ServiceAffectsElement.c	Fri Dec 19 21:38:43 2008 -0200
@@ -29,9 +29,11 @@
 #include <libcmpiutil/libcmpiutil.h>
 #include <libcmpiutil/std_association.h>
 #include "misc_util.h"
+#include "svpc_types.h"
 
 #include "Virt_ComputerSystem.h"
 #include "Virt_ConsoleRedirectionService.h"
+#include "Virt_Device.h"
 
 const static CMPIBroker *_BROKER;
 
@@ -41,15 +43,70 @@
 {
         CMPIStatus s = {CMPI_RC_OK, NULL};
         CMPIInstance *instance = NULL;
-
+        const char *host = NULL;
+        int i;
+        int num_of_domains;
+        
         if (!match_hypervisor_prefix(ref, info))
-                return s;
+                goto out;
 
         s = get_console_rs(ref, &instance, _BROKER, info->context, true);
         if (s.rc != CMPI_RC_OK)
-                return s;
+                goto out;
 
         s = enum_domains(_BROKER, ref, list);
+        if (s.rc != CMPI_RC_OK)
+                goto out;
+       
+        num_of_domains = list->cur;
+ 
+        /*
+         * For each domain, insert its video and pointer devices into
+         * the list
+         */
+        for (i = 0; i < num_of_domains; i++) {
+                s.rc = cu_get_str_prop(list->list[i], "Name", &host);
+                if (s.rc != CMPI_RC_OK) 
+                        goto out;
+
+                s = enum_devices(_BROKER, 
+                                 ref, 
+                                 host, 
+                                 CIM_RES_TYPE_INPUT, 
+                                 list);
+                if (s.rc != CMPI_RC_OK)
+                        goto out;
+
+                s = enum_devices(_BROKER, 
+                                 ref,
+                                 host,
+                                 CIM_RES_TYPE_GRAPHICS,
+                                 list);
+                if (s.rc != CMPI_RC_OK)
+                        goto out;
+        }
+
+ out:
+        return s;
+}
+
+static CMPIStatus validate_cs_or_dev_ref(const CMPIContext *context,
+                                         const CMPIObjectPath *ref)
+{
+        CMPIStatus s = {CMPI_RC_OK, NULL};
+        CMPIInstance *inst = NULL;
+        char* classname;
+                                  
+        classname = class_base_name(CLASSNAME(ref));
+
+        if (STREQC(classname, "ComputerSystem")) {
+                s = get_domain_by_ref(_BROKER, ref, &inst);
+        } else if ((STREQC(classname, "PointingDevice"))  || 
+                   (STREQC(classname, "DisplayController"))) {
+                s = get_device_by_ref(_BROKER, ref, &inst);        
+        }
+
+        free(classname);
 
         return s;
 }
@@ -63,8 +120,8 @@
 
         if (!match_hypervisor_prefix(ref, info))
                 return s;
-
-        s = get_domain_by_ref(_BROKER, ref, &inst);
+        
+        s = validate_cs_or_dev_ref(info->context, ref);
         if (s.rc != CMPI_RC_OK)
                 return s;
 
@@ -83,6 +140,12 @@
         "Xen_ComputerSystem",
         "KVM_ComputerSystem",
         "LXC_ComputerSystem",
+        "Xen_PointingDevice",
+        "KVM_PointingDevice",
+        "LXC_PointingDevice",
+        "Xen_DisplayController",
+        "KVM_DisplayController",
+        "LXC_DisplayController",
         NULL
 };
 




More information about the Libvirt-cim mailing list