[Libvirt-cim] [PATCH 2 of 2] Add RedirectionServiceCapabilites

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Mon Sep 15 20:27:52 UTC 2008


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1221510414 25200
# Node ID b65af27bd0b1fcf2f3224f2db94be398402bb235
# Parent  f5078be18a2225b913ea3cf792840b0fa58985e9
Add RedirectionServiceCapabilites.

Put SHARING_MODE value in a header file.  This header file will probably be needed for a function definition later on when the console related assocations are implemented.

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

diff -r f5078be18a22 -r b65af27bd0b1 src/Makefile.am
--- a/src/Makefile.am	Mon Sep 15 10:04:53 2008 -0700
+++ b/src/Makefile.am	Mon Sep 15 13:26:54 2008 -0700
@@ -20,7 +20,8 @@
     Virt_AllocationCapabilities.h               \
     Virt_VirtualSystemSnapshotService.h         \
     Virt_VirtualSystemSnapshotServiceCapabilities.h \
-    Virt_VSMigrationSettingData.h
+    Virt_VSMigrationSettingData.h \
+    Virt_RedirectionService.h
 
 XKUADD = $(top_builddir)/libxkutil/libxkutil.la
 
diff -r f5078be18a22 -r b65af27bd0b1 src/Virt_RedirectionService.c
--- a/src/Virt_RedirectionService.c	Mon Sep 15 10:04:53 2008 -0700
+++ b/src/Virt_RedirectionService.c	Mon Sep 15 13:26:54 2008 -0700
@@ -35,9 +35,9 @@
 #include <libcmpiutil/std_instance.h>
 
 #include "Virt_HostSystem.h"
+#include "Virt_RedirectionService.h"
 
 #define SERVICE_TYPE  3
-#define SHARING_MODE  3
 
 #define ENABLED_STATE   2
 #define REQUESTED_STATE 12
