[Libvirt-cim] [PATCH] [RFC] Added HostedAccessPoint association (ComputerSystem <-> KVMRedirectionSAP)

Richard Maciel richardm at br.ibm.com
Mon Nov 24 18:59:31 UTC 2008


# HG changeset patch
# User Richard Maciel <richardm at br.ibm.com>
# Date 1227553119 7200
# Node ID 6197321a3c5e864bd37b6dae14b060e7c2bf95de
# Parent  5d8d418eef37aebf8870e5b434253bdc095d7b24
# Parent  441d2f85e912f460b26f3fdcd265d83ad46cbfb3
[RFC] Added HostedAccessPoint association (ComputerSystem <-> KVMRedirectionSAP)

Changed:
* Created Virt_HostedAccessPoint.c file
* Changed src/Makefile.am file, so the libvirt build creates
the libHostedAccessPoint.la library
* Created a new function in the Virt_KVMRedirectionSAP.c called enum_console_saps()
that is responsible for returning a CMPIResult type containing the redirection saps
* Function return_console_sap in Virt_KVMRedirectionSAP.c now only takes two
arguments: the reference and a return argument that represent the list of redirection
saps
* Added schema/HostedAccessPoint.mof (and .registration) to
create and register the new associations
* Changed Makefile.am to regiser HostedAccessPoint association

Running the following query:
wbemcli ain -ac KVM_HostedAccessPoint 'http://root:1mud2ar3@localhost:5988/root/virt:
KVM_HostSystem.CreationClassName="KVM_HostSystem",Name="F10"'

Expecting this query to return the list KVMRedirectionSAPs associated with the host

Right now the query returns the following message:
 wbemcli: Cim: (4) CIM_ERR_INVALID_PARAMETER: KVM_HostSystem.CreationClassName=
"KVM_HostSystem",Name="F10"


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

diff -r 5d8d418eef37 -r 6197321a3c5e Makefile.am
--- a/Makefile.am	Wed Nov 19 16:08:21 2008 -0200
+++ b/Makefile.am	Mon Nov 24 16:58:39 2008 -0200
@@ -51,7 +51,8 @@
         schema/DisplayController.mof \
         schema/PointingDevice.mof \
         schema/GraphicsPool.mof \
-        schema/InputPool.mof
+        schema/InputPool.mof \
+        schema/HostedAccessPoint.mof
 
 INTEROP_MOFS = \
 	schema/ComputerSystem.mof \
@@ -117,7 +118,8 @@
         schema/DisplayController.registration \
         schema/PointingDevice.registration \
         schema/GraphicsPool.registration \
-        schema/InputPool.registration
+        schema/InputPool.registration \
+        schema/HostedAccessPoint.registration
 
 INTEROP_REGS = \
 	schema/RegisteredProfile.registration \
diff -r 5d8d418eef37 -r 6197321a3c5e schema/HostedAccessPoint.mof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/schema/HostedAccessPoint.mof	Mon Nov 24 16:58:39 2008 -0200
@@ -0,0 +1,22 @@
+// Copyright IBM Corp. 2007
+
+[Association,
+ Provider("cmpi::Virt_HostedAccessPoint")
+]
+class Xen_HostedAccessPoint : CIM_HostedAccessPoint
+{
+};
+
+[Association,
+ Provider("cmpi::Virt_HostedAccessPoint")
+]
+class KVM_HostedAccessPoint : CIM_HostedAccessPoint
+{
+};
+
+[Association,
+ Provider("cmpi::Virt_HostedAccessPoint")
+]
+class LXC_HostedAccessPoint : CIM_HostedAccessPoint
+{
+};
diff -r 5d8d418eef37 -r 6197321a3c5e schema/HostedAccessPoint.registration
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/schema/HostedAccessPoint.registration	Mon Nov 24 16:58:39 2008 -0200
@@ -0,0 +1,5 @@
+# Copyright IBM Corp. 2007
+# Classname Namespace ProviderName ProviderModule ProviderTypes
+Xen_HostedAccessPoint root/virt Virt_HostedAccessPoint Virt_HostedAccessPoint association
+KVM_HostedAccessPoint root/virt Virt_HostedAccessPoint Virt_HostedAccessPoint association
+LXC_HostedAccessPoint root/virt Virt_HostedAccessPoint Virt_HostedAccessPoint association
diff -r 5d8d418eef37 -r 6197321a3c5e src/Makefile.am
--- a/src/Makefile.am	Wed Nov 19 16:08:21 2008 -0200
+++ b/src/Makefile.am	Mon Nov 24 16:58:39 2008 -0200
@@ -72,7 +72,8 @@
                        libVirt_HostedService.la \
                        libVirt_ElementSettingData.la \
                        libVirt_ConcreteComponent.la \
-                       libVirt_ServiceAffectsElement.la
+                       libVirt_ServiceAffectsElement.la \
+                       libVirt_HostedAccessPoint.la
 
 libVirt_ComputerSystem_la_SOURCES = Virt_ComputerSystem.c
 libVirt_ComputerSystem_la_DEPENDENCIES = libVirt_VirtualSystemSnapshotService.la
@@ -216,3 +217,7 @@
 
 libVirt_KVMRedirectionSAP_la_SOURCES = Virt_KVMRedirectionSAP.c
 
+libVirt_HostedAccessPoint_la_DEPENDENCIES = libVirt_HostSystem.la libVirt_KVMRedirectionSAP.la
+libVirt_HostedAccessPoint_la_SOURCES = Virt_HostedAccessPoint.c
+libVirt_HostedAccessPoint_la_LIBADD = -lVirt_HostSystem -lVirt_KVMRedirectionSAP
+
diff -r 5d8d418eef37 -r 6197321a3c5e src/Virt_HostedAccessPoint.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Virt_HostedAccessPoint.c	Mon Nov 24 16:58:39 2008 -0200
@@ -0,0 +1,162 @@
+/*
+ * Copyright IBM Corp. 2008
+ *
+ * Authors:
+ * Richard Maciel <richardm at br.ibm.com> 
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ */
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdbool.h>
+
+#include "cmpidt.h"
+#include "cmpift.h"
+#include "cmpimacs.h"
+
+#include <libcmpiutil/libcmpiutil.h>
+#include <libcmpiutil/std_association.h>
+#include "misc_util.h"
+
+#include "Virt_HostSystem.h"
+#include "Virt_KVMRedirectionSAP.h"
+
+static const CMPIBroker *_BROKER;
+
+static CMPIStatus rsap_to_host(const CMPIObjectPath *ref,
+                               struct std_assoc_info *info,
+                               struct inst_list *list)
+{
+        CMPIStatus s = {CMPI_RC_OK, NULL};
+        CMPIInstance *instance = NULL;
+
+        if (!match_hypervisor_prefix(ref, info))
+                goto out;
+
+        s = get_console_sap_by_ref(_BROKER, ref, &instance);
+        if (s.rc != CMPI_RC_OK)
+                goto out;
+
+        s = get_host(_BROKER, info->context, ref, &instance, false);
+        if (s.rc == CMPI_RC_OK)
+                inst_list_add(list, instance);
+
+out:
+        return s;
+}
+
+
+static CMPIStatus host_to_rsap(const CMPIObjectPath *ref,
+                               struct std_assoc_info *info,
+                               struct inst_list *list)
+{
+        CMPIStatus s = {CMPI_RC_OK, NULL};
+        CMPIInstance *instance = NULL;
+        CMPIObjectPath *vref = NULL;
+
+        if (!match_hypervisor_prefix(ref, info))
+                goto out;
+
+        s = get_host(_BROKER, info->context, ref, &instance, true);
+        if (s.rc != CMPI_RC_OK)
+                goto out; 
+
+        vref = convert_sblim_hostsystem(_BROKER, ref, info);
+        if (vref == NULL)
+                goto out;
+
+        s = return_console_sap(vref, list);
+
+        //s = get_console_sap_by_ref(_BROKER, ref, &instance);
+        if (s.rc != CMPI_RC_OK)
+                goto out;
+        //if (!CMIIsNullObject(instance))
+        inst_list_add(list, instance);
+         
+out:
+        return s;
+}
+
+LIBVIRT_CIM_DEFAULT_MAKEREF()
+
+static char* antecedent[] = {
+        "Xen_HostSystem",
+        "KVM_HostSystem",
+        "LXC_HostSystem",
+        NULL
+};
+
+static char* dependent[] = {
+        "Xen_KVMRedirectionSAP",
+        "KVM_KVMRedirectionSAP",
+        "LXC_KVMRedirectionSAP",
+        NULL
+};
+
+static char* assoc_classname[] = {
+        "Xen_HostedAccessPoint",
+        "KVM_HostedAccessPoint",
+        "LXC_HostedAccessPoint",
+        NULL
+};
+
+static struct std_assoc _rsap_to_host = {
+        .source_class = (char **)&antecedent,
+        .source_prop = "Antecedent", 
+
+        .target_class = (char **)&dependent,
+        .target_prop = "Dependent", 
+
+        .assoc_class = (char **)&assoc_classname,
+
+        .handler = rsap_to_host,
+        .make_ref = make_ref
+};
+
+static struct std_assoc _host_to_rsap = {
+        .source_class = (char **)&dependent,
+        .source_prop = "Dependent",
+
+        .target_class = (char **)&antecedent,
+        .target_prop = "Antecedent",
+        
+        .assoc_class = (char **)&assoc_classname,
+
+        .handler = host_to_rsap,
+        .make_ref = make_ref
+};
+
+static struct std_assoc *handlers[] = {
+        &_rsap_to_host,
+        &_host_to_rsap,
+        NULL
+};
+
+STDA_AssocMIStub(,
+                 Virt_HostedAccessPoint,
+                 _BROKER, 
+                 libvirt_cim_init(), 
+                 handlers);
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-set-style: "K&R"
+ * tab-width: 8
+ * c-basic-offset: 8
+ * indent-tabs-mode: nil
+ * End:
+ */
diff -r 5d8d418eef37 -r 6197321a3c5e src/Virt_KVMRedirectionSAP.c
--- a/src/Virt_KVMRedirectionSAP.c	Wed Nov 19 16:08:21 2008 -0200
+++ b/src/Virt_KVMRedirectionSAP.c	Mon Nov 24 16:58:39 2008 -0200
@@ -236,15 +236,36 @@
         return true;
 }
 
