iotests: Test media change with iothreads
[qemu/kevin.git] / migration / migration-stats.h
blob2358caad63827c383ae7994665bc27c1c1ea7a53
1 /*
2 * Migration stats
4 * Copyright (c) 2012-2023 Red Hat Inc
6 * Authors:
7 * Juan Quintela <quintela@redhat.com>
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
13 #ifndef QEMU_MIGRATION_STATS_H
14 #define QEMU_MIGRATION_STATS_H
16 #include "qemu/stats64.h"
19 * Amount of time to allocate to each "chunk" of bandwidth-throttled
20 * data.
22 #define BUFFER_DELAY 100
25 * If rate_limit_max is 0, there is special code to remove the rate
26 * limit.
28 #define RATE_LIMIT_DISABLED 0
31 * These are the ram migration statistic counters. It is loosely
32 * based on MigrationStats. We change to Stat64 any counter that
33 * needs to be updated using atomic ops (can be accessed by more than
34 * one thread).
36 typedef struct {
38 * Number of bytes that were dirty last time that we synced with
39 * the guest memory. We use that to calculate the downtime. As
40 * the remaining dirty amounts to what we know that is still dirty
41 * since last iteration, not counting what the guest has dirtied
42 * since we synchronized bitmaps.
44 Stat64 dirty_bytes_last_sync;
46 * Number of pages dirtied per second.
48 Stat64 dirty_pages_rate;
50 * Number of times we have synchronized guest bitmaps.
52 Stat64 dirty_sync_count;
54 * Number of times zero copy failed to send any page using zero
55 * copy.
57 Stat64 dirty_sync_missed_zero_copy;
59 * Number of bytes sent at migration completion stage while the
60 * guest is stopped.
62 Stat64 downtime_bytes;
64 * Number of bytes sent through multifd channels.
66 Stat64 multifd_bytes;
68 * Number of pages transferred that were not full of zeros.
70 Stat64 normal_pages;
72 * Number of bytes sent during postcopy.
74 Stat64 postcopy_bytes;
76 * Number of postcopy page faults that we have handled during
77 * postcopy stage.
79 Stat64 postcopy_requests;
81 * Number of bytes sent during precopy stage.
83 Stat64 precopy_bytes;
85 * Amount of transferred data at the start of current cycle.
87 Stat64 rate_limit_start;
89 * Maximum amount of data we can send in a cycle.
91 Stat64 rate_limit_max;
93 * Number of bytes sent through RDMA.
95 Stat64 rdma_bytes;
97 * Total number of bytes transferred.
99 Stat64 transferred;
101 * Number of pages transferred that were full of zeros.
103 Stat64 zero_pages;
104 } MigrationAtomicStats;
106 extern MigrationAtomicStats mig_stats;
109 * migration_rate_get: Get the maximum amount that can be transferred.
111 * Returns the maximum number of bytes that can be transferred in a cycle.
113 uint64_t migration_rate_get(void);
116 * migration_rate_reset: Reset the rate limit counter.
118 * This is called when we know we start a new transfer cycle.
120 * @f: QEMUFile used for main migration channel
122 void migration_rate_reset(QEMUFile *f);
125 * migration_rate_set: Set the maximum amount that can be transferred.
127 * Sets the maximum amount of bytes that can be transferred in one cycle.
129 * @new_rate: new maximum amount
131 void migration_rate_set(uint64_t new_rate);
134 * migration_transferred_bytes: Return number of bytes transferred
136 * @f: QEMUFile used for main migration channel
138 * Returns how many bytes have we transferred since the beginning of
139 * the migration. It accounts for bytes sent through any migration
140 * channel, multifd, qemu_file, rdma, ....
142 uint64_t migration_transferred_bytes(QEMUFile *f);
143 #endif