Skip to content

Commit 5e7ca4a

Browse files
zhijianli88xzpeter
authored andcommitted
migration: Unfold control_save_page()
control_save_page() is for RDMA only, unfold it to make the code more clear. In addition: - Similar to other branches style in ram_save_target_page(), involve RDMA only if the condition 'migrate_rdma()' is true. - Further simplify the code by removing the RAM_SAVE_CONTROL_NOT_SUPP. Reviewed-by: Peter Xu <[email protected]> Signed-off-by: Li Zhijian <[email protected]> Message-ID: <[email protected]> Signed-off-by: Fabiano Rosas <[email protected]>
1 parent 4ecd6be commit 5e7ca4a

File tree

3 files changed

+10
-34
lines changed

3 files changed

+10
-34
lines changed

migration/ram.c

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,32 +1143,6 @@ static int save_zero_page(RAMState *rs, PageSearchStatus *pss,
11431143
return len;
11441144
}
11451145

1146-
/*
1147-
* @pages: the number of pages written by the control path,
1148-
* < 0 - error
1149-
* > 0 - number of pages written
1150-
*
1151-
* Return true if the pages has been saved, otherwise false is returned.
1152-
*/
1153-
static bool control_save_page(PageSearchStatus *pss,
1154-
ram_addr_t offset, int *pages)
1155-
{
1156-
int ret;
1157-
1158-
ret = rdma_control_save_page(pss->pss_channel, pss->block->offset, offset,
1159-
TARGET_PAGE_SIZE);
1160-
if (ret == RAM_SAVE_CONTROL_NOT_SUPP) {
1161-
return false;
1162-
}
1163-
1164-
if (ret == RAM_SAVE_CONTROL_DELAYED) {
1165-
*pages = 1;
1166-
return true;
1167-
}
1168-
*pages = ret;
1169-
return true;
1170-
}
1171-
11721146
/*
11731147
* directly send the page to the stream
11741148
*
@@ -1965,7 +1939,13 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss)
19651939
int res;
19661940

19671941
/* Hand over to RDMA first */
1968-
if (control_save_page(pss, offset, &res)) {
1942+
if (migrate_rdma()) {
1943+
res = rdma_control_save_page(pss->pss_channel, pss->block->offset,
1944+
offset, TARGET_PAGE_SIZE);
1945+
1946+
if (res == RAM_SAVE_CONTROL_DELAYED) {
1947+
res = 1;
1948+
}
19691949
return res;
19701950
}
19711951

migration/rdma.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3284,14 +3284,11 @@ static int qemu_rdma_save_page(QEMUFile *f, ram_addr_t block_offset,
32843284
int rdma_control_save_page(QEMUFile *f, ram_addr_t block_offset,
32853285
ram_addr_t offset, size_t size)
32863286
{
3287-
if (!migrate_rdma()) {
3288-
return RAM_SAVE_CONTROL_NOT_SUPP;
3289-
}
3287+
assert(migrate_rdma());
32903288

32913289
int ret = qemu_rdma_save_page(f, block_offset, offset, size);
32923290

3293-
if (ret != RAM_SAVE_CONTROL_DELAYED &&
3294-
ret != RAM_SAVE_CONTROL_NOT_SUPP) {
3291+
if (ret != RAM_SAVE_CONTROL_DELAYED) {
32953292
if (ret < 0) {
32963293
qemu_file_set_error(f, ret);
32973294
}

migration/rdma.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ void rdma_start_incoming_migration(InetSocketAddress *host_port, Error **errp);
3333
#define RAM_CONTROL_ROUND 1
3434
#define RAM_CONTROL_FINISH 3
3535

36-
#define RAM_SAVE_CONTROL_NOT_SUPP -1000
3736
#define RAM_SAVE_CONTROL_DELAYED -2000
3837

3938
#ifdef CONFIG_RDMA
@@ -56,7 +55,7 @@ static inline
5655
int rdma_control_save_page(QEMUFile *f, ram_addr_t block_offset,
5756
ram_addr_t offset, size_t size)
5857
{
59-
return RAM_SAVE_CONTROL_NOT_SUPP;
58+
g_assert_not_reached();
6059
}
6160
#endif
6261
#endif

0 commit comments

Comments
 (0)