<html><body>
<p>+1<br>
<br>
Sharad Mishra<br>
System x Enablement<br>
Linux Technology Center<br>
IBM<br>
<br>
<img width="16" height="16" src="cid:1__=08BBFF76DFEA0D5F8f9e8a93df938@us.ibm.com" border="0" alt="Inactive hide details for Kaitlin Rupert ---06/29/2009 05:00:16 PM---# HG changeset patch"><font color="#424282">Kaitlin Rupert ---06/29/2009 05:00:16 PM---# HG changeset patch</font><br>
<br>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top"><td style="background-image:url(cid:2__=08BBFF76DFEA0D5F8f9e8a93df938@us.ibm.com); background-repeat: no-repeat; " width="40%">
<ul>
<ul>
<ul>
<ul><b><font size="2">Kaitlin Rupert <kaitlin@linux.vnet.ibm.com></font></b><font size="2"> </font><br>
<font size="2">Sent by: libvirt-cim-bounces@redhat.com</font>
<p><font size="2">06/29/2009 05:05 PM</font>
<table border="1">
<tr valign="top"><td width="168" bgcolor="#FFFFFF"><div align="center"><font size="2">Please respond to<br>
List for discussion and development of libvirt CIM      <libvirt-cim@redhat.com></font></div></td></tr>
</table>
</ul>
</ul>
</ul>
</ul>
</td><td width="60%">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top"><td width="1%"><img width="58" height="1" src="cid:3__=08BBFF76DFEA0D5F8f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<div align="right"><font size="2">To</font></div></td><td width="100%"><img width="1" height="1" src="cid:3__=08BBFF76DFEA0D5F8f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<font size="2">libvirt-cim@redhat.com</font></td></tr>

<tr valign="top"><td width="1%"><img width="58" height="1" src="cid:3__=08BBFF76DFEA0D5F8f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<div align="right"><font size="2">cc</font></div></td><td width="100%"><img width="1" height="1" src="cid:3__=08BBFF76DFEA0D5F8f9e8a93df938@us.ibm.com" border="0" alt=""><br>
</td></tr>

<tr valign="top"><td width="1%"><img width="58" height="1" src="cid:3__=08BBFF76DFEA0D5F8f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<div align="right"><font size="2">Subject</font></div></td><td width="100%"><img width="1" height="1" src="cid:3__=08BBFF76DFEA0D5F8f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<font size="2">[Libvirt-cim] [PATCH 3 of 3] When a guest is modified,   raise an indication and set the PreviousInstance prop</font></td></tr>
</table>

<table border="0" cellspacing="0" cellpadding="0">
<tr valign="top"><td width="58"><img width="1" height="1" src="cid:3__=08BBFF76DFEA0D5F8f9e8a93df938@us.ibm.com" border="0" alt=""></td><td width="336"><img width="1" height="1" src="cid:3__=08BBFF76DFEA0D5F8f9e8a93df938@us.ibm.com" border="0" alt=""></td></tr>
</table>
</td></tr>
</table>
<br>
<tt># HG changeset patch<br>
# User Kaitlin Rupert <karupert@us.ibm.com><br>
# Date 1245869168 25200<br>
# Node ID 7e1613aaff99b7ff536a9bd0277345bf2d62f4f1<br>
# Parent  ca56533192e5a5715c66a8d9ebe0d0fedfe02bd3<br>
When a guest is modified, raise an indication and set the PreviousInstance prop<br>
<br>
Be sure to get the instance of the guest to modifying the guest.  This value is<br>
needed when we generate an indication.<br>
<br>
To test this:<br>
Modify a guest and make sure the SourceInstance and PreviousInstance<br>
values differ and are correctly set.<br>
<br>
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com><br>
<br>
diff -r ca56533192e5 -r 7e1613aaff99 src/Virt_ComputerSystem.c<br>
--- a/src/Virt_ComputerSystem.c          Mon Jun 29 17:05:05 2009 -0700<br>
+++ b/src/Virt_ComputerSystem.c          Wed Jun 24 11:46:08 2009 -0700<br>
@@ -680,6 +680,39 @@<br>
 DEFAULT_EQ();<br>
 DEFAULT_INST_CLEANUP();<br>
 <br>
