Skip to contentSkip to conversation

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

PATCH Superseded Fiona Ebner 2 participants 3 messages Oct 12, 2022

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---
 migration/channel-block.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
migration/channel-block.c +4 -2
index c55c8c93ce..aabc4634a4 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(errp, "bdrv_readv_vmstate returned error %d", ret);
+        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(errp, "bdrv_writev_vmstate returned error %d", ret);
+        return -1;
     }
 
     bioc->offset += qiov.size;
Signature · 1 line
2.30.2
#1 lore raw

Am 12.10.22 um 13:19 schrieb Fiona Ebner:

Quoted 7 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.

CC-ing [email protected] since I messed up when sending the mail. Sorry about that!

#2 lore raw
In reply to Fiona Ebner
Quoted 5 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.

Opps, yes, my bad in writing this code.

Quoted 11 lines
---
 migration/channel-block.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
migration/channel-block.c +0 -0
index c55c8c93ce..aabc4634a4 100644

migration/channel-block.c qio_channel_block_readv(QIOChannel *ioc, · line 65

Quoted 5 lines
migration/channel-block.c +1 -1
@@ -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(errp, "bdrv_readv_vmstate returned error %d", ret);

IIUC, the bdrv functions return errno, so should use

    error_setg_errno(errp, -ret, "bdrv_readv_vmstate returned error");
Quoted 16 lines
migration/channel-block.c +2 -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(errp, "bdrv_writev_vmstate returned error %d", ret);
+        return -1;
     }
 
     bioc->offset += qiov.size;
Signature · 1 line
2.30.2

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|