# HG changeset patch
# User Richard Maciel <richardm(a)br.ibm.com>
# Date 1229729923 7200
# Node ID 0a617ecc1b6f49a1391afa5566f3f7ca710ec5cb
# Parent 27c75ec951e790bfec72273828154eec647e4caf
Added 2 end points for the ServiceAffectsElement association, both related to the
LogicalDevice class.
- ConsoleRedirectionService <-> DisplayController
- ConsoleRedirectionService <-> PointingDevice
Signed-off-by: Richard Maciel <richardm(a)br.ibm.com>
diff -r 27c75ec951e7 -r 0a617ecc1b6f 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 27c75ec951e7 -r 0a617ecc1b6f 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,11 +29,29 @@
#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;
+
+static CMPIStatus add_devices_to_list(const CMPIObjectPath *ref,
+ const char *host,
+ int type,
+ struct inst_list *list)
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+
+ s = enum_devices(_BROKER, ref, host, type, list);
+
+ if (s.rc != CMPI_RC_OK)
+ goto out;
+
+ out:
+ return s;
+}
static CMPIStatus service_to_cs(const CMPIObjectPath *ref,
struct std_assoc_info *info,
@@ -41,15 +59,60 @@
{
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 = add_devices_to_list(ref, host, CIM_RES_TYPE_INPUT, list);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
+
+ s = add_devices_to_list(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 +126,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 +146,12 @@
"Xen_ComputerSystem",
"KVM_ComputerSystem",
"LXC_ComputerSystem",
+ "Xen_PointingDevice",
+ "KVM_PointingDevice",
+ "LXC_PointingDevice",
+ "Xen_DisplayController",
+ "KVM_DisplayController",
+ "LXC_DisplayController",
NULL
};