qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/5] migration: never fail in global_state_store()


From: Vladimir Sementsov-Ogievskiy
Subject: Re: [PATCH 2/5] migration: never fail in global_state_store()
Date: Thu, 18 May 2023 17:43:35 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0

On 18.05.23 14:18, Juan Quintela wrote:
Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> wrote:
Actually global_state_store() can never fail. Let's get rid of extra
error paths.

To make things clear, use new runstate_get() and use same approach for
global_state_store() and global_state_store_running().

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>

I don't know.

On one hand, you have removed a lot of code that "can't" happen.

On the other:

+static void global_state_do_store(RunState state)
  {
-    if (!runstate_store((char *)global_state.runstate,
-                        sizeof(global_state.runstate))) {
-        error_report("runstate name too big: %s", global_state.runstate);
-        trace_migrate_state_too_big();
-        return -EINVAL;
-    }
-    return 0;
+    const char *state_str = RunState_str(state);
+    assert(strlen(state_str) < sizeof(global_state.runstate));

First: g_assert() please.

Second: We try really hard not to fail during migration and get the
whole qemu back.  One assert is bad.  Specially in a place like this
one, where we know that nothing is broken, simpli that we can't migrate.


On the other hand, having runstate longer than 100 characters means memory 
corruption, so aborting QEMU is best we can do

--
Best regards,
Vladimir




reply via email to

[Prev in Thread] Current Thread [Next in Thread]