mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-11 03:24:58 -06:00
migration/rdma: Make qemu_rdma_buffer_mergeable() return bool
qemu_rdma_buffer_mergeable() is semantically a predicate. It returns int 0 or 1. Return bool instead, and fix the function name's spelling. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Fabiano Rosas <farosas@suse.de> Reviewed-by: Li Zhijian <lizhijian@fujitsu.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com> Message-ID: <20230928132019.2544702-15-armbru@redhat.com>
This commit is contained in:
parent
87e6bdabf0
commit
6a3792d78d
1 changed files with 10 additions and 10 deletions
|
@ -2264,7 +2264,7 @@ static int qemu_rdma_write_flush(RDMAContext *rdma)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int qemu_rdma_buffer_mergable(RDMAContext *rdma,
|
static inline bool qemu_rdma_buffer_mergeable(RDMAContext *rdma,
|
||||||
uint64_t offset, uint64_t len)
|
uint64_t offset, uint64_t len)
|
||||||
{
|
{
|
||||||
RDMALocalBlock *block;
|
RDMALocalBlock *block;
|
||||||
|
@ -2272,11 +2272,11 @@ static inline int qemu_rdma_buffer_mergable(RDMAContext *rdma,
|
||||||
uint8_t *chunk_end;
|
uint8_t *chunk_end;
|
||||||
|
|
||||||
if (rdma->current_index < 0) {
|
if (rdma->current_index < 0) {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rdma->current_chunk < 0) {
|
if (rdma->current_chunk < 0) {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
block = &(rdma->local_ram_blocks.block[rdma->current_index]);
|
block = &(rdma->local_ram_blocks.block[rdma->current_index]);
|
||||||
|
@ -2284,29 +2284,29 @@ static inline int qemu_rdma_buffer_mergable(RDMAContext *rdma,
|
||||||
chunk_end = ram_chunk_end(block, rdma->current_chunk);
|
chunk_end = ram_chunk_end(block, rdma->current_chunk);
|
||||||
|
|
||||||
if (rdma->current_length == 0) {
|
if (rdma->current_length == 0) {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Only merge into chunk sequentially.
|
* Only merge into chunk sequentially.
|
||||||
*/
|
*/
|
||||||
if (offset != (rdma->current_addr + rdma->current_length)) {
|
if (offset != (rdma->current_addr + rdma->current_length)) {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset < block->offset) {
|
if (offset < block->offset) {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((offset + len) > (block->offset + block->length)) {
|
if ((offset + len) > (block->offset + block->length)) {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((host_addr + len) > chunk_end) {
|
if ((host_addr + len) > chunk_end) {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2329,7 +2329,7 @@ static int qemu_rdma_write(RDMAContext *rdma,
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* If we cannot merge it, we flush the current buffer first. */
|
/* If we cannot merge it, we flush the current buffer first. */
|
||||||
if (!qemu_rdma_buffer_mergable(rdma, current_addr, len)) {
|
if (!qemu_rdma_buffer_mergeable(rdma, current_addr, len)) {
|
||||||
ret = qemu_rdma_write_flush(rdma);
|
ret = qemu_rdma_write_flush(rdma);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue