API: Add VIR_DOMAIN_JOB_ERRMSG domain job statistics field

In some cases it's useful to report the error which caused the domain
job to fail. Add an optional field for holding the error message so that
it can be later retrieved from statistics of a completed job.

Add the field name macro and code for extracting it in virsh.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Peter Krempa 2020-04-15 12:27:53 +02:00
parent 72186f9c8c
commit 4f39774610
2 changed files with 17 additions and 0 deletions

View File

@ -3612,6 +3612,15 @@ typedef enum {
*/
# define VIR_DOMAIN_JOB_SUCCESS "success"
/**
* VIR_DOMAIN_JOB_ERRMSG:
*
* virDomainGetJobStats field: Present only in statistics for a completed job.
* Optional error message for a failed job.
*/
# define VIR_DOMAIN_JOB_ERRMSG "errmsg"
/**
* VIR_DOMAIN_JOB_DISK_TEMP_USED:
* virDomainGetJobStats field: current usage of temporary disk space for the

View File

@ -6226,6 +6226,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
unsigned long long value;
unsigned int flags = 0;
int ivalue;
const char *svalue;
int op;
int rc;
size_t i;
@ -6506,6 +6507,13 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, "%-17s %-.3lf %s\n", _("Temporary disk space total:"), val, unit);
}
if ((rc = virTypedParamsGetString(params, nparams, VIR_DOMAIN_JOB_ERRMSG,
&svalue)) < 0) {
goto save_error;
} else if (rc == 1) {
vshPrint(ctl, "%-17s %s\n", _("Error message:"), svalue);
}
ret = true;
cleanup: