From: Steve Sistare <steven.sistare@oracle.com>
To: qemu-devel@nongnu.org
Cc: Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>,
Peter Maydell <peter.maydell@linaro.org>,
Steve Sistare <steven.sistare@oracle.com>
Subject: [PATCH] migration: use parameters.mode in cpr_state_save
Date: Wed, 5 Feb 2025 12:54:01 -0800 [thread overview]
Message-ID: <1738788841-211843-1-git-send-email-steven.sistare@oracle.com> (raw)
qmp_migrate guarantees that cpr_channel is not null for
MIG_MODE_CPR_TRANSFER when cpr_state_save is called:
qmp_migrate()
if (s->parameters.mode == MIG_MODE_CPR_TRANSFER && !cpr_channel) {
return;
}
cpr_state_save(cpr_channel)
but cpr_state_save checks for mode differently before using channel,
and Coverity cannot infer that they are equivalent in outgoing QEMU,
and warns that channel may be NULL:
cpr_state_save(channel)
MigMode mode = migrate_mode();
if (mode == MIG_MODE_CPR_TRANSFER) {
f = cpr_transfer_output(channel, errp);
To make Coverity happy, use parameters.mode in cpr_state_save.
Resolves: Coverity CID 1590980
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
migration/cpr.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/migration/cpr.c b/migration/cpr.c
index 584b0b9..7f20bd5 100644
--- a/migration/cpr.c
+++ b/migration/cpr.c
@@ -8,6 +8,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "migration/cpr.h"
+#include "migration/migration.h"
#include "migration/misc.h"
#include "migration/options.h"
#include "migration/qemu-file.h"
@@ -132,7 +133,7 @@ int cpr_state_save(MigrationChannel *channel, Error **errp)
{
int ret;
QEMUFile *f;
- MigMode mode = migrate_mode();
+ MigMode mode = migrate_get_current()->parameters.mode;
trace_cpr_state_save(MigMode_str(mode));
--
1.8.3.1
next reply other threads:[~2025-02-05 20:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-05 20:54 Steve Sistare [this message]
2025-02-05 21:28 ` [PATCH] migration: use parameters.mode in cpr_state_save Peter Xu
2025-02-05 21:52 ` Steven Sistare
2025-02-07 20:02 ` Steven Sistare
2025-02-14 13:14 ` 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=1738788841-211843-1-git-send-email-steven.sistare@oracle.com \
--to=steven.sistare@oracle.com \
--cc=farosas@suse.de \
--cc=peter.maydell@linaro.org \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).