]> git.ipfire.org Git - thirdparty/libvirt.git/commit
qemu: Move 'shmem' device size validation to qemu_validate
authorPeter Krempa <pkrempa@redhat.com>
Mon, 18 Dec 2023 23:16:29 +0000 (00:16 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 17 Jan 2024 16:31:12 +0000 (17:31 +0100)
commit7dd3d779407b42d4bfea0f951c0ce4ed38d356df
tree6ee5ed9270edd8212667c89438987835bddbfce3
parentdeb3c834e5dbcfb9c50f990ee124215f942f6a01
qemu: Move 'shmem' device size validation to qemu_validate

The 'size' of a 'shmem' device is parsed and formatted as a "scaled"
value, stored in bytes, but the formatting scale is mebibytes. This
precission loss combined with the fact that the value was validated only
when starting and the size is formatted only when non-zero meant that
on first parse a value < 1 MiB would be accepted, but would be formatted
to the XML as 0 MiB as it was non-zero but truncated and a subsequent
parse would parse of such XML would parse it as 0 bytes, which in turn
would be interpreted as 'default' size.

Fix the issue by moving the validator, which ensures that the number is
a power of two and more than 1 MiB to the validator code so that it'll
be rejected at XML parsing time.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_command.c
src/qemu/qemu_validate.c
tests/qemuxml2argvdata/shmem-invalid-size.x86_64-latest.err
tests/qemuxml2argvdata/shmem-small-size.x86_64-latest.err
tests/qemuxml2xmloutdata/shmem-invalid-size.x86_64-latest.xml [deleted file]
tests/qemuxml2xmloutdata/shmem-small-size.x86_64-latest.xml [deleted file]
tests/qemuxmlconftest.c