+1
Sharad Mishra
System x Enablement
Linux Technology Center
IBM
Kaitlin Rupert
<kaitlin(a)linux.vn
et.ibm.com> To
Sent by: libvirt-cim(a)redhat.com
libvirt-cim-bounc cc
es(a)redhat.com
Subject
[Libvirt-cim] [PATCH 3 of 3] When a
06/29/2009 05:05 guest is modified, raise an
PM indication and set the
PreviousInstance prop
Please respond to
List for
discussion and
development of
libvirt CIM
<libvirt-cim@redh
at.com>
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1245869168 25200
# Node ID 7e1613aaff99b7ff536a9bd0277345bf2d62f4f1
# Parent ca56533192e5a5715c66a8d9ebe0d0fedfe02bd3
When a guest is modified, raise an indication and set the PreviousInstance
prop
Be sure to get the instance of the guest to modifying the guest. This
value is
needed when we generate an indication.
To test this:
Modify a guest and make sure the SourceInstance and PreviousInstance
values differ and are correctly set.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r ca56533192e5 -r 7e1613aaff99 src/Virt_ComputerSystem.c
--- a/src/Virt_ComputerSystem.c Mon Jun 29 17:05:05 2009 -0700
+++ b/src/Virt_ComputerSystem.c Wed Jun 24 11:46:08 2009 -0700
@@ -680,6 +680,39 @@
DEFAULT_EQ();
DEFAULT_INST_CLEANUP();
+static bool trigger_mod_indication(const CMPIContext *context,
+ CMPIInstance *prev_inst,
+ const CMPIObjectPath *ref)
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ const char *ind_name = "ComputerSystemModifiedIndication";
+ CMPIInstance *ind = NULL;
+ char *type = NULL;
+
+ CU_DEBUG("Preparing ComputerSystem indication");
+
+ ind = get_typed_instance(_BROKER,
+ CLASSNAME(ref),
+ ind_name,
+ NAMESPACE(ref));
+ if (ind == NULL) {
+ CU_DEBUG("Failed to create ind '%s'", ind_name);
+ goto out;
+ }
+
+ CU_DEBUG("Setting PreviousInstance");
+ CMSetProperty(ind, "PreviousInstance",
+ (CMPIValue *)&prev_inst, CMPI_instance);
+
+ type = get_typed_class(CLASSNAME(ref), ind_name);
+
+ s = stdi_raise_indication(_BROKER, context, type, NAMESPACE(ref),
ind);
+
+ out:
+ free(type);
+ return s.rc == CMPI_RC_OK;
+}
+
static int xen_scheduler_params(struct infostore_ctx *ctx,
virSchedParameter **params)
{
@@ -1068,10 +1101,12 @@
CMPIArgs *argsout)
{
CMPIStatus s;
+ CMPIInstance *prev_inst = NULL;
uint16_t state;
int ret;
const char *name = NULL;
uint32_t rc = 1;
+ bool ind_rc;
ret = cu_get_u16_arg(argsin, "RequestedState", &state);
if (ret != CMPI_RC_OK) {
@@ -1088,22 +1123,24 @@
goto out;
}
+ /* Retain original instance of the guest to use for the
PreviousInstance attribute when generating an indication. */
+ s = get_domain_by_name(_BROKER, reference, name, &prev_inst);
+ if (s.rc != CMPI_RC_OK || prev_inst == NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_INVALID_PARAMETER,
+ "Unable to get instance for guest '%s'",
+ name);
+ goto out;
+ }
+
s = __state_change(name, state, reference);
if (s.rc == CMPI_RC_OK) {
- char *type = NULL;
-
- type = get_typed_class(CLASSNAME(reference),
-
"ComputerSystemModifiedIndication");
-
- /* Failure to raise the indication is okay */
- stdi_trigger_indication(_BROKER,
- context,
- type,
- NAMESPACE(reference));
+ ind_rc= trigger_mod_indication(context, prev_inst,
reference);
+ if (!ind_rc)
+ CU_DEBUG("Unable to trigger indication");
+
rc = 0;
-
- free(type);
}
out:
CMReturnData(results, &rc, CMPI_uint32);
_______________________________________________
Libvirt-cim mailing list
Libvirt-cim(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvirt-cim