summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorSteve Sistare <steven.sistare@oracle.com>2025-02-05 12:54:01 -0800
committerFabiano Rosas <farosas@suse.de>2025-02-14 15:19:06 -0300
commitb451705e3b90e55c6070338fa97aaae274721a5c (patch)
treeeea2c61201338f791e6d7d6bb32215c7fc23fe5d
parent24f4c80cfc31ab4ed4cb6553c9289e3cf8ca63ac (diff)
downloadfocaccia-qemu-b451705e3b90e55c6070338fa97aaae274721a5c.tar.gz
focaccia-qemu-b451705e3b90e55c6070338fa97aaae274721a5c.zip
migration: use parameters.mode in cpr_state_save
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, assert that channel != NULL 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>
Message-ID: <1738788841-211843-1-git-send-email-steven.sistare@oracle.com>
[assert instead of using parameters.mode in cpr_state_save]
Signed-off-by: Fabiano Rosas <farosas@suse.de>
Diffstat (limited to '')
-rw-r--r--migration/cpr.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/migration/cpr.c b/migration/cpr.c
index 584b0b98f7..180faab247 100644
--- a/migration/cpr.c
+++ b/migration/cpr.c
@@ -137,6 +137,7 @@ int cpr_state_save(MigrationChannel *channel, Error **errp)
     trace_cpr_state_save(MigMode_str(mode));
 
     if (mode == MIG_MODE_CPR_TRANSFER) {
+        g_assert(channel);
         f = cpr_transfer_output(channel, errp);
     } else {
         return 0;