mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-08 16:54:49 +00:00
qemu: Add infrastructure for statistics of a backup job
Introduce QEMU_DOMAIN_JOB_STATS_TYPE_BACKUP and the convertors and other plumbing to be able to report statistics for the backup job. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
c15b0cd601
commit
fed2cb487b
@ -519,6 +519,12 @@ qemuDomainJobInfoToInfo(qemuDomainJobInfoPtr jobInfo,
|
|||||||
info->memRemaining = info->memTotal - info->memProcessed;
|
info->memRemaining = info->memTotal - info->memProcessed;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case QEMU_DOMAIN_JOB_STATS_TYPE_BACKUP:
|
||||||
|
info->fileTotal = jobInfo->stats.backup.total;
|
||||||
|
info->fileProcessed = jobInfo->stats.backup.transferred;
|
||||||
|
info->fileRemaining = info->fileTotal - info->fileProcessed;
|
||||||
|
break;
|
||||||
|
|
||||||
case QEMU_DOMAIN_JOB_STATS_TYPE_NONE:
|
case QEMU_DOMAIN_JOB_STATS_TYPE_NONE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -751,6 +757,59 @@ qemuDomainDumpJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuDomainBackupJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
|
||||||
|
int *type,
|
||||||
|
virTypedParameterPtr *params,
|
||||||
|
int *nparams)
|
||||||
|
{
|
||||||
|
qemuDomainBackupStats *stats = &jobInfo->stats.backup;
|
||||||
|
g_autoptr(virTypedParamList) par = g_new0(virTypedParamList, 1);
|
||||||
|
|
||||||
|
if (virTypedParamListAddInt(par, jobInfo->operation,
|
||||||
|
VIR_DOMAIN_JOB_OPERATION) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (virTypedParamListAddULLong(par, jobInfo->timeElapsed,
|
||||||
|
VIR_DOMAIN_JOB_TIME_ELAPSED) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (stats->transferred > 0 || stats->total > 0) {
|
||||||
|
if (virTypedParamListAddULLong(par, stats->total,
|
||||||
|
VIR_DOMAIN_JOB_DISK_TOTAL) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (virTypedParamListAddULLong(par, stats->transferred,
|
||||||
|
VIR_DOMAIN_JOB_DISK_PROCESSED) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (virTypedParamListAddULLong(par, stats->total - stats->transferred,
|
||||||
|
VIR_DOMAIN_JOB_DISK_REMAINING) < 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stats->tmp_used > 0 || stats->tmp_total > 0) {
|
||||||
|
if (virTypedParamListAddULLong(par, stats->tmp_used,
|
||||||
|
VIR_DOMAIN_JOB_DISK_TEMP_USED) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (virTypedParamListAddULLong(par, stats->tmp_total,
|
||||||
|
VIR_DOMAIN_JOB_DISK_TEMP_TOTAL) < 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jobInfo->status != QEMU_DOMAIN_JOB_STATUS_ACTIVE &&
|
||||||
|
virTypedParamListAddBoolean(par,
|
||||||
|
jobInfo->status == QEMU_DOMAIN_JOB_STATUS_COMPLETED,
|
||||||
|
VIR_DOMAIN_JOB_SUCCESS) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
*nparams = virTypedParamListStealParams(par, params);
|
||||||
|
*type = qemuDomainJobStatusToType(jobInfo->status);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
qemuDomainJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
|
qemuDomainJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
|
||||||
int *type,
|
int *type,
|
||||||
@ -765,6 +824,9 @@ qemuDomainJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
|
|||||||
case QEMU_DOMAIN_JOB_STATS_TYPE_MEMDUMP:
|
case QEMU_DOMAIN_JOB_STATS_TYPE_MEMDUMP:
|
||||||
return qemuDomainDumpJobInfoToParams(jobInfo, type, params, nparams);
|
return qemuDomainDumpJobInfoToParams(jobInfo, type, params, nparams);
|
||||||
|
|
||||||
|
case QEMU_DOMAIN_JOB_STATS_TYPE_BACKUP:
|
||||||
|
return qemuDomainBackupJobInfoToParams(jobInfo, type, params, nparams);
|
||||||
|
|
||||||
case QEMU_DOMAIN_JOB_STATS_TYPE_NONE:
|
case QEMU_DOMAIN_JOB_STATS_TYPE_NONE:
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("invalid job statistics type"));
|
_("invalid job statistics type"));
|
||||||
|
@ -126,6 +126,7 @@ typedef enum {
|
|||||||
QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION,
|
QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION,
|
||||||
QEMU_DOMAIN_JOB_STATS_TYPE_SAVEDUMP,
|
QEMU_DOMAIN_JOB_STATS_TYPE_SAVEDUMP,
|
||||||
QEMU_DOMAIN_JOB_STATS_TYPE_MEMDUMP,
|
QEMU_DOMAIN_JOB_STATS_TYPE_MEMDUMP,
|
||||||
|
QEMU_DOMAIN_JOB_STATS_TYPE_BACKUP,
|
||||||
} qemuDomainJobStatsType;
|
} qemuDomainJobStatsType;
|
||||||
|
|
||||||
|
|
||||||
@ -136,6 +137,14 @@ struct _qemuDomainMirrorStats {
|
|||||||
unsigned long long total;
|
unsigned long long total;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct _qemuDomainBackupStats qemuDomainBackupStats;
|
||||||
|
struct _qemuDomainBackupStats {
|
||||||
|
unsigned long long transferred;
|
||||||
|
unsigned long long total;
|
||||||
|
unsigned long long tmp_used;
|
||||||
|
unsigned long long tmp_total;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct _qemuDomainJobInfo qemuDomainJobInfo;
|
typedef struct _qemuDomainJobInfo qemuDomainJobInfo;
|
||||||
typedef qemuDomainJobInfo *qemuDomainJobInfoPtr;
|
typedef qemuDomainJobInfo *qemuDomainJobInfoPtr;
|
||||||
struct _qemuDomainJobInfo {
|
struct _qemuDomainJobInfo {
|
||||||
@ -160,6 +169,7 @@ struct _qemuDomainJobInfo {
|
|||||||
union {
|
union {
|
||||||
qemuMonitorMigrationStats mig;
|
qemuMonitorMigrationStats mig;
|
||||||
qemuMonitorDumpStats dump;
|
qemuMonitorDumpStats dump;
|
||||||
|
qemuDomainBackupStats backup;
|
||||||
} stats;
|
} stats;
|
||||||
qemuDomainMirrorStats mirrorStats;
|
qemuDomainMirrorStats mirrorStats;
|
||||||
};
|
};
|
||||||
|
@ -13858,6 +13858,10 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case QEMU_DOMAIN_JOB_STATS_TYPE_BACKUP:
|
||||||
|
/* TODO implement for backup job */
|
||||||
|
break;
|
||||||
|
|
||||||
case QEMU_DOMAIN_JOB_STATS_TYPE_NONE:
|
case QEMU_DOMAIN_JOB_STATS_TYPE_NONE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user