-static CMPIStatus return_console_sap(const CMPIObjectPath *ref,
-                                     const CMPIResult *results,
-                                     bool names_only)
+static CMPIStatus enum_console_saps(const CMPIObjectPath *ref,
+                                    const CMPIResult *results,
+                                    bool names_only)
+{
+        CMPIStatus s = {CMPI_RC_OK, NULL};
+        struct inst_list list;
+
+        s = return_console_sap(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:
+        return s;
+}
+
+CMPIStatus return_console_sap(const CMPIObjectPath *ref,
+                              struct inst_list *list)
+                                     //const CMPIResult *results,
+                                     //bool names_only)
 {
         CMPIStatus s = {CMPI_RC_OK, NULL};
         virConnectPtr conn;
         virDomainPtr *domain_list;
         struct domain *dominfo = NULL;
-        struct inst_list list;
+        //struct inst_list list;
         struct vnc_ports port_list;
         int count;
         int lport;
@@ -255,7 +276,7 @@
         if (conn == NULL)
                 return s;
 
-        inst_list_init(&list);
+        inst_list_init(list);
 
         port_list.list = NULL;
         port_list.max = 0;
@@ -325,18 +346,18 @@
         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)
+        /*if (names_only)
                 cu_return_instance_names(results, &list);
         else
-                cu_return_instances(results, &list);
+                cu_return_instances(results, &list);*/
 
  out:
         free(domain_list);
-        inst_list_free(&list);
+        //inst_list_free(&list);
 
         for (i = 0; i < count; i++) {
                 free(port_list.list[i]->name);
@@ -471,7 +492,7 @@
                                     const CMPIResult *results,
                                     const CMPIObjectPath *reference)
 {
-        return return_console_sap(reference, results, true);
+        return enum_console_saps(reference, results, true);
 }
 
 static CMPIStatus EnumInstances(CMPIInstanceMI *self,
@@ -481,7 +502,7 @@
                                 const char **properties)
 {
 
-        return return_console_sap(reference, results, false);
+        return enum_console_saps(reference, results, false);
 }
 
 static CMPIStatus GetInstance(CMPIInstanceMI *self,
diff -r 5d8d418eef37 -r 6197321a3c5e src/Virt_KVMRedirectionSAP.h
--- a/src/Virt_KVMRedirectionSAP.h	Wed Nov 19 16:08:21 2008 -0200
+++ b/src/Virt_KVMRedirectionSAP.h	Mon Nov 24 16:58:39 2008 -0200
@@ -28,6 +28,9 @@
                                   const CMPIObjectPath *reference,
                                   CMPIInstance **_inst);
 
+CMPIStatus return_console_sap(const CMPIObjectPath *ref,
+                              struct inst_list *list);
+
 /*
  * Local Variables:
  * mode: C




More information about the Libvirt-cim mailing list