]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
api: Allow keeping completed domain job stats when reading them
authorPeter Krempa <pkrempa@redhat.com>
Fri, 22 Nov 2019 12:23:31 +0000 (13:23 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 3 Dec 2019 14:26:53 +0000 (15:26 +0100)
virDomainGetJobStats destroys the completed statistics on the first
read. Give the user possibility to keep them around if they wish so.

Add a flag VIR_DOMAIN_JOB_STATS_KEEP_COMPLETED which will read the stats
without destroying them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
include/libvirt/libvirt-domain.h
src/libvirt-domain.c

index a2f007568c8831873c549401564eef423dca4468..6c21fe10986c4e810e68ebf4c9f372e192aaf4eb 100644 (file)
@@ -3246,6 +3246,8 @@ struct _virDomainJobInfo {
 typedef enum {
     VIR_DOMAIN_JOB_STATS_COMPLETED = 1 << 0, /* return stats of a recently
                                               * completed job */
+    VIR_DOMAIN_JOB_STATS_KEEP_COMPLETED = 1 << 1, /* don't remove completed
+                                                     stats when reading them */
 } virDomainGetJobStatsFlags;
 
 int virDomainGetJobInfo(virDomainPtr dom,
index 87110036ca675a48bb17f34efb7f5dfb81ee661a..b9345804ea81f93396f930d9e4481dfcee7e1b83 100644 (file)
@@ -8796,7 +8796,8 @@ virDomainGetJobInfo(virDomainPtr domain, virDomainJobInfoPtr info)
  * flag may be used to query statistics of a completed incoming pre-copy
  * migration (statistics for post-copy migration are only available on the
  * source host). Statistics of a completed job are automatically destroyed
- * once read or when libvirtd is restarted. Note that time information
+ * once read (unless the VIR_DOMAIN_JOB_STATS_COMPLETED_KEEP is used as well)
+ * or when libvirtd is restarted. Note that time information
  * returned for completed migrations may be completely irrelevant unless both
  * source and destination hosts have synchronized time (i.e., NTP daemon is
  * running on both of them). The statistics of a completed job can also be
@@ -8823,6 +8824,9 @@ virDomainGetJobStats(virDomainPtr domain,
     virCheckNonNullArgGoto(type, error);
     virCheckNonNullArgGoto(params, error);
     virCheckNonNullArgGoto(nparams, error);
+    VIR_REQUIRE_FLAG_GOTO(VIR_DOMAIN_JOB_STATS_KEEP_COMPLETED,
+                          VIR_DOMAIN_JOB_STATS_COMPLETED,
+                          error);
 
     conn = domain->conn;