+static bool trigger_mod_indication(const CMPIContext *context,<br>
+                                   CMPIInstance *prev_inst,<br>
+                                   const CMPIObjectPath *ref)<br>
+{<br>
+        CMPIStatus s = {CMPI_RC_OK, NULL};<br>
+        const char *ind_name = "ComputerSystemModifiedIndication";<br>
+        CMPIInstance *ind = NULL;<br>
+        char *type = NULL;<br>
+<br>
+        CU_DEBUG("Preparing ComputerSystem indication");<br>
+<br>
+        ind = get_typed_instance(_BROKER,<br>
+                                 CLASSNAME(ref),<br>
+                                 ind_name,<br>
+                                 NAMESPACE(ref));<br>
+        if (ind == NULL) {<br>
+                CU_DEBUG("Failed to create ind '%s'", ind_name);<br>
+                goto out;<br>
+        }<br>
+<br>
+        CU_DEBUG("Setting PreviousInstance");<br>
+        CMSetProperty(ind, "PreviousInstance",<br>
+                      (CMPIValue *)&prev_inst, CMPI_instance);<br>
+<br>
+        type = get_typed_class(CLASSNAME(ref), ind_name);<br>
+<br>
+        s = stdi_raise_indication(_BROKER, context, type, NAMESPACE(ref), ind);<br>
+<br>
+ out:<br>
+        free(type);<br>
+        return s.rc == CMPI_RC_OK;<br>
+}<br>
+<br>
 static int xen_scheduler_params(struct infostore_ctx *ctx,<br>
                                 virSchedParameter **params)<br>
 {<br>
@@ -1068,10 +1101,12 @@<br>
                                CMPIArgs *argsout)<br>
 {<br>
         CMPIStatus s;<br>
+        CMPIInstance *prev_inst = NULL;<br>
         uint16_t state;<br>
         int ret;<br>
         const char *name = NULL;<br>
         uint32_t rc = 1;<br>
+        bool ind_rc;<br>
 <br>
         ret = cu_get_u16_arg(argsin, "RequestedState", &state);<br>
         if (ret != CMPI_RC_OK) {<br>
@@ -1088,22 +1123,24 @@<br>
                 goto out;<br>
         }<br>
 <br>
+        /* Retain original instance of the guest to use for the PreviousInstance           attribute when generating an indication. */<br>
+        s = get_domain_by_name(_BROKER, reference, name, &prev_inst);<br>
+        if (s.rc != CMPI_RC_OK || prev_inst == NULL) {<br>
+                cu_statusf(_BROKER, &s,<br>
+                           CMPI_RC_ERR_INVALID_PARAMETER,<br>
+                           "Unable to get instance for guest '%s'",<br>
+                           name);<br>
+                goto out;<br>
+        }<br>
+<br>
         s = __state_change(name, state, reference);<br>
 <br>
         if (s.rc == CMPI_RC_OK) {<br>
-                char *type = NULL;<br>
-<br>
-                type = get_typed_class(CLASSNAME(reference),<br>
-                                       "ComputerSystemModifiedIndication");<br>
-<br>
-                /* Failure to raise the indication is okay */<br>
-                stdi_trigger_indication(_BROKER,<br>
-                                        context,<br>
-                                        type,<br>
-                                        NAMESPACE(reference));<br>
+                ind_rc= trigger_mod_indication(context, prev_inst, reference);<br>
+                if (!ind_rc)<br>
+                        CU_DEBUG("Unable to trigger indication");<br>
+         <br>
                 rc = 0;<br>
-<br>
-                free(type);<br>
         }<br>
  out:<br>
         CMReturnData(results, &rc, CMPI_uint32);<br>
<br>
_______________________________________________<br>
Libvirt-cim mailing list<br>
Libvirt-cim@redhat.com<br>
</tt><tt><a href="https://www.redhat.com/mailman/listinfo/libvirt-cim">https://www.redhat.com/mailman/listinfo/libvirt-cim</a></tt><tt><br>
</tt><br>
</body></html>