[Libvirt-cim] [PATCH 1/2] VSMigrationService: Move job state definitions to svpc_types.h

Daniel Veillard veillard at redhat.com
Tue Jul 10 05:56:02 UTC 2012


On Wed, Jun 27, 2012 at 03:58:01PM -0300, Eduardo Lima (Etrunko) wrote:
> From: "Eduardo Lima (Etrunko)" <eblima at br.ibm.com>
> 
> Further job implementations may reuse these values.
> 
> Signed-off-by: Eduardo Lima (Etrunko) <eblima at br.ibm.com>
> ---
>  src/Virt_VSMigrationService.c |   14 +++++---------
>  src/svpc_types.h              |   13 +++++++++++++
>  2 files changed, 18 insertions(+), 9 deletions(-)
> 
> diff --git a/src/Virt_VSMigrationService.c b/src/Virt_VSMigrationService.c
> index 76e3d25..a6b5fc0 100644
> --- a/src/Virt_VSMigrationService.c
> +++ b/src/Virt_VSMigrationService.c
> @@ -52,10 +52,6 @@
>  
>  #include "config.h"
>  
> -#define CIM_JOBSTATE_STARTING 3
> -#define CIM_JOBSTATE_RUNNING 4
> -#define CIM_JOBSTATE_COMPLETE 7
> -
>  #define MIGRATE_SHUTDOWN_TIMEOUT 120
>  
>  #define METHOD_RETURN(r, v) do {                                        \
> @@ -1289,19 +1285,19 @@ static CMPI_THREAD_RETURN migration_thread(struct migration_job *job)
>          CBAttachThread(_BROKER, job->context);
>  
>          CU_DEBUG("Migration Job %s started", job->uuid);
> -        migrate_job_set_state(job, CIM_JOBSTATE_RUNNING, 0, "Running");
> +        migrate_job_set_state(job, CIM_JOB_STATE_RUNNING, 0, "Running");
>  
>          s = migrate_vs(job);
>  
>          CU_DEBUG("Migration Job %s finished: %i", job->uuid, s.rc);
>          if (s.rc != CMPI_RC_OK)
>                  migrate_job_set_state(job,
> -                                      CIM_JOBSTATE_COMPLETE,
> +                                      CIM_JOB_STATE_COMPLETED,
>                                        s.rc,
>                                        CMGetCharPtr(s.msg));
>          else
>                  migrate_job_set_state(job,
> -                                      CIM_JOBSTATE_COMPLETE,
> +                                      CIM_JOB_STATE_COMPLETED,
>                                        0,
>                                        "Completed");
>  
> @@ -1361,7 +1357,7 @@ static CMPIInstance *_migrate_job_new_instance(const char *cn,
>          }
>  
>          inst = CMNewInstance(_BROKER, op, &s);
> -        if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(op))) {
> +        if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(inst))) {
>                  CU_DEBUG("Failed to create instance from ref: %s",
>                           CMGetCharPtr(CMObjectPathToString(op, NULL)));
>                  return NULL;
> @@ -1378,7 +1374,7 @@ static CMPIStatus migrate_create_job_instance(const CMPIContext *context,
>          CMPIInstance *jobinst;
>          CMPIDateTime *start;
>          CMPIBoolean autodelete = true;
> -        uint16_t state = CIM_JOBSTATE_STARTING;
> +        uint16_t state = CIM_JOB_STATE_STARTING;
>          char *type = NULL;
>  
>          start = CMNewDateTime(_BROKER, &s);
> diff --git a/src/svpc_types.h b/src/svpc_types.h
> index 90bb608..338a7ef 100644
> --- a/src/svpc_types.h
> +++ b/src/svpc_types.h
> @@ -167,5 +167,18 @@ enum CIM_op_status {
>          CIM_OP_STATUS_POWER_MODE = 18,
>  };
>  
> +enum CIM_job_state {
> +        CIM_JOB_STATE_NEW = 2,
> +        CIM_JOB_STATE_STARTING,
> +        CIM_JOB_STATE_RUNNING,
> +        CIM_JOB_STATE_SUSPENDED,
> +        CIM_JOB_STATE_SHUTTING_DOWN,
> +        CIM_JOB_STATE_COMPLETED,
> +        CIM_JOB_STATE_TERMINATED,
> +        CIM_JOB_STATE_KILLED,
> +        CIM_JOB_STATE_EXCEPTION,
> +        CIM_JOB_STATE_SERVICE,
> +        CIM_JOB_STATE_QUERY_PENDING,
> +};

  Okay, that looks fairly safe as the values for the enums are preserved.
i would just suggest to explicitely set the values instead of relying on
C for propagating the right value:


 +        CIM_JOB_STATE_STARTING = 3,
 +        CIM_JOB_STATE_RUNNING = 4,
 +        CIM_JOB_STATE_SUSPENDED = 5,
 +        CIM_JOB_STATE_SHUTTING_DOWN = 6,
 +        CIM_JOB_STATE_COMPLETED = 7,
 +        CIM_JOB_STATE_TERMINATED = 8,
 +        CIM_JOB_STATE_KILLED = 9,
 +        CIM_JOB_STATE_EXCEPTION = 10,
 +        CIM_JOB_STATE_SERVICE = 11,
 +        CIM_JOB_STATE_QUERY_PENDING = 12,

ACK,

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/




More information about the Libvirt-cim mailing list