On Tue, May 06, 2025 at 17:08:18 +0300, Dmitry Frolov wrote:
> Enum variable of type qemuMigrationCapability is checked for zero in
> src/qemu/qemu_migration_params.c:729.
> 
> "if (item->optional) { ..."
> 
> Actualy, QEMU_MIGRATION_CAP_XBZRLE enum constant has value 0.
> Thus, all uninitialized .optinnal fields of the static array
> qemuMigrationParamsFlagMap[] will be implicitly initialized with
> value 0 (QEMU_MIGRATION_CAP_XBZRLE).

Heh, funny.

> To my opinion, introducing a separate enum for optional capabilities,
> would be a better solution.

First, the bug does not actually cause any issues in real world as it
only means QEMU_MIGRATION_CAP_XBZRLE can never be used as an optional
feature. And it isn't used that way anywhere.

Your solution is not fixing any real bug while breaking a lot of stuff.
Just grep for QEMU_MIGRATION_CAP_LAST in the code and you'll see several
places broken by this patch.

Since the optional capability is always converted to a bitmap when
non-zero, we could just as well try to specify it as such right away.
It's just an idea that came to my mind when looking at this patch. I
haven't really checked whether it's reasonably doable :-)

Jirka

Reply via email to