On 02/20/2012 05:43 PM, Eduardo Lima (Etrunko) wrote:
From: "Eduardo Lima (Etrunko)" <eblima(a)br.ibm.com>
For Reboot and Shutdown, th RequestStateChange method returns immediately with
return code 0 (successful) even though the state change is still not completed.
According to the DMTF specification DSP1052 (Computer System Profile) the
RequestStateChange() method should return 0x1000 and a corresponding job
reference in the return parameters which can be polled for completion.
Signed-off-by: Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
---
schema/ComputerSystem.mof | 9 ++
src/Virt_ComputerSystem.c | 300 +++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 299 insertions(+), 10 deletions(-)
diff --git a/schema/ComputerSystem.mof b/schema/ComputerSystem.mof
index 10cb8c4..886c085 100644
--- a/schema/ComputerSystem.mof
+++ b/schema/ComputerSystem.mof
@@ -1,5 +1,14 @@
// Copyright IBM Corp. 2007
+class Xen_ComputerSystemStateChangeJob : CIM_ConcreteJob {
+};
+
+class KVM_ComputerSystemStateChangeJob : CIM_ConcreteJob {
+};
+
+class LXC_ComputerSystemStateChangeJob : CIM_ConcreteJob {
+};
+
[Description (
"A class derived from CIM_ComputerSystem to represent "
"the Xen virtual machines/domains running on the system."),
diff --git a/src/Virt_ComputerSystem.c b/src/Virt_ComputerSystem.c
index e6c7e55..dee4ef7 100644
--- a/src/Virt_ComputerSystem.c
+++ b/src/Virt_ComputerSystem.c
@@ -30,23 +30,40 @@
#include <cmpift.h>
#include <cmpimacs.h>
+#include <uuid.h>
#include <libvirt/libvirt.h>
+#include <libvirt/virterror.h>
-#include "cs_util.h"
#include <libcmpiutil/libcmpiutil.h>
-#include "misc_util.h"
-#include "infostore.h"
-#include "device_parsing.h"
#include <libcmpiutil/std_invokemethod.h>
#include <libcmpiutil/std_instance.h>
#include <libcmpiutil/std_indication.h>
+#include "cs_util.h"
+#include "misc_util.h"
+#include "infostore.h"
+#include "device_parsing.h"
+#include "svpc_types.h"
+
#include "Virt_ComputerSystem.h"
#include "Virt_HostSystem.h"
#include "Virt_VirtualSystemSnapshotService.h"
+
const static CMPIBroker *_BROKER;
+typedef struct _state_change_job state_change_job_t;
+struct _state_change_job {
+ char uuid[VIR_UUID_STRING_BUFLEN];
+ CMPIContext *context;
+ CMPIObjectPath *obj_path;
+ char *dom_name;
+ uint16_t dom_state;
+ uint16_t status; /* job status */
+};
+
+static bool events_registered = false;
+
/* Set the "Name" property of an instance from a domain */
static int set_name_from_dom(virDomainPtr dom, CMPIInstance *instance)
{
@@ -1189,19 +1206,20 @@ static CMPIStatus __state_change(const char *name,
s = state_change_enable(dom, &info);
else if (state == CIM_STATE_DISABLED)
s = state_change_disable(dom, &info);
- else if (state == CIM_STATE_SHUTDOWN)
- s = state_change_shutdown(dom, &info);
else if (state == CIM_STATE_PAUSED)
s = state_change_pause(dom, &info);
- else if (state == CIM_STATE_REBOOT)
- s = state_change_reboot(dom, &info);
else if (state == CIM_STATE_RESET)
s = state_change_reset(dom, &info);
+ else if (state == CIM_STATE_SHUTDOWN || state == CIM_STATE_REBOOT)
+ s.rc = CIM_SVPC_RETURN_JOB_STARTED;
else
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_NOT_SUPPORTED,
"State not supported");
+ if (s.rc != CMPI_RC_OK || s.rc != CIM_SVPC_RETURN_JOB_STARTED)
+ goto out;
+
This block is wrong, should be && instead of ||.
Best regards, Eduardo
--
Eduardo de Barros Lima
Software Engineer, Open Virtualization
Linux Technology Center - IBM/Brazil
eblima(a)br.ibm.com