]> git.proxmox.com Git - pve-qemu.git/commitdiff
savevm async IO channel: channel writev: fix return value in error case
authorFiona Ebner <f.ebner@proxmox.com>
Mon, 17 Oct 2022 07:18:33 +0000 (09:18 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 18 Oct 2022 13:32:13 +0000 (15:32 +0200)
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 blk-functions has the potential to
confuse the call sides. Non-blocking mode is not implemented
currently, so -1 it is.

The "return ret" was mistakenly left over from the previous
QEMUFileOps based implementation. Also, use error_setg_errno(), since
the blk(_co)_p{readv,writev} functions return errno codes.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
debian/patches/pve/0016-PVE-add-IOChannel-implementation-for-savevm-async.patch

index e48eb9d054419fd5afcb2b4c69de6cd7bf3436d9..a1073bd62c39e090e437f5d21f53829d84cc4b7f 100644 (file)
@@ -15,19 +15,19 @@ Additionally, allows tracking the current position from the outside
 
 Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
 ---
- migration/channel-savevm-async.c | 181 +++++++++++++++++++++++++++++++
+ migration/channel-savevm-async.c | 182 +++++++++++++++++++++++++++++++
  migration/channel-savevm-async.h |  51 +++++++++
  migration/meson.build            |   1 +
- 3 files changed, 233 insertions(+)
+ 3 files changed, 234 insertions(+)
  create mode 100644 migration/channel-savevm-async.c
  create mode 100644 migration/channel-savevm-async.h
 
 diff --git a/migration/channel-savevm-async.c b/migration/channel-savevm-async.c
 new file mode 100644
-index 0000000000..efea3842cf
+index 0000000000..06d5484778
 --- /dev/null
 +++ b/migration/channel-savevm-async.c
-@@ -0,0 +1,181 @@
+@@ -0,0 +1,182 @@
 +/*
 + * QIO Channel implementation to be used by savevm-async QMP calls
 + */
@@ -96,7 +96,7 @@ index 0000000000..efea3842cf
 +    // returns 0 on success
 +    ret = blk_preadv(be, *saioc->bs_pos, size, &qiov, 0);
 +    if (ret < 0) {
-+        error_setg(errp, "blk_preadv returned %d", ret);
++        error_setg_errno(errp, -ret, "blk_preadv failed");
 +        return -1;
 +    }
 +
@@ -129,7 +129,8 @@ index 0000000000..efea3842cf
 +    }
 +
 +    if (ret < 0) {
-+        return ret;
++        error_setg_errno(errp, -ret, "blk(_co)_pwritev failed");
++        return -1;
 +    }
 +
 +    *saioc->bs_pos += qiov.size;