diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index 501996bc84f1829324e6f996a611ec86d3b26f61..c9e96a6c90bc9ab6b0d7d2ad923a451297a0a55f 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -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: * diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index db8accfe436b9504415869ac4b0fd683ffcb2e7b..0d19d0e0126e4d6fa10a5f072788365b9cffcaac 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -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,