[PATCH 0 of 3] Indications for state changes

This set: - Makes domain state an explicit factor in the dom_changed() determination for CSI - Makes CS trigger CSI on state change to avoid waiting for the loop - Fixes up registration of KVM_ and LXC_ CSI variants

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1214850492 25200 # Node ID 0734a17d5aa18239e8a53b1131ccc02dfecc4874 # Parent b123b6b1fb08c3ab956f1c33801e743e082192b9 Make CSI throw an indication for domain state changes Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r b123b6b1fb08 -r 0734a17d5aa1 src/Virt_ComputerSystemIndication.c --- a/src/Virt_ComputerSystemIndication.c Fri Jun 27 08:59:09 2008 -0700 +++ b/src/Virt_ComputerSystemIndication.c Mon Jun 30 11:28:12 2008 -0700 @@ -62,6 +62,12 @@ struct dom_xml { char uuid[VIR_UUID_STRING_BUFLEN]; char *xml; + enum {DOM_OFFLINE, + DOM_ONLINE, + DOM_PAUSED, + DOM_CRASHED, + DOM_GONE, + } state; }; static void free_dom_xml (struct dom_xml dom) @@ -85,6 +91,35 @@ out: return name; +} + +static int dom_state(virDomainPtr dom) +{ + virDomainInfo info; + int ret; + + ret = virDomainGetInfo(dom, &info); + if (ret != 0) + return DOM_GONE; + + switch (info.state) { + case VIR_DOMAIN_NOSTATE: + case VIR_DOMAIN_RUNNING: + case VIR_DOMAIN_BLOCKED: + return DOM_ONLINE; + + case VIR_DOMAIN_PAUSED: + return DOM_PAUSED; + + case VIR_DOMAIN_SHUTOFF: + return DOM_OFFLINE; + + case VIR_DOMAIN_CRASHED: + return DOM_CRASHED; + + default: + return DOM_GONE; + }; } static CMPIStatus doms_to_xml(struct dom_xml **dom_xml_list, @@ -115,6 +150,8 @@ "Failed to get xml desc"); break; } + + (*dom_xml_list)[i].state = dom_state(dom_ptr_list[i]); } return s; @@ -131,8 +168,15 @@ if (strcmp(cur_xml[i].uuid, prev_dom.uuid) != 0) continue; - if (strcmp(cur_xml[i].xml, prev_dom.xml) != 0) + if (strcmp(cur_xml[i].xml, prev_dom.xml) != 0) { + CU_DEBUG("Domain config changed"); ret = true; + } + + if (prev_dom.state != cur_xml[i].state) { + CU_DEBUG("Domain state changed"); + ret = true; + } break; }

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1214852562 25200 # Node ID 25963f4ea20e26b353d11d4d6f394ae38ce09e9e # Parent 0734a17d5aa18239e8a53b1131ccc02dfecc4874 Make ComputerSystem trigger CSI on RequestStateChange Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 0734a17d5aa1 -r 25963f4ea20e src/Virt_ComputerSystem.c --- a/src/Virt_ComputerSystem.c Mon Jun 30 11:28:12 2008 -0700 +++ b/src/Virt_ComputerSystem.c Mon Jun 30 12:02:42 2008 -0700 @@ -39,6 +39,7 @@ #include "device_parsing.h" #include <libcmpiutil/std_invokemethod.h> #include <libcmpiutil/std_instance.h> +#include <libcmpiutil/std_indication.h> #include "Virt_ComputerSystem.h" #include "Virt_HostSystem.h" @@ -880,9 +881,19 @@ s = __state_change(name, state, reference); - if (s.rc == CMPI_RC_OK) + if (s.rc == CMPI_RC_OK) { + char *type; + + type = get_typed_class(CLASSNAME(reference), + "ComputerSystemModifiedIndication"); + + /* Failure to raise the indication is okay */ + stdi_trigger_indication(_BROKER, + context, + type, + NAMESPACE(reference)); rc = 0; - + } out: CMReturnData(results, &rc, CMPI_uint32);

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1214852563 25200 # Node ID 834563d8520b1876d99bf579cc3319b1dfa09795 # Parent 25963f4ea20e26b353d11d4d6f394ae38ce09e9e Make CSI declare support for KVM and LXC indications Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 25963f4ea20e -r 834563d8520b src/Virt_ComputerSystemIndication.c --- a/src/Virt_ComputerSystemIndication.c Mon Jun 30 12:02:42 2008 -0700 +++ b/src/Virt_ComputerSystemIndication.c Mon Jun 30 12:02:43 2008 -0700 @@ -505,11 +505,23 @@ DECLARE_FILTER(xen_created, "Xen_ComputerSystemCreatedIndication"); DECLARE_FILTER(xen_deleted, "Xen_ComputerSystemDeletedIndication"); DECLARE_FILTER(xen_modified, "Xen_ComputerSystemModifiedIndication"); +DECLARE_FILTER(kvm_created, "KVM_ComputerSystemCreatedIndication"); +DECLARE_FILTER(kvm_deleted, "KVM_ComputerSystemDeletedIndication"); +DECLARE_FILTER(kvm_modified, "KVM_ComputerSystemModifiedIndication"); +DECLARE_FILTER(lxc_created, "LXC_ComputerSystemCreatedIndication"); +DECLARE_FILTER(lxc_deleted, "LXC_ComputerSystemDeletedIndication"); +DECLARE_FILTER(lxc_modified, "LXC_ComputerSystemModifiedIndication"); static struct std_ind_filter *filters[] = { &xen_created, &xen_deleted, &xen_modified, + &kvm_created, + &kvm_deleted, + &kvm_modified, + &lxc_created, + &lxc_deleted, + &lxc_modified, NULL, };

Dan Smith wrote:
This set: - Makes domain state an explicit factor in the dom_changed() determination for CSI - Makes CS trigger CSI on state change to avoid waiting for the loop - Fixes up registration of KVM_ and LXC_ CSI variants
+1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (2)
-
Dan Smith
-
Kaitlin Rupert