migration/rdma: Convert qemu_rdma_write_flush() to Error
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>
This commit is contained in:
parent
de1aa35f8d
commit
5609547781
@ -2283,7 +2283,7 @@ retry:
|
||||
* 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;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -2368,6 +2369,7 @@ 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;
|
||||
@ -2375,8 +2377,9 @@ static int qemu_rdma_write(RDMAContext *rdma,
|
||||
|
||||
/* 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;
|
||||
@ -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;
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user