diff -r f5078be18a22 -r b65af27bd0b1 src/Virt_RedirectionService.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Virt_RedirectionService.h	Mon Sep 15 13:26:54 2008 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright IBM Corp. 2007
+ *
+ * Authors:
+ *  Kaitlin Rupert <karupert at us.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
+ */
+
+#define SHARING_MODE  3
+
+CMPIStatus get_rs(const CMPIObjectPath *reference,
+                  CMPIInstance **_inst,
+                  const CMPIBroker *broker,
+                  const CMPIContext *context,
+                  bool is_get_inst);
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-set-style: "K&R"
+ * tab-width: 8
+ * c-basic-offset: 8
+ * indent-tabs-mode: nil
+ * End:
+ */
+
diff -r f5078be18a22 -r b65af27bd0b1 src/Virt_RedirectionServiceCapabilities.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Virt_RedirectionServiceCapabilities.c	Mon Sep 15 13:26:54 2008 -0700
@@ -0,0 +1,180 @@
+/*
+ * Copyright IBM Corp. 2007
+ *
+ * Authors:
+ *  Kaitlin Rupert <karupert at us.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 <stdlib.h>
+#include <unistd.h>
+
+#include <cmpidt.h>
+#include <cmpift.h>
+#include <cmpimacs.h>
+
+#include <libcmpiutil/libcmpiutil.h>
+#include <libcmpiutil/std_instance.h>
+
+#include "misc_util.h"
+
+#include "Virt_RedirectionService.h"
+
+const static CMPIBroker *_BROKER;
+
+static CMPIStatus set_inst_properties(const CMPIBroker *broker,
+                                      const CMPIObjectPath *ref,
+                                      CMPIInstance *inst)
+{
+        CMPIStatus s = {CMPI_RC_OK, NULL};
+        CMPIBoolean element_edit = false;
+        CMPIArray *array;
+        uint16_t prop_val;
+
+        CMSetProperty(inst, "InstanceID",
+                      (CMPIValue *)"RedirectionCapabilities", CMPI_chars);
+
+        CMSetProperty(inst, "ElementName",
+                      (CMPIValue *)"RedirectionCapabilities", CMPI_chars);
+
+        CMSetProperty(inst, "ElementNameEditSupported",
+                      (CMPIValue *)&element_edit, CMPI_boolean);
+
+        array = CMNewArray(broker, 1, CMPI_uint16, &s);
+        if ((s.rc != CMPI_RC_OK) || CMIsNullObject(array))
+                goto out;
+
+        prop_val = (uint16_t)SHARING_MODE;
+        CMSetArrayElementAt(array, 0, &prop_val, CMPI_uint16);
+
+        CMSetProperty(inst, "SharingModeSupported",
+                      (CMPIValue *)&array, CMPI_uint16A);
+
+ out:
+        return s;
+}
+
+static CMPIStatus get_rs_cap(const CMPIBroker *broker,
+                             const CMPIObjectPath *ref,
+                             CMPIInstance **_inst,
+                             bool is_get_inst)
+{
+        CMPIStatus s = {CMPI_RC_OK, NULL};
+        CMPIInstance *inst = NULL;
+        virConnectPtr conn = NULL;
+
+        conn = connect_by_classname(broker, CLASSNAME(ref), &s);
+        if (conn == NULL) {
+                if (is_get_inst)
+                        cu_statusf(broker, &s,
+                                   CMPI_RC_ERR_NOT_FOUND,
+                                   "No such instance");
+                goto out;
+        }
+
+        inst = get_typed_instance(broker,
+                                  pfx_from_conn(conn),
+                                  "RedirectionServiceCapabilities",
+                                  NAMESPACE(ref));
+        if (inst == NULL) {
+                cu_statusf(broker, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "Can't create instance for %s", CLASSNAME(ref));
+                goto out;
+        }
+
+        s = set_inst_properties(broker, ref, inst);
+
+        if (is_get_inst) {
+                s = cu_validate_ref(broker, ref, inst);
+                if (s.rc != CMPI_RC_OK)
+                        goto out;
+        }
+
+        *_inst = inst;
+
+ out:
+        virConnectClose(conn);
+
+        return s;
+}
+
+static CMPIStatus return_rs_cap(const CMPIObjectPath *ref,
+                                const CMPIResult *results,
+                                bool names_only,
+                                bool is_get_inst)
+{
+        CMPIStatus s = {CMPI_RC_OK, NULL};
+        CMPIInstance *inst = NULL;
+
+        s = get_rs_cap(_BROKER, ref, &inst, is_get_inst);
+        if ((s.rc != CMPI_RC_OK) || (inst == NULL))
+                goto out;
+
+        if (names_only)
+                cu_return_instance_name(results, inst);
+        else
+                CMReturnInstance(results, inst);
+ out:
+        return s;
+}
+
+static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self,
+                                    const CMPIContext *context,
+                                    const CMPIResult *results,
+                                    const CMPIObjectPath *reference)
+{
+        return return_rs_cap(reference, results, true, false);
+}
+
+static CMPIStatus EnumInstances(CMPIInstanceMI *self,
+                                const CMPIContext *context,
+                                const CMPIResult *results,
+                                const CMPIObjectPath *reference,
+                                const char **properties)
+{
+
+        return return_rs_cap(reference, results, false, false);
+}
+
+static CMPIStatus GetInstance(CMPIInstanceMI *self,
+                              const CMPIContext *context,
+                              const CMPIResult *results,
+                              const CMPIObjectPath *reference,
+                              const char **properties)
+{
+        return return_rs_cap(reference, results, false, true);
+}
+
+DEFAULT_CI();
+DEFAULT_MI();
+DEFAULT_DI();
+DEFAULT_EQ();
+DEFAULT_INST_CLEANUP();
+
+STD_InstanceMIStub(,
+                   Virt_RedirectionServiceCapabilities, 
+                   _BROKER,
+                   libvirt_cim_init());
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-set-style: "K&R"
+ * tab-width: 8
+ * c-basic-offset: 8
+ * indent-tabs-mode: nil
+ * End:
+ */




More information about the Libvirt-cim mailing list