From: Fabiano Rosas <farosas@suse.de>
To: qemu-devel@nongnu.org
Cc: Juan Quintela <quintela@redhat.com>, Peter Xu <peterx@redhat.com>,
Leonardo Bras <leobras@redhat.com>
Subject: [PATCH 2/2] migration: Make it clear that qemu_file_set_error() needs a negative value
Date: Thu, 6 Jul 2023 16:52:01 -0300 [thread overview]
Message-ID: <20230706195201.18595-3-farosas@suse.de> (raw)
In-Reply-To: <20230706195201.18595-1-farosas@suse.de>
The convention in qemu-file.c is to return a negative value on
error.
The only place that could use qemu_file_set_error() to store a
positive value to f->last_error was vmstate_save() which has been
fixed in the previous patch.
bdrv_inactivate_all() already returns a negative value on error.
Document that qemu_file_set_error() needs -errno and alter the callers
to check ret < 0.
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
migration/qemu-file.c | 2 ++
migration/savevm.c | 6 +++---
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/migration/qemu-file.c b/migration/qemu-file.c
index acc282654a..8276bac248 100644
--- a/migration/qemu-file.c
+++ b/migration/qemu-file.c
@@ -222,6 +222,8 @@ int qemu_file_get_error(QEMUFile *f)
/*
* Set the last error for stream f
+ *
+ * The error ('ret') should be in -errno format.
*/
void qemu_file_set_error(QEMUFile *f, int ret)
{
diff --git a/migration/savevm.c b/migration/savevm.c
index 95c2abf47c..f3c303ab74 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1249,7 +1249,7 @@ void qemu_savevm_state_setup(QEMUFile *f)
QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
if (se->vmsd && se->vmsd->early_setup) {
ret = vmstate_save(f, se, ms->vmdesc);
- if (ret) {
+ if (ret < 0) {
qemu_file_set_error(f, ret);
break;
}
@@ -1464,7 +1464,7 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f,
}
ret = vmstate_save(f, se, vmdesc);
- if (ret) {
+ if (ret < 0) {
qemu_file_set_error(f, ret);
return ret;
}
@@ -1474,7 +1474,7 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f,
/* Inactivate before sending QEMU_VM_EOF so that the
* bdrv_activate_all() on the other end won't fail. */
ret = bdrv_inactivate_all();
- if (ret) {
+ if (ret < 0) {
error_report("%s: bdrv_inactivate_all() failed (%d)",
__func__, ret);
qemu_file_set_error(f, ret);
--
2.35.3
next prev parent reply other threads:[~2023-07-06 19:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-06 19:51 [PATCH 0/2] migration: Only pass negative values to qemu_file_set_error() Fabiano Rosas
2023-07-06 19:52 ` [PATCH 1/2] target/arm: Return negative value on power state migration error Fabiano Rosas
2023-07-06 19:52 ` Fabiano Rosas [this message]
2023-07-13 11:23 ` [PATCH 2/2] migration: Make it clear that qemu_file_set_error() needs a negative value Peter Maydell
2023-07-13 13:18 ` Fabiano Rosas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230706195201.18595-3-farosas@suse.de \
--to=farosas@suse.de \
--cc=leobras@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).