]> git.proxmox.com Git - mirror_qemu.git/blame - migration/migration-stats.h
Merge tag 'pull-trivial-patches' of https://gitlab.com/mjt0k/qemu into staging
[mirror_qemu.git] / migration / migration-stats.h
CommitLineData
947701cc
JQ
1/*
2 * Migration stats
3 *
4 * Copyright (c) 2012-2023 Red Hat Inc
5 *
6 * Authors:
7 * Juan Quintela <quintela@redhat.com>
8 *
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.
11 */
12
13#ifndef QEMU_MIGRATION_STATS_H
14#define QEMU_MIGRATION_STATS_H
15
16#include "qemu/stats64.h"
17
e1fde0e0
JQ
18/*
19 * Amount of time to allocate to each "chunk" of bandwidth-throttled
20 * data.
21 */
22#define BUFFER_DELAY 100
23
8e4b2a70
JQ
24/*
25 * If rate_limit_max is 0, there is special code to remove the rate
26 * limit.
27 */
28#define RATE_LIMIT_DISABLED 0
29
947701cc
JQ
30/*
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).
35 */
36typedef struct {
e2ee2005
JQ
37 /*
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.
43 */
947701cc 44 Stat64 dirty_bytes_last_sync;
e2ee2005
JQ
45 /*
46 * Number of pages dirtied per second.
47 */
947701cc 48 Stat64 dirty_pages_rate;
e2ee2005
JQ
49 /*
50 * Number of times we have synchronized guest bitmaps.
51 */
947701cc 52 Stat64 dirty_sync_count;
e2ee2005
JQ
53 /*
54 * Number of times zero copy failed to send any page using zero
55 * copy.
56 */
947701cc 57 Stat64 dirty_sync_missed_zero_copy;
e2ee2005
JQ
58 /*
59 * Number of bytes sent at migration completion stage while the
60 * guest is stopped.
61 */
947701cc 62 Stat64 downtime_bytes;
e2ee2005
JQ
63 /*
64 * Number of bytes sent through multifd channels.
65 */
947701cc 66 Stat64 multifd_bytes;
e2ee2005
JQ
67 /*
68 * Number of pages transferred that were not full of zeros.
69 */
947701cc 70 Stat64 normal_pages;
e2ee2005
JQ
71 /*
72 * Number of bytes sent during postcopy.
73 */
947701cc 74 Stat64 postcopy_bytes;
e2ee2005
JQ
75 /*
76 * Number of postcopy page faults that we have handled during
77 * postcopy stage.
78 */
947701cc 79 Stat64 postcopy_requests;
e2ee2005
JQ
80 /*
81 * Number of bytes sent during precopy stage.
82 */
947701cc 83 Stat64 precopy_bytes;
2d897237
JQ
84 /*
85 * Number of bytes transferred with QEMUFile.
86 */
87 Stat64 qemu_file_transferred;
813cd616
JQ
88 /*
89 * Amount of transferred data at the start of current cycle.
90 */
91 Stat64 rate_limit_start;
e1fde0e0
JQ
92 /*
93 * Maximum amount of data we can send in a cycle.
94 */
95 Stat64 rate_limit_max;
67c31c9c
JQ
96 /*
97 * Number of bytes sent through RDMA.
98 */
99 Stat64 rdma_bytes;
40f240a7
JQ
100 /*
101 * Number of pages transferred that were full of zeros.
102 */
103 Stat64 zero_pages;
96820df2 104} MigrationAtomicStats;
947701cc 105
96820df2 106extern MigrationAtomicStats mig_stats;
947701cc 107
e1fde0e0
JQ
108/**
109 * migration_rate_get: Get the maximum amount that can be transferred.
110 *
111 * Returns the maximum number of bytes that can be transferred in a cycle.
112 */
113uint64_t migration_rate_get(void);
114
115/**
116 * migration_rate_reset: Reset the rate limit counter.
117 *
118 * This is called when we know we start a new transfer cycle.
119 */
0743f41f 120void migration_rate_reset(void);
e1fde0e0
JQ
121
122/**
123 * migration_rate_set: Set the maximum amount that can be transferred.
124 *
125 * Sets the maximum amount of bytes that can be transferred in one cycle.
126 *
127 * @new_rate: new maximum amount
128 */
129void migration_rate_set(uint64_t new_rate);
99319e2d
JQ
130
131/**
132 * migration_transferred_bytes: Return number of bytes transferred
133 *
99319e2d
JQ
134 * Returns how many bytes have we transferred since the beginning of
135 * the migration. It accounts for bytes sent through any migration
136 * channel, multifd, qemu_file, rdma, ....
137 */
f57e5a6c 138uint64_t migration_transferred_bytes(void);
947701cc 139#endif