# HG changeset patch
# User Richard Maciel <richardm(a)br.ibm.com>
# Date 1228338049 7200
# Node ID 8c20f4dd7edcd92ba59f7cc1795a0eb712f57daa
# Parent 7a9f4c0b781a65d5c1e4d1b70e5c380e64ce0ca7
Added association HostedAccessPoint (HostSystem <-> KVMRedirectionSAP)
* Created Virt_HostedAccessPoint.c file
* Changed src/Makefile.am file, so the libvirt build creates
the libHostedAccessPoint.la library
changes for submission #2:
* Added support for SBLIM host references
changes for submission #3:
* Association now uses the enum_console_sap function (simple rename) which
was renamed from the return_console_sap
This patch implements the HostedAccessPoint association using
the standard procedure.
Signed-off by: Richard Maciel <richardm(a)br.ibm.com>
diff -r 7a9f4c0b781a -r 8c20f4dd7edc src/Makefile.am
--- a/src/Makefile.am Wed Dec 03 18:59:54 2008 -0200
+++ b/src/Makefile.am Wed Dec 03 19:00:49 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 7a9f4c0b781a -r 8c20f4dd7edc src/Virt_HostedAccessPoint.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Virt_HostedAccessPoint.c Wed Dec 03 19:00:49 2008 -0200
@@ -0,0 +1,161 @@
+/*
+ * Copyright IBM Corp. 2008
+ *
+ * Authors:
+ * Richard Maciel <richardm(a)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 (!STARTS_WITH(CLASSNAME(ref), "Linux_") &&
+ !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 = enum_console_sap(_BROKER, vref, list);
+
+ if (s.rc != CMPI_RC_OK)
+ goto out;
+
+ out:
+ return s;
+}
+
+LIBVIRT_CIM_DEFAULT_MAKEREF()
+
+static char* antecedent[] = {
+ "Xen_HostSystem",
+ "KVM_HostSystem",
+ "LXC_HostSystem",
+ "Linux_ComputerSystem",
+ 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 _host_to_rsap = {
+ .source_class = (char **)&antecedent,
+ .source_prop = "Antecedent",
+
+ .target_class = (char **)&dependent,
+ .target_prop = "Dependent",
+
+ .assoc_class = (char **)&assoc_classname,
+
+ .handler = host_to_rsap,
+ .make_ref = make_ref
+};
+
+static struct std_assoc _rsap_to_host = {
+ .source_class = (char **)&dependent,
+ .source_prop = "Dependent",
+
+ .target_class = (char **)&antecedent,
+ .target_prop = "Antecedent",
+
+ .assoc_class = (char **)&assoc_classname,
+
+ .handler = rsap_to_host,
+ .make_ref = make_ref
+};
+
+static struct std_assoc *handlers[] = {
+ &_host_to_rsap,
+ &_rsap_to_host,
+ 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:
+ */