Skip to contentSkip to conversation

migration/channel-block: fix return value for qio_channel_block_{readv, writev}

PATCH Applied Fiona Ebner 3 participants 4 messages Oct 13, 2022 – Oct 18, 2022

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 migration/channel-block: fix return value for qio_channel_block_{readv, writev}

in the error case. The documentation in include/io/channel.h states that -1 or QIO_CHANNEL_ERR_BLOCK should be returned upon error. Simply passing along the return value from the bdrv-functions has the potential to confuse the call sides. Non-blocking mode is not implemented currently, so -1 it is.

---

v1 -> v2:
* Use error_setg_errno() instead of error_setg().
* Use "failed" instead of "returned error" in error message. Now that no numerical error code is used, this sounds a bit nicer IMHO.

 migration/channel-block.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
migration/channel-block.c +4 -2
index c55c8c93ce..f4ab53acdb 100644
@@ -62,7 +62,8 @@ qio_channel_block_readv(QIOChannel *ioc,
     qemu_iovec_init_external(&qiov, (struct iovec *)iov, niov);
     ret = bdrv_readv_vmstate(bioc->bs, &qiov, bioc->offset);
     if (ret < 0) {
-        return ret;
+        error_setg_errno(errp, -ret, "bdrv_readv_vmstate failed");
+        return -1;
     }
 
     bioc->offset += qiov.size;
@@ -86,7 +87,8 @@ qio_channel_block_writev(QIOChannel *ioc,
     qemu_iovec_init_external(&qiov, (struct iovec *)iov, niov);
     ret = bdrv_writev_vmstate(bioc->bs, &qiov, bioc->offset);
     if (ret < 0) {
-        return ret;
+        error_setg_errno(errp, -ret, "bdrv_writev_vmstate failed");
+        return -1;
     }
 
     bioc->offset += qiov.size;
Signature · 1 line
2.30.2
Reviewed-by on v2 1/1 Applied
#1 lore raw

Re: [PATCH v2] migration/channel-block: fix return value for qio_channel_block_{readv,writev}

Quoted 7 lines · Fiona Ebner

in the error case. The documentation in include/io/channel.h states that -1 or QIO_CHANNEL_ERR_BLOCK should be returned upon error. Simply passing along the return value from the bdrv-functions has the potential to confuse the call sides. Non-blocking mode is not implemented currently, so -1 it is.

Queued in migration tree.

Reviewed-by on v2 1/1
#2 lore raw
In reply to Fiona Ebner
Quoted 11 lines

-----Original Message-----
From: Qemu-devel <[email protected]> On Behalf Of Fiona Ebner
Sent: Thursday, October 13, 2022 4:41 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: [PATCH v2] migration/channel-block: fix return value for qio_channel_block_{readv, writev}

Quoted 6 lines

in the error case. The documentation in include/io/channel.h states that -1 or QIO_CHANNEL_ERR_BLOCK should be returned upon error. Simply passing along the return value from the bdrv-functions has the potential to confuse the call sides. Non-blocking mode is not implemented currently, so -1 it is.

LGTM.

But I found the same problem elsewhere, for example:
"qio_channel_rdma_writev/readv", "qio_channel_buffer_writev/readv"...etc...

Can you send other patches to fix it?

Thanks
Chen

Quoted 39 lines

---

v1 -> v2:
* Use error_setg_errno() instead of error_setg().
* Use "failed" instead of "returned error" in error message. Now that no numerical error code is used, this sounds a bit nicer IMHO.

 migration/channel-block.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
migration/channel-block.c index renamed from migration/channel-block.c +0 -0

c55c8c93ce..f4ab53acdb 100644

migration/channel-block.c +4 -3
@@ -62,7 +62,8 @@ qio_channel_block_readv(QIOChannel *ioc,
     qemu_iovec_init_external(&qiov, (struct iovec *)iov, niov);
     ret = bdrv_readv_vmstate(bioc->bs, &qiov, bioc->offset);
     if (ret < 0) {
-        return ret;
+        error_setg_errno(errp, -ret, "bdrv_readv_vmstate failed");
+        return -1;
     }
 
     bioc->offset += qiov.size;
@@ -86,7 +87,8 @@ qio_channel_block_writev(QIOChannel *ioc,
     qemu_iovec_init_external(&qiov, (struct iovec *)iov, niov);
     ret = bdrv_writev_vmstate(bioc->bs, &qiov, bioc->offset);
     if (ret < 0) {
-        return ret;
+        error_setg_errno(errp, -ret, "bdrv_writev_vmstate failed");
+        return -1;
     }
 
     bioc->offset += qiov.size;
--

2.30.2

#3 lore raw

Am 17.10.22 um 11:54 schrieb Zhang, Chen:

Quoted 18 lines
Quoted 11 lines

-----Original Message-----
From: Qemu-devel <[email protected]> On Behalf Of Fiona Ebner
Sent: Thursday, October 13, 2022 4:41 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: [PATCH v2] migration/channel-block: fix return value for qio_channel_block_{readv, writev}

Quoted 6 lines

in the error case. The documentation in include/io/channel.h states that -1 or QIO_CHANNEL_ERR_BLOCK should be returned upon error. Simply passing along the return value from the bdrv-functions has the potential to confuse the call sides. Non-blocking mode is not implemented currently, so -1 it is.

Quoted 8 lines

LGTM.

But I found the same problem elsewhere, for example:
"qio_channel_rdma_writev/readv", "qio_channel_buffer_writev/readv"...etc...

Can you send other patches to fix it?

Thank you for the review! Unfortunately, I'll be pretty busy in the coming weeks, because we have some releases coming up. But if nobody else sends patches until those are done, I'll take a look then.

Best Regards,
Fiona

Quoted 4 lines

Thanks
Chen