Skip to content

Commit

Permalink
migration/rdma: Convert qemu_rdma_write_flush() to Error
Browse files Browse the repository at this point in the history
Functions that use an Error **errp parameter to return errors should
not also report them to the user, because reporting is the caller's
job.  When the caller does, the error is reported twice.  When it
doesn't (because it recovered from the error), there is no error to
report, i.e. the report is bogus.

qio_channel_rdma_writev() violates this principle: it calls
error_report() via qemu_rdma_write_flush().  I elected not to
investigate how callers handle the error, i.e. precise impact is not
known.

Clean this up by converting qemu_rdma_write_flush() to Error.

Necessitates setting an error when qemu_rdma_write_one() failed.
Since this error will go away later in this series, simply use "FIXME
temporary error message" there.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
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-40-armbru@redhat.com>
  • Loading branch information
Markus Armbruster authored and Juan Quintela committed Oct 11, 2023
1 parent de1aa35 commit 5609547
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions migration/rdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -2283,7 +2283,7 @@ static int qemu_rdma_write_one(RDMAContext *rdma,
* We support sending out multiple chunks at the same time.
* Not all of them need to get signaled in the completion queue.
*/
static int qemu_rdma_write_flush(RDMAContext *rdma)
static int qemu_rdma_write_flush(RDMAContext *rdma, Error **errp)
{
int ret;

Expand All @@ -2295,6 +2295,7 @@ static int qemu_rdma_write_flush(RDMAContext *rdma)
rdma->current_index, rdma->current_addr, rdma->current_length);

if (ret < 0) {
error_setg(errp, "FIXME temporary error message");
return -1;
}

Expand Down Expand Up @@ -2368,15 +2369,17 @@ static int qemu_rdma_write(RDMAContext *rdma,
uint64_t block_offset, uint64_t offset,
uint64_t len)
{
Error *err = NULL;
uint64_t current_addr = block_offset + offset;
uint64_t index = rdma->current_index;
uint64_t chunk = rdma->current_chunk;
int ret;

/* If we cannot merge it, we flush the current buffer first. */
if (!qemu_rdma_buffer_mergeable(rdma, current_addr, len)) {
ret = qemu_rdma_write_flush(rdma);
ret = qemu_rdma_write_flush(rdma, &err);
if (ret < 0) {
error_report_err(err);
return -1;
}
rdma->current_length = 0;
Expand All @@ -2393,7 +2396,10 @@ static int qemu_rdma_write(RDMAContext *rdma,

/* flush it if buffer is too large */
if (rdma->current_length >= RDMA_MERGE_MAX) {
return qemu_rdma_write_flush(rdma);
if (qemu_rdma_write_flush(rdma, &err) < 0) {
error_report_err(err);
return -1;
}
}

return 0;
Expand Down Expand Up @@ -2857,10 +2863,9 @@ static ssize_t qio_channel_rdma_writev(QIOChannel *ioc,
* Push out any writes that
* we're queued up for VM's ram.
*/
ret = qemu_rdma_write_flush(rdma);
ret = qemu_rdma_write_flush(rdma, errp);
if (ret < 0) {
rdma->errored = true;
error_setg(errp, "qemu_rdma_write_flush failed");
return -1;
}

Expand Down Expand Up @@ -3002,9 +3007,11 @@ static ssize_t qio_channel_rdma_readv(QIOChannel *ioc,
*/
static int qemu_rdma_drain_cq(RDMAContext *rdma)
{
Error *err = NULL;
int ret;

if (qemu_rdma_write_flush(rdma) < 0) {
if (qemu_rdma_write_flush(rdma, &err) < 0) {
error_report_err(err);
return -1;
}

Expand Down

0 comments on commit 5609547

Please sign in to comment.