Add VIR_DOMAIN_JOB_OPERATION typed parameter

The parameter is reported by virDomainGetJobStats API and
VIR_DOMAIN_EVENT_ID_JOB_COMPLETED event and it can be used to identify
the operation (migration, snapshot, ...) to which the reported
statistics belong.

https://bugzilla.redhat.com/show_bug.cgi?id=1441563

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Jiri Denemark 2017-04-26 11:59:59 +02:00
parent 6ff38cee60
commit b1c79d785f
2 changed files with 54 additions and 0 deletions

View File

@ -3117,6 +3117,31 @@ int virDomainGetJobStats(virDomainPtr domain,
unsigned int flags);
int virDomainAbortJob(virDomainPtr dom);
typedef enum {
VIR_DOMAIN_JOB_OPERATION_UNKNOWN = 0,
VIR_DOMAIN_JOB_OPERATION_START = 1,
VIR_DOMAIN_JOB_OPERATION_SAVE = 2,
VIR_DOMAIN_JOB_OPERATION_RESTORE = 3,
VIR_DOMAIN_JOB_OPERATION_MIGRATION_IN = 4,
VIR_DOMAIN_JOB_OPERATION_MIGRATION_OUT = 5,
VIR_DOMAIN_JOB_OPERATION_SNAPSHOT = 6,
VIR_DOMAIN_JOB_OPERATION_SNAPSHOT_REVERT = 7,
VIR_DOMAIN_JOB_OPERATION_DUMP = 8,
# ifdef VIR_ENUM_SENTINELS
VIR_DOMAIN_JOB_OPERATION_LAST
# endif
} virDomainJobOperation;
/**
* VIR_DOMAIN_JOB_OPERATION:
*
* virDomainGetJobStats field: the operation which started the job as
* VIR_TYPED_PARAM_INT. The values correspond to the items in
* virDomainJobOperation enum.
*/
# define VIR_DOMAIN_JOB_OPERATION "operation"
/**
* VIR_DOMAIN_JOB_TIME_ELAPSED:
*

View File

@ -5658,6 +5658,26 @@ virshDomainJobToString(int type)
return str ? _(str) : _("unknown");
}
VIR_ENUM_DECL(virshDomainJobOperation);
VIR_ENUM_IMPL(virshDomainJobOperation,
VIR_DOMAIN_JOB_OPERATION_LAST,
N_("Unknown"),
N_("Start"),
N_("Save"),
N_("Restore"),
N_("Incoming migration"),
N_("Outgoing migration"),
N_("Snapshot"),
N_("Snapshot revert"),
N_("Dump"))
static const char *
virshDomainJobOperationToString(int op)
{
const char *str = virshDomainJobOperationTypeToString(op);
return str ? _(str) : _("unknown");
}
static bool
cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
{
@ -5671,6 +5691,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
unsigned long long value;
unsigned int flags = 0;
int ivalue;
int op;
int rc;
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
@ -5740,6 +5761,14 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
op = VIR_DOMAIN_JOB_OPERATION_UNKNOWN;
if ((rc = virTypedParamsGetInt(params, nparams,
VIR_DOMAIN_JOB_OPERATION, &op)) < 0)
goto save_error;
vshPrint(ctl, "%-17s %-12s\n", _("Operation:"),
virshDomainJobOperationToString(op));
vshPrint(ctl, "%-17s %-12llu ms\n", _("Time elapsed:"), info.timeElapsed);
if ((rc = virTypedParamsGetULLong(params, nparams,
VIR_DOMAIN_JOB_TIME_ELAPSED_